diff options
author | Benoit Foucher <benoit@zeroc.com> | 2014-09-26 18:39:28 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2014-09-26 18:39:28 +0200 |
commit | aa3c4ebfa279188cf689c6ef2318ed573c4fec7b (patch) | |
tree | c7c1c9b7b6ce2daee3cd9b5507a49d3520fd1d06 /java/src/IceInternal/QueueRequestHandler.java | |
parent | Slightly improved fix for ICE-3692 (diff) | |
download | ice-aa3c4ebfa279188cf689c6ef2318ed573c4fec7b.tar.bz2 ice-aa3c4ebfa279188cf689c6ef2318ed573c4fec7b.tar.xz ice-aa3c4ebfa279188cf689c6ef2318ed573c4fec7b.zip |
Fixed deadlock in connection binding code (ICE-5693)
Diffstat (limited to 'java/src/IceInternal/QueueRequestHandler.java')
-rw-r--r-- | java/src/IceInternal/QueueRequestHandler.java | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/java/src/IceInternal/QueueRequestHandler.java b/java/src/IceInternal/QueueRequestHandler.java index 6709c2f7ab3..c4c315e7f5c 100644 --- a/java/src/IceInternal/QueueRequestHandler.java +++ b/java/src/IceInternal/QueueRequestHandler.java @@ -29,6 +29,76 @@ public class QueueRequestHandler implements RequestHandler } @Override + public RequestHandler + connect() + { + try + { + Future<Void> future = _executor.submit(new Callable<Void>() + { + @Override + public Void call() throws RetryException + { + _delegate.connect(); + return null; + } + }); + + // + // Just wait for connect() to complete, don't return the + // request handler returned by connect() since it's not + // interrupt safe. + // + future.get(); + } + catch(RejectedExecutionException e) + { + throw new CommunicatorDestroyedException(); + } + catch(InterruptedException e) + { + throw new Ice.OperationInterruptedException(); + } + catch(ExecutionException e) + { + try + { + throw e.getCause(); + } + catch(RuntimeException ex) + { + throw ex; + } + catch(Throwable ex) + { + assert(false); + } + } + return this; + } + + @Override + public RequestHandler + update(RequestHandler previousHandler, RequestHandler newHandler) + { + // + // Only update to new handler if the previous handler matches this one. + // + if(previousHandler == this) + { + if(newHandler != null) + { + return new QueueRequestHandler(_delegate.getReference().getInstance(), newHandler); + } + else + { + return null; + } + } + return this; + } + + @Override public void prepareBatchRequest(final BasicStream out) throws RetryException { |