- cancels future on timeout before making callback
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/branches/common/common-clients/2.0@58663 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c87ab663b4
commit
03c5360ad5
|
@ -186,11 +186,12 @@ public class AsyncProxyDelegate<S> implements ProxyDelegate<S> {
|
|||
|
||||
} catch (TimeoutException e) {
|
||||
|
||||
// attempt to cancel the call, in case it's designed for it
|
||||
callFuture.cancel(true);
|
||||
|
||||
// notify callback the required timeout has expired
|
||||
callback.onFailure(e);
|
||||
|
||||
// attempt to cancel the call, in case it's designed for it
|
||||
callFuture.cancel(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -215,7 +215,7 @@ public class AsyncDelegateTest {
|
|||
|
||||
@SuppressWarnings("all")
|
||||
Callback<Object> callback = mock(Callback.class);
|
||||
when(callback.timeout()).thenReturn(50L);
|
||||
when(callback.timeout()).thenReturn(100L);
|
||||
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
|
@ -229,12 +229,10 @@ public class AsyncDelegateTest {
|
|||
|
||||
doAnswer(unblock).when(callback).onFailure(any(TimeoutException.class));
|
||||
|
||||
Future<?> future = delegate.makeAsync(call,callback);
|
||||
delegate.makeAsync(call,callback);
|
||||
|
||||
//makes sure callback has been invoked
|
||||
latch.await(5,SECONDS);
|
||||
|
||||
assertTrue(future.isCancelled());
|
||||
assertTrue(latch.await(5,SECONDS));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue