@Test public void testAllocate_FailThenSucceed() throws Exception { TestPoolable value = new TestPoolable("value"); when(allocator.allocate(slot)) .thenThrow(new IOException()) .thenThrow(new IOException()) .thenThrow(new IOException()) .thenReturn(value); Assert.assertSame(value, retryingAllocator.allocate(slot)); Mockito.verify(allocator, atLeast(2)).allocate(slot); }
@Override public V allocate(final Slot slot) throws Exception { return retryer.call(new Callable<V>() { @Override public V call() throws Exception { return allocator.allocate(slot); } }); }
RetryingAllocator implements Allocator<V> { @Override public V allocate(final Slot slot) throws Exception { return retryer.call(new Callable<V>() { @Override public V call() throws Exception { return allocator.allocate(slot); } }); } }
RetryingAllocator implements Allocator<V> { @Override public V allocate(final Slot slot) throws Exception { return retryer.call(new Callable<V>() { @Override public V call() throws Exception { return allocator.allocate(slot); } }); } RetryingAllocator(Allocator<V> allocator);  RetryingAllocator(Allocator<V> allocator, long waitInterval, long maxWaitInterval); }
RetryingAllocator implements Allocator<V> { @Override public V allocate(final Slot slot) throws Exception { return retryer.call(new Callable<V>() { @Override public V call() throws Exception { return allocator.allocate(slot); } }); } RetryingAllocator(Allocator<V> allocator);  RetryingAllocator(Allocator<V> allocator, long waitInterval, long maxWaitInterval); @Override V allocate(final Slot slot); @Override void deallocate(V poolable); }
RetryingAllocator implements Allocator<V> { @Override public V allocate(final Slot slot) throws Exception { return retryer.call(new Callable<V>() { @Override public V call() throws Exception { return allocator.allocate(slot); } }); } RetryingAllocator(Allocator<V> allocator);  RetryingAllocator(Allocator<V> allocator, long waitInterval, long maxWaitInterval); @Override V allocate(final Slot slot); @Override void deallocate(V poolable);  }