summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2019-09-24 11:10:14 +0200
committerBenoit Foucher <benoit@zeroc.com>2019-09-24 11:10:14 +0200
commit5b186e09fed963d1a5c7b711957c40fc757aaafb (patch)
tree6ef5a777a3bc4577b97fa5ee503113b1d5a6f812 /java
parentMissing icon for Swift iOS test driver - Close #544 (diff)
downloadice-5b186e09fed963d1a5c7b711957c40fc757aaafb.tar.bz2
ice-5b186e09fed963d1a5c7b711957c40fc757aaafb.tar.xz
ice-5b186e09fed963d1a5c7b711957c40fc757aaafb.zip
Fixed retry in Java to no longer rely on Future cancel, fixes #538
Diffstat (limited to 'java')
-rw-r--r--java/src/Ice/src/main/java/com/zeroc/IceInternal/RetryTask.java47
1 files changed, 36 insertions, 11 deletions
diff --git a/java/src/Ice/src/main/java/com/zeroc/IceInternal/RetryTask.java b/java/src/Ice/src/main/java/com/zeroc/IceInternal/RetryTask.java
index e451e427b16..4fef01ecd47 100644
--- a/java/src/Ice/src/main/java/com/zeroc/IceInternal/RetryTask.java
+++ b/java/src/Ice/src/main/java/com/zeroc/IceInternal/RetryTask.java
@@ -16,21 +16,24 @@ class RetryTask implements Runnable, CancellationHandler
@Override
public void run()
{
- _outAsync.retry();
+ if(cancel())
+ {
+ _outAsync.retry();
- //
- // NOTE: this must be called last, destroy() blocks until all task
- // are removed to prevent the client thread pool to be destroyed
- // (we still need the client thread pool at this point to call
- // exception callbacks with CommunicatorDestroyedException).
- //
- _queue.remove(this);
+ //
+ // NOTE: this must be called last, destroy() blocks until all task
+ // are removed to prevent the client thread pool to be destroyed
+ // (we still need the client thread pool at this point to call
+ // exception callbacks with CommunicatorDestroyedException).
+ //
+ _queue.remove(this);
+ }
}
@Override
public void asyncRequestCanceled(OutgoingAsyncBase outAsync, com.zeroc.Ice.LocalException ex)
{
- if(_queue.remove(this) && _future.cancel(false))
+ if(_queue.remove(this) && cancel())
{
if(_instance.traceLevels().retry >= 1)
{
@@ -48,7 +51,7 @@ class RetryTask implements Runnable, CancellationHandler
public boolean destroy()
{
- if(_future.cancel(false))
+ if(cancel())
{
try
{
@@ -63,13 +66,35 @@ class RetryTask implements Runnable, CancellationHandler
return false;
}
- public void setFuture(java.util.concurrent.Future<?> future)
+ synchronized public void setFuture(java.util.concurrent.Future<?> future)
{
_future = future;
+ if(_cancelled)
+ {
+ _future.cancel(false);
+ }
+ }
+
+ synchronized private boolean cancel()
+ {
+ if(_cancelled)
+ {
+ return false;
+ }
+ else
+ {
+ if(_future != null)
+ {
+ _future.cancel(false);
+ }
+ _cancelled = true;
+ return true;
+ }
}
private final Instance _instance;
private final RetryQueue _queue;
private final ProxyOutgoingAsyncBase _outAsync;
private java.util.concurrent.Future<?> _future;
+ private boolean _cancelled = false;
}