diff options
author | Matthew Newhook <matthew@zeroc.com> | 2014-10-03 15:34:33 -0230 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2014-10-03 15:34:33 -0230 |
commit | b530efc5ccfb6c2b6e096933431f1f1827851996 (patch) | |
tree | 32436ff41466bb7339d250477cda3a4ec7708075 /java/src | |
parent | ICE-5613 - Systemd service support (diff) | |
download | ice-b530efc5ccfb6c2b6e096933431f1f1827851996.tar.bz2 ice-b530efc5ccfb6c2b6e096933431f1f1827851996.tar.xz ice-b530efc5ccfb6c2b6e096933431f1f1827851996.zip |
- Java Application now catches OperationInterruptedException and
retries.
- Removed the InProgress state from Instance, simplified and corrected
the destroy logic.
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/Application.java | 13 | ||||
-rw-r--r-- | java/src/Ice/ConnectionI.java | 2 | ||||
-rw-r--r-- | java/src/IceInternal/Instance.java | 34 |
3 files changed, 22 insertions, 27 deletions
diff --git a/java/src/Ice/Application.java b/java/src/Ice/Application.java index 4190f39043e..ab9a72f272d 100644 --- a/java/src/Ice/Application.java +++ b/java/src/Ice/Application.java @@ -276,7 +276,18 @@ public abstract class Application { try { - _communicator.destroy(); + try + { + _communicator.destroy(); + } + catch(Ice.OperationInterruptedException ex) + { + Util.getProcessLogger().error(IceInternal.Ex.toString(ex)); + // Retry communicator destroy in case of an operation + // interrupt exception, but don't do so in a loop + // otherwise it could go on forever. + _communicator.destroy(); + } } catch(LocalException ex) { diff --git a/java/src/Ice/ConnectionI.java b/java/src/Ice/ConnectionI.java index fe26e8c1104..3e2b9b70c7e 100644 --- a/java/src/Ice/ConnectionI.java +++ b/java/src/Ice/ConnectionI.java @@ -1735,7 +1735,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne // If setState() is called with an exception, then only closed // and closing states are permissible. // - assert (state >= StateClosing); + assert state >= StateClosing; if(_state == state) // Don't switch twice. { diff --git a/java/src/IceInternal/Instance.java b/java/src/IceInternal/Instance.java index 83725c1afdc..e1f323cb229 100644 --- a/java/src/IceInternal/Instance.java +++ b/java/src/IceInternal/Instance.java @@ -1140,7 +1140,7 @@ public final class Instance getAdmin(); } } - + // // Only for use by Ice.CommunicatorI // @@ -1152,27 +1152,6 @@ public final class Instance throw new Ice.OperationInterruptedException(); } - synchronized(this) - { - // - // If the _state is not StateActive then the instance is - // either being destroyed, or has already been destroyed. - // - if(_state != StateActive) - { - return; - } - - // - // We cannot set state to StateDestroyed otherwise instance - // methods called during the destroy process (such as - // outgoingConnectionFactory() from - // ObjectAdapterI::deactivate() will cause an exception. - // - _state = StateDestroyInProgress; - } - - if(_objectAdapterFactory != null) { _objectAdapterFactory.shutdown(); @@ -1222,6 +1201,7 @@ public final class Instance ThreadPool clientThreadPool = null; EndpointHostResolver endpointHostResolver = null; ExecutorService queueExecutor = null; + boolean checkUnused = false; synchronized(this) { _objectAdapterFactory = null; @@ -1306,6 +1286,10 @@ public final class Instance _typeToClassMap.clear(); + if(_state != StateDestroyed) + { + checkUnused = true; + } _state = StateDestroyed; } @@ -1335,6 +1319,7 @@ public final class Instance if(queueExecutor != null) { queueExecutor.shutdown(); + try { queueExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); @@ -1346,7 +1331,7 @@ public final class Instance queueExecutor = null; } - if(_initData.properties.getPropertyAsInt("Ice.Warn.UnusedProperties") > 0) + if(checkUnused && _initData.properties.getPropertyAsInt("Ice.Warn.UnusedProperties") > 0) { java.util.List<String> unusedProperties = ((Ice.PropertiesI)_initData.properties).getUnusedProperties(); if(unusedProperties.size() != 0) @@ -1552,8 +1537,7 @@ public final class Instance } private static final int StateActive = 0; - private static final int StateDestroyInProgress = 1; - private static final int StateDestroyed = 2; + private static final int StateDestroyed = 1; private int _state; private final Ice.InitializationData _initData; // Immutable, not reset by destroy(). |