diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/IceInternal/Instance.java | 74 | ||||
-rw-r--r-- | java/src/IceInternal/Network.java | 43 | ||||
-rw-r--r-- | java/src/IceInternal/SelectorThread.java | 20 | ||||
-rw-r--r-- | java/src/IceInternal/TcpConnector.java | 9 | ||||
-rw-r--r-- | java/src/IceInternal/TcpTransceiver.java | 9 | ||||
-rw-r--r-- | java/src/IceInternal/UdpTransceiver.java | 9 | ||||
-rw-r--r-- | java/src/IceSSL/ConnectorI.java | 9 | ||||
-rw-r--r-- | java/src/IceSSL/TransceiverI.java | 29 |
8 files changed, 80 insertions, 122 deletions
diff --git a/java/src/IceInternal/Instance.java b/java/src/IceInternal/Instance.java index e494bb9c4d7..37f95cfe1ff 100644 --- a/java/src/IceInternal/Instance.java +++ b/java/src/IceInternal/Instance.java @@ -27,6 +27,7 @@ public final class Instance traceLevels() { // No mutex lock, immutable. + assert(_traceLevels != null); return _traceLevels; } @@ -34,6 +35,7 @@ public final class Instance defaultsAndOverrides() { // No mutex lock, immutable. + assert(_defaultsAndOverrides != null); return _defaultsAndOverrides; } @@ -45,6 +47,7 @@ public final class Instance throw new Ice.CommunicatorDestroyedException(); } + assert(_routerManager != null); return _routerManager; } @@ -56,6 +59,7 @@ public final class Instance throw new Ice.CommunicatorDestroyedException(); } + assert(_locatorManager != null); return _locatorManager; } @@ -67,6 +71,7 @@ public final class Instance throw new Ice.CommunicatorDestroyedException(); } + assert(_referenceFactory != null); return _referenceFactory; } @@ -78,6 +83,7 @@ public final class Instance throw new Ice.CommunicatorDestroyedException(); } + assert(_proxyFactory != null); return _proxyFactory; } @@ -89,6 +95,7 @@ public final class Instance throw new Ice.CommunicatorDestroyedException(); } + assert(_outgoingConnectionFactory != null); return _outgoingConnectionFactory; } @@ -100,6 +107,7 @@ public final class Instance throw new Ice.CommunicatorDestroyedException(); } + //assert(_connectionMonitor != null); // Optional return _connectionMonitor; } @@ -111,6 +119,7 @@ public final class Instance throw new Ice.CommunicatorDestroyedException(); } + assert(_servantFactoryManager != null); return _servantFactoryManager; } @@ -122,6 +131,7 @@ public final class Instance throw new Ice.CommunicatorDestroyedException(); } + assert(_objectAdapterFactory != null); return _objectAdapterFactory; } @@ -143,12 +153,8 @@ public final class Instance { throw new Ice.CommunicatorDestroyedException(); } - - if(_clientThreadPool == null) // Lazy initialization. - { - _clientThreadPool = new ThreadPool(this, "Ice.ThreadPool.Client", 0); - } + assert(_clientThreadPool != null); return _clientThreadPool; } @@ -177,11 +183,7 @@ public final class Instance throw new Ice.CommunicatorDestroyedException(); } - if(_selectorThread == null) // Lazy initialization. - { - _selectorThread = new SelectorThread(this); - } - + assert(_selectorThread != null); return _selectorThread; } @@ -193,11 +195,7 @@ public final class Instance throw new Ice.CommunicatorDestroyedException(); } - if(_endpointHostResolver == null) // Lazy initialization. - { - _endpointHostResolver = new EndpointHostResolver(this); - } - + assert(_endpointHostResolver != null); return _endpointHostResolver; } @@ -209,6 +207,7 @@ public final class Instance throw new Ice.CommunicatorDestroyedException(); } + assert(_retryQueue != null); return _retryQueue; } @@ -220,11 +219,7 @@ public final class Instance throw new Ice.CommunicatorDestroyedException(); } - if(_timer == null) // Lazy initialization. - { - _timer = new Timer(this); - } - + assert(_timer != null); return _timer; } @@ -236,6 +231,7 @@ public final class Instance throw new Ice.CommunicatorDestroyedException(); } + assert(_endpointFactoryManager != null); return _endpointFactoryManager; } @@ -247,6 +243,7 @@ public final class Instance throw new Ice.CommunicatorDestroyedException(); } + assert(_pluginManager != null); return _pluginManager; } @@ -726,6 +723,40 @@ public final class Instance _retryQueue = new RetryQueue(this); + try + { + _endpointHostResolver = new EndpointHostResolver(this); + } + catch(RuntimeException ex) + { + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + ex.printStackTrace(pw); + pw.flush(); + String s = "cannot create thread for endpoint host resolver:\n" + sw.toString(); + _initData.logger.error(s); + throw ex; + } + + try + { + _timer = new Timer(this); + } + catch(RuntimeException ex) + { + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + ex.printStackTrace(pw); + pw.flush(); + String s = "cannot create thread for timer:\n" + sw.toString(); + _initData.logger.error(s); + throw ex; + } + + _clientThreadPool = new ThreadPool(this, "Ice.ThreadPool.Client", 0); + + _selectorThread = new SelectorThread(this); + // // Add Process and Properties facets // @@ -838,8 +869,7 @@ public final class Instance } // - // Thread pool initialization is now lazy initialization in - // clientThreadPool() and serverThreadPool(). + // Server thread pool initialization is lazy in serverThreadPool(). // } diff --git a/java/src/IceInternal/Network.java b/java/src/IceInternal/Network.java index e7130b41bd4..40b411d5f9d 100644 --- a/java/src/IceInternal/Network.java +++ b/java/src/IceInternal/Network.java @@ -17,45 +17,6 @@ public final class Network public final static int EnableBoth = 2; public static boolean - connectionLost(java.io.IOException ex) - { - // - // TODO: The JDK raises a generic IOException for certain - // cases of connection loss. Unfortunately, our only choice is - // to search the exception message for distinguishing phrases. - // - String msg = ex.getMessage(); - if(msg != null) - { - msg = msg.toLowerCase(); - - final String[] msgs = - { - "connection reset by peer", // ECONNRESET - "cannot send after socket shutdown", // ESHUTDOWN (Win32) - "cannot send after transport endpoint shutdown", // ESHUTDOWN (Linux) - "software caused connection abort", // ECONNABORTED - "an existing connection was forcibly closed", // unknown - "connection closed by remote host", // unknown - "an established connection was aborted by the software in your host machine", // unknown (Win32) - "broken pipe", // EPIPE - "there is no process to read data written to a pipe", // EPIPE? (AIX JDK 1.4.2) - "socket is closed" // unknown (AIX JDK 1.4.2) - }; - - for(int i = 0; i < msgs.length; i++) - { - if(msg.indexOf(msgs[i]) != -1) - { - return true; - } - } - } - - return false; - } - - public static boolean connectionRefused(java.net.ConnectException ex) { // @@ -1184,9 +1145,7 @@ public final class Network public static boolean interrupted(java.io.IOException ex) { - return ex instanceof java.io.InterruptedIOException || - ex.getMessage().indexOf("Interrupted system call") >= 0 || - ex.getMessage().indexOf("A system call received an interrupt") >= 0; // AIX JDK 1.4.2 + return ex instanceof java.io.InterruptedIOException; } private static java.net.InetSocketAddress diff --git a/java/src/IceInternal/SelectorThread.java b/java/src/IceInternal/SelectorThread.java index c253b785546..ae532792540 100644 --- a/java/src/IceInternal/SelectorThread.java +++ b/java/src/IceInternal/SelectorThread.java @@ -34,8 +34,24 @@ public class SelectorThread _destroyed = false; _selector = new Selector(instance, 0); - _thread = new HelperThread(); - _thread.start(); + try + { + _thread = new HelperThread(); + _thread.start(); + } + catch(RuntimeException ex) + { + _selector.destroy(); + _selector = null; + + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + ex.printStackTrace(pw); + pw.flush(); + String s = "cannot create thread for selector thread:\n" + sw.toString(); + _instance.initializationData().logger.error(s); + throw ex; + } _timer = _instance.timer(); } diff --git a/java/src/IceInternal/TcpConnector.java b/java/src/IceInternal/TcpConnector.java index 2f9d4f99a14..3e524736f13 100644 --- a/java/src/IceInternal/TcpConnector.java +++ b/java/src/IceInternal/TcpConnector.java @@ -133,15 +133,6 @@ final class TcpConnector implements Connector, java.lang.Comparable return _connectionId.compareTo(p._connectionId); } - if(_timeout < p._timeout) - { - return -1; - } - else if(p._timeout < _timeout) - { - return 1; - } - return Network.compareAddress(_addr, p._addr); } diff --git a/java/src/IceInternal/TcpTransceiver.java b/java/src/IceInternal/TcpTransceiver.java index 2e7b9f2bfd2..3a12a0a9154 100644 --- a/java/src/IceInternal/TcpTransceiver.java +++ b/java/src/IceInternal/TcpTransceiver.java @@ -198,14 +198,7 @@ final class TcpTransceiver implements Transceiver } catch(java.io.IOException ex) { - if(Network.connectionLost(ex)) - { - Ice.ConnectionLostException se = new Ice.ConnectionLostException(); - se.initCause(ex); - throw se; - } - - Ice.SocketException se = new Ice.SocketException(); + Ice.ConnectionLostException se = new Ice.ConnectionLostException(); se.initCause(ex); throw se; } diff --git a/java/src/IceInternal/UdpTransceiver.java b/java/src/IceInternal/UdpTransceiver.java index 52000361be0..c23a695c79a 100644 --- a/java/src/IceInternal/UdpTransceiver.java +++ b/java/src/IceInternal/UdpTransceiver.java @@ -187,14 +187,7 @@ final class UdpTransceiver implements Transceiver } catch(java.io.IOException ex) { - if(Network.connectionLost(ex)) - { - Ice.ConnectionLostException se = new Ice.ConnectionLostException(); - se.initCause(ex); - throw se; - } - - Ice.SocketException se = new Ice.SocketException(); + Ice.ConnectionLostException se = new Ice.ConnectionLostException(); se.initCause(ex); throw se; } diff --git a/java/src/IceSSL/ConnectorI.java b/java/src/IceSSL/ConnectorI.java index 51f490975eb..ca5601c83a0 100644 --- a/java/src/IceSSL/ConnectorI.java +++ b/java/src/IceSSL/ConnectorI.java @@ -144,15 +144,6 @@ final class ConnectorI implements IceInternal.Connector, java.lang.Comparable return _connectionId.compareTo(p._connectionId); } - if(_timeout < p._timeout) - { - return -1; - } - else if(p._timeout < _timeout) - { - return 1; - } - return IceInternal.Network.compareAddress(_addr, p._addr); } diff --git a/java/src/IceSSL/TransceiverI.java b/java/src/IceSSL/TransceiverI.java index 4a90b8c05df..99fddae6a51 100644 --- a/java/src/IceSSL/TransceiverI.java +++ b/java/src/IceSSL/TransceiverI.java @@ -85,8 +85,8 @@ final class TransceiverI implements IceInternal.Transceiver try { // - // Note: we can't block to send the close_notify message. In some cases, the - // close_notify message might therefore not be receieved by the peer. This is + // Note: we can't block to send the close_notify message. In some cases, the + // close_notify message might therefore not be receieved by the peer. This is // not a big issue since the Ice protocol isn't subject to truncation attacks. // flushNonBlocking(); @@ -160,8 +160,8 @@ final class TransceiverI implements IceInternal.Transceiver read(IceInternal.Buffer buf, Ice.BooleanHolder moreData) { // - // If the handshake isn't completed yet, we shouldn't be reading (read can be - // called by the thread pool when the connection is registered/unregistered + // If the handshake isn't completed yet, we shouldn't be reading (read can be + // called by the thread pool when the connection is registered/unregistered // with the pool to be closed). // if(_state < StateHandshakeComplete) @@ -471,7 +471,7 @@ final class TransceiverI implements IceInternal.Transceiver // if(!_incoming) { - int verifyPeer = + int verifyPeer = _instance.communicator().getProperties().getPropertyAsIntWithDefault("IceSSL.VerifyPeer", 2); if(verifyPeer > 0) { @@ -652,14 +652,7 @@ final class TransceiverI implements IceInternal.Transceiver } catch(java.io.IOException ex) { - if(IceInternal.Network.connectionLost(ex)) - { - Ice.ConnectionLostException se = new Ice.ConnectionLostException(); - se.initCause(ex); - throw se; - } - - Ice.SocketException se = new Ice.SocketException(); + Ice.ConnectionLostException se = new Ice.ConnectionLostException(); se.initCause(ex); throw se; } @@ -678,7 +671,6 @@ final class TransceiverI implements IceInternal.Transceiver return status; } - private IceInternal.SocketStatus readNonBlocking() { @@ -706,14 +698,7 @@ final class TransceiverI implements IceInternal.Transceiver } catch(java.io.IOException ex) { - if(IceInternal.Network.connectionLost(ex)) - { - Ice.ConnectionLostException se = new Ice.ConnectionLostException(); - se.initCause(ex); - throw se; - } - - Ice.SocketException se = new Ice.SocketException(); + Ice.ConnectionLostException se = new Ice.ConnectionLostException(); se.initCause(ex); throw se; } |