summaryrefslogtreecommitdiff
path: root/java/src/Ice/ObjectPrxHelperBase.java
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2014-08-07 14:36:07 -0230
committerMatthew Newhook <matthew@zeroc.com>2014-08-07 14:36:07 -0230
commitb36ae21c88735cbd2c39c5ccde2572a8fcc4e928 (patch)
treedfd5eee6e7d61a9c6efcbaabe916639009aaa9af /java/src/Ice/ObjectPrxHelperBase.java
parentAdd @Override where possible, and remove trailing white space. (diff)
downloadice-b36ae21c88735cbd2c39c5ccde2572a8fcc4e928.tar.bz2
ice-b36ae21c88735cbd2c39c5ccde2572a8fcc4e928.tar.xz
ice-b36ae21c88735cbd2c39c5ccde2572a8fcc4e928.zip
ICE-1593 Handling thread interrupts in Java
- Added Ice.BackgroundIO property to perform all IO in a non-user thread. This makes Ice for Java interrupt safe. This is implemented by the QueueRequestHanbler. - EndpointHostResolver now uses an executor instead of a thread. - Added java/demo/Ice/interrupt and java/test/Ice/interrupt. - Made several changes that must be ported to C++ & C#. - InvocationTimeout exceptions can hang forever. - Connection establishment is always asynchronous. - RequestHandler.requestTimeout and asyncRequestTimeout have been renamed to requestCancel and asyncRequestCancel.
Diffstat (limited to 'java/src/Ice/ObjectPrxHelperBase.java')
-rw-r--r--java/src/Ice/ObjectPrxHelperBase.java80
1 files changed, 59 insertions, 21 deletions
diff --git a/java/src/Ice/ObjectPrxHelperBase.java b/java/src/Ice/ObjectPrxHelperBase.java
index 27504e0d4c2..2f9d1cd67d4 100644
--- a/java/src/Ice/ObjectPrxHelperBase.java
+++ b/java/src/Ice/ObjectPrxHelperBase.java
@@ -10,6 +10,7 @@
package Ice;
import Ice.Instrumentation.InvocationObserver;
+import IceInternal.QueueRequestHandler;
/**
* Base class for all proxies.
@@ -2391,8 +2392,15 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
IceInternal.RequestHandler handler = null;
try
{
- handler = __getRequestHandler(false);
- return handler.getConnection(true);
+ handler = __getRequestHandler();
+ try
+ {
+ return handler.waitForConnection();
+ }
+ catch (InterruptedException e)
+ {
+ throw new Ice.OperationInterruptedException();
+ }
}
catch(Ice.Exception ex)
{
@@ -2412,6 +2420,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
}
catch(InterruptedException ex1)
{
+ throw new Ice.OperationInterruptedException();
}
}
}
@@ -2460,7 +2469,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
{
try
{
- return handler.getConnection(false);
+ return handler.getConnection();
}
catch(LocalException ex)
{
@@ -2477,7 +2486,14 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
ice_flushBatchRequests()
{
IceInternal.BatchOutgoing __og = new IceInternal.BatchOutgoing(this, __ice_flushBatchRequests_name);
- __og.invoke();
+ try
+ {
+ __og.invoke();
+ }
+ catch(InterruptedException ex)
+ {
+ throw new Ice.OperationInterruptedException();
+ }
}
/**
@@ -2746,7 +2762,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
}
public final IceInternal.RequestHandler
- __getRequestHandler(boolean async)
+ __getRequestHandler()
{
if(_reference.getCacheConnection())
{
@@ -2756,16 +2772,12 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
{
return _requestHandler;
}
- // async = true to avoid blocking with the proxy mutex locked.
- _requestHandler = createRequestHandler(true);
+ _requestHandler = createRequestHandler();
return _requestHandler;
}
}
- final int mode = _reference.getMode();
- return createRequestHandler(async ||
- mode == IceInternal.Reference.ModeBatchOneway ||
- mode == IceInternal.Reference.ModeBatchDatagram);
+ return createRequestHandler();
}
public void
@@ -2777,7 +2789,21 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
{
if(previous == _requestHandler)
{
- _requestHandler = handler;
+ if(handler != null)
+ {
+ if(_reference.getInstance().queueRequests())
+ {
+ _requestHandler = new QueueRequestHandler(_reference.getInstance(), handler);
+ }
+ else
+ {
+ _requestHandler = handler;
+ }
+ }
+ else
+ {
+ _requestHandler = null;
+ }
}
else if(previous != null && _requestHandler != null)
{
@@ -2788,9 +2814,23 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
// update the request handler. See bug ICE-5489 for reasons why
// this can be useful.
//
- if(previous.getConnection(false) == _requestHandler.getConnection(false))
+ if(previous.getConnection() == _requestHandler.getConnection())
{
- _requestHandler = handler;
+ if(handler != null)
+ {
+ if(_reference.getInstance().queueRequests())
+ {
+ _requestHandler = new QueueRequestHandler(_reference.getInstance(), handler);
+ }
+ else
+ {
+ _requestHandler = handler;
+ }
+ }
+ else
+ {
+ _requestHandler = null;
+ }
}
}
catch(Ice.Exception ex)
@@ -2803,7 +2843,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
}
private IceInternal.RequestHandler
- createRequestHandler(boolean async)
+ createRequestHandler()
{
if(_reference.getCollocationOptimized())
{
@@ -2814,14 +2854,12 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
}
}
- if(async)
- {
- return (new IceInternal.ConnectRequestHandler(_reference, this)).connect();
- }
- else
+ IceInternal.RequestHandler handler = (new IceInternal.ConnectRequestHandler(_reference, this)).connect();
+ if(_reference.getInstance().queueRequests())
{
- return new IceInternal.ConnectionRequestHandler(_reference, this);
+ handler = new QueueRequestHandler(_reference.getInstance(), handler);
}
+ return handler;
}
//