diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/Blobject.java | 20 | ||||
-rw-r--r-- | java/src/Ice/CommunicatorI.java | 22 | ||||
-rw-r--r-- | java/src/Ice/ObjectPrx.java | 7 | ||||
-rw-r--r-- | java/src/Ice/ObjectPrxHelper.java | 13 | ||||
-rw-r--r-- | java/src/Ice/_ObjectDel.java | 4 | ||||
-rw-r--r-- | java/src/Ice/_ObjectDelD.java | 6 | ||||
-rw-r--r-- | java/src/Ice/_ObjectDelM.java | 28 | ||||
-rw-r--r-- | java/src/IceInternal/Connection.java | 57 | ||||
-rw-r--r-- | java/src/IceInternal/Incoming.java | 4 | ||||
-rw-r--r-- | java/src/IceInternal/IncomingConnectionFactory.java | 21 | ||||
-rw-r--r-- | java/src/IceInternal/Outgoing.java | 9 |
11 files changed, 103 insertions, 88 deletions
diff --git a/java/src/Ice/Blobject.java b/java/src/Ice/Blobject.java index 53904e5c4b6..ee6531e2ac7 100644 --- a/java/src/Ice/Blobject.java +++ b/java/src/Ice/Blobject.java @@ -12,18 +12,26 @@ package Ice; public abstract class Blobject extends Ice.Object { - public abstract byte[] - ice_invoke(byte[] inParams, Current current); + // Returns true if ok, false if user exception. + public abstract boolean + ice_invoke(byte[] inParams, ByteSeqHolder outParams, Current current); public IceInternal.DispatchStatus __dispatch(IceInternal.Incoming in, Current current) { byte[] inParams; - byte[] outParams; + ByteSeqHolder outParams = new ByteSeqHolder(); int sz = in.is().getReadEncapsSize(); inParams = in.is().readBlob(sz); - outParams = ice_invoke(inParams, current); - in.os().writeBlob(outParams); - return IceInternal.DispatchStatus.DispatchOK; + boolean ok = ice_invoke(inParams, outParams, current); + in.os().writeBlob(outParams.value); + if (ok) + { + return IceInternal.DispatchStatus.DispatchOK; + } + else + { + return IceInternal.DispatchStatus.DispatchUserException; + } } } diff --git a/java/src/Ice/CommunicatorI.java b/java/src/Ice/CommunicatorI.java index 898d6f47022..feb80402789 100644 --- a/java/src/Ice/CommunicatorI.java +++ b/java/src/Ice/CommunicatorI.java @@ -62,20 +62,19 @@ class CommunicatorI implements Communicator return _instance.proxyFactory().proxyToString(proxy); } - public ObjectAdapter + public synchronized ObjectAdapter createObjectAdapter(String name) { - ObjectAdapter adapter = - createObjectAdapterFromProperty(name, "Ice.Adapter." + name + - ".Endpoints"); - String router = - _instance.properties().getProperty("Ice.Adapter." + name + - ".Router"); + if (_instance == null) + { + throw new CommunicatorDestroyedException(); + } + + ObjectAdapter adapter = createObjectAdapterFromProperty(name, "Ice.Adapter." + name + ".Endpoints"); + String router = _instance.properties().getProperty("Ice.Adapter." + name + ".Router"); if (router != null) { - adapter.addRouter( - RouterPrxHelper.uncheckedCast( - _instance.proxyFactory().stringToProxy(router))); + adapter.addRouter(RouterPrxHelper.uncheckedCast(_instance.proxyFactory().stringToProxy(router))); } return adapter; } @@ -98,8 +97,7 @@ class CommunicatorI implements Communicator { throw new CommunicatorDestroyedException(); } - return _instance.objectAdapterFactory().createObjectAdapter( - name, endpts); + return _instance.objectAdapterFactory().createObjectAdapter(name, endpts); } public synchronized void diff --git a/java/src/Ice/ObjectPrx.java b/java/src/Ice/ObjectPrx.java index 6431ce2f7c4..94733f64f67 100644 --- a/java/src/Ice/ObjectPrx.java +++ b/java/src/Ice/ObjectPrx.java @@ -29,9 +29,10 @@ public interface ObjectPrx String[] ice_facets(); String[] ice_facets(java.util.Map __context); - byte[] ice_invoke(String operation, boolean nonmutating, byte[] inParams); - byte[] ice_invoke(String operation, boolean nonmutating, byte[] inParams, - java.util.Map __context); + // Returns true if ok, false if user exception. + boolean ice_invoke(String operation, boolean nonmutating, byte[] inParams, ByteSeqHolder outParams); + boolean ice_invoke(String operation, boolean nonmutating, byte[] inParams, ByteSeqHolder outParams, + java.util.Map __context); Identity ice_getIdentity(); diff --git a/java/src/Ice/ObjectPrxHelper.java b/java/src/Ice/ObjectPrxHelper.java index c67b64e424b..4229b949906 100644 --- a/java/src/Ice/ObjectPrxHelper.java +++ b/java/src/Ice/ObjectPrxHelper.java @@ -185,14 +185,14 @@ public class ObjectPrxHelper implements ObjectPrx } } - public final byte[] - ice_invoke(String operation, boolean nonmutating, byte[] inParams) + public final boolean + ice_invoke(String operation, boolean nonmutating, byte[] inParams, ByteSeqHolder outParams) { - return ice_invoke(operation, nonmutating, inParams, null); + return ice_invoke(operation, nonmutating, inParams, outParams, null); } - public final byte[] - ice_invoke(String operation, boolean nonmutating, byte[] inParams, + public final boolean + ice_invoke(String operation, boolean nonmutating, byte[] inParams, ByteSeqHolder outParams, java.util.Map __context) { int __cnt = 0; @@ -201,8 +201,7 @@ public class ObjectPrxHelper implements ObjectPrx try { _ObjectDel __del = __getDelegate(); - return __del.ice_invoke(operation, nonmutating, inParams, - __context); + return __del.ice_invoke(operation, nonmutating, inParams, outParams, __context); } catch (LocationForward __ex) { diff --git a/java/src/Ice/_ObjectDel.java b/java/src/Ice/_ObjectDel.java index cf767e3cd30..a4068fffbb8 100644 --- a/java/src/Ice/_ObjectDel.java +++ b/java/src/Ice/_ObjectDel.java @@ -27,8 +27,8 @@ public interface _ObjectDel String[] ice_facets(java.util.Map __context) throws LocationForward, IceInternal.NonRepeatable; - byte[] ice_invoke(String operation, boolean nonmutating, byte[] inParams, - java.util.Map context) + boolean ice_invoke(String operation, boolean nonmutating, byte[] inParams, ByteSeqHolder outParams, + java.util.Map context) throws LocationForward, IceInternal.NonRepeatable; void ice_flush(); diff --git a/java/src/Ice/_ObjectDelD.java b/java/src/Ice/_ObjectDelD.java index 655cf084e4e..3e527ce6971 100644 --- a/java/src/Ice/_ObjectDelD.java +++ b/java/src/Ice/_ObjectDelD.java @@ -188,8 +188,8 @@ public class _ObjectDelD implements _ObjectDel } } - public byte[] - ice_invoke(String operation, boolean nonmutating, byte[] inParams, + public boolean + ice_invoke(String operation, boolean nonmutating, byte[] inParams, ByteSeqHolder outParams, java.util.Map __context) throws LocationForward, IceInternal.NonRepeatable { @@ -211,7 +211,7 @@ public class _ObjectDelD implements _ObjectDel } try { - return __servant.ice_invoke(inParams, __current); + return __servant.ice_invoke(inParams, outParams, __current); } catch (LocalException ex) { diff --git a/java/src/Ice/_ObjectDelM.java b/java/src/Ice/_ObjectDelM.java index 61e3a77a488..e4dcb4284c9 100644 --- a/java/src/Ice/_ObjectDelM.java +++ b/java/src/Ice/_ObjectDelM.java @@ -17,8 +17,7 @@ public class _ObjectDelM implements _ObjectDel throws LocationForward, IceInternal.NonRepeatable { IceInternal.Outgoing __out = - new IceInternal.Outgoing(__connection, __reference, "ice_isA", - true, __context); + new IceInternal.Outgoing(__connection, __reference, "ice_isA", true, __context); IceInternal.BasicStream __is = __out.is(); IceInternal.BasicStream __os = __out.os(); __os.writeString(__id); @@ -34,8 +33,7 @@ public class _ObjectDelM implements _ObjectDel throws LocationForward, IceInternal.NonRepeatable { IceInternal.Outgoing __out = - new IceInternal.Outgoing(__connection, __reference, "ice_ping", - true, __context); + new IceInternal.Outgoing(__connection, __reference, "ice_ping", true, __context); if (!__out.invoke()) { throw new UnknownUserException(); @@ -47,8 +45,7 @@ public class _ObjectDelM implements _ObjectDel throws LocationForward, IceInternal.NonRepeatable { IceInternal.Outgoing __out = - new IceInternal.Outgoing(__connection, __reference, "ice_ids", - true, __context); + new IceInternal.Outgoing(__connection, __reference, "ice_ids", true, __context); IceInternal.BasicStream __is = __out.is(); IceInternal.BasicStream __os = __out.os(); if (!__out.invoke()) @@ -63,8 +60,7 @@ public class _ObjectDelM implements _ObjectDel throws LocationForward, IceInternal.NonRepeatable { IceInternal.Outgoing __out = - new IceInternal.Outgoing(__connection, __reference, "ice_id", - true, __context); + new IceInternal.Outgoing(__connection, __reference, "ice_id", true, __context); IceInternal.BasicStream __is = __out.is(); IceInternal.BasicStream __os = __out.os(); if (!__out.invoke()) @@ -79,8 +75,7 @@ public class _ObjectDelM implements _ObjectDel throws LocationForward, IceInternal.NonRepeatable { IceInternal.Outgoing __out = - new IceInternal.Outgoing(__connection, __reference, "ice_facets", - true, __context); + new IceInternal.Outgoing(__connection, __reference, "ice_facets", true, __context); IceInternal.BasicStream __is = __out.is(); IceInternal.BasicStream __os = __out.os(); if (!__out.invoke()) @@ -90,24 +85,23 @@ public class _ObjectDelM implements _ObjectDel return __is.readStringSeq(); } - public byte[] - ice_invoke(String operation, boolean nonmutating, byte[] inParams, + public boolean + ice_invoke(String operation, boolean nonmutating, byte[] inParams, ByteSeqHolder outParams, java.util.Map __context) throws LocationForward, IceInternal.NonRepeatable { IceInternal.Outgoing __out = - new IceInternal.Outgoing(__connection, __reference, operation, - nonmutating, __context); + new IceInternal.Outgoing(__connection, __reference, operation, nonmutating, __context); IceInternal.BasicStream __os = __out.os(); __os.writeBlob(inParams); - __out.invoke(); + boolean ok = __out.invoke(); if (__reference.mode == IceInternal.Reference.ModeTwoway) { IceInternal.BasicStream __is = __out.is(); int sz = __is.getReadEncapsSize(); - return __is.readBlob(sz); + outParams.value = __is.readBlob(sz); } - return null; + return ok; } public void diff --git a/java/src/IceInternal/Connection.java b/java/src/IceInternal/Connection.java index 52447ebe0ae..0dc37aeb7d4 100644 --- a/java/src/IceInternal/Connection.java +++ b/java/src/IceInternal/Connection.java @@ -459,7 +459,10 @@ public final class Connection extends EventHandler _mutex.lock(); try { - warning(ex); + if (_warn) + { + warning("connection exception", ex); + } } finally { @@ -468,7 +471,18 @@ public final class Connection extends EventHandler } catch (Exception ex) { - assert(false); // Should not happen + _mutex.lock(); + try + { + if (_warn) + { + warning("unknown exception", ex); + } + } + finally + { + _mutex.unlock(); + } } } while (batch && is.pos() < is.size()); @@ -671,16 +685,19 @@ public final class Connection extends EventHandler { _exception = ex; - // - // Don't warn about certain expected exceptions. - // - if (!(ex instanceof Ice.CloseConnectionException || - ex instanceof Ice.CommunicatorDestroyedException || - ex instanceof Ice.ObjectAdapterDeactivatedException || - (ex instanceof Ice.ConnectionLostException && - _state == StateClosing))) + if (_warn) { - warning(ex); + // + // Don't warn about certain expected exceptions. + // + if (!(ex instanceof Ice.CloseConnectionException || + ex instanceof Ice.CommunicatorDestroyedException || + ex instanceof Ice.ObjectAdapterDeactivatedException || + (ex instanceof Ice.ConnectionLostException && + _state == StateClosing))) + { + warning("connection exception", ex); + } } } @@ -796,18 +813,14 @@ public final class Connection extends EventHandler } private void - warning(Ice.LocalException ex) + warning(String msg, Exception ex) { - if (_warn) - { - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - ex.printStackTrace(pw); - pw.flush(); - String s = "connection exception:\n" + sw.toString() + '\n' + - _transceiver.toString(); - _logger.warning(s); - } + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + ex.printStackTrace(pw); + pw.flush(); + String s = msg + ":\n" + sw.toString() + '\n' + _transceiver.toString(); + _logger.warning(s); } private Transceiver _transceiver; diff --git a/java/src/IceInternal/Incoming.java b/java/src/IceInternal/Incoming.java index 883776175ec..29e0f597631 100644 --- a/java/src/IceInternal/Incoming.java +++ b/java/src/IceInternal/Incoming.java @@ -263,9 +263,7 @@ public class Incoming _os.writeByte((byte)DispatchStatus._DispatchUnknownException); } - Ice.UnknownException ue = new Ice.UnknownException(); - ue.initCause(ex); - throw ue; + throw ex; } } diff --git a/java/src/IceInternal/IncomingConnectionFactory.java b/java/src/IceInternal/IncomingConnectionFactory.java index eb261376ebf..79a4900df86 100644 --- a/java/src/IceInternal/IncomingConnectionFactory.java +++ b/java/src/IceInternal/IncomingConnectionFactory.java @@ -122,14 +122,14 @@ public class IncomingConnectionFactory extends EventHandler /* catch (IceSecurity.SecurityException ex) { - warning(ex); + // TODO: bandaid. Takes care of SSL Handshake problems during + // creation of a Transceiver. Ignore, nothing we can do here. } */ catch (Ice.SocketException ex) { // TODO: bandaid. Takes care of SSL Handshake problems during // creation of a Transceiver. Ignore, nothing we can do here. - warning(ex); } catch (Ice.TimeoutException ex) { @@ -137,7 +137,10 @@ public class IncomingConnectionFactory extends EventHandler } catch (Ice.LocalException ex) { - warning(ex); + if (_warn) + { + warning(ex); + } setState(StateClosed); } @@ -346,12 +349,12 @@ public class IncomingConnectionFactory extends EventHandler private void warning(Ice.LocalException ex) { - if (_warn) - { - String s = "connection exception:\n" + ex + '\n' + - _acceptor.toString(); - _instance.logger().warning(s); - } + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + ex.printStackTrace(pw); + pw.flush(); + String s = "connection exception:\n" + sw.toString() + '\n' + _acceptor.toString(); + _instance.logger().warning(s); } private Endpoint _endpoint; diff --git a/java/src/IceInternal/Outgoing.java b/java/src/IceInternal/Outgoing.java index 138a2ce056e..0bb6f7de39c 100644 --- a/java/src/IceInternal/Outgoing.java +++ b/java/src/IceInternal/Outgoing.java @@ -86,6 +86,7 @@ public final class Outgoing super.finalize(); } + // Returns true if ok, false if user exception. public boolean invoke() throws Ice.LocationForward, NonRepeatable @@ -161,7 +162,7 @@ public final class Outgoing throw new NonRepeatable(_exception); } - if (_state == StateException) + if (_state == StateUserException) { return false; } @@ -233,7 +234,7 @@ public final class Outgoing // oneway requests as blobs. // _is.startReadEncaps(); - _state = StateException; + _state = StateUserException; break; } @@ -326,8 +327,8 @@ public final class Outgoing private static final int StateUnsent = 0; private static final int StateInProgress = 1; private static final int StateOK = 2; - private static final int StateException = 3; - private static final int StateLocationForward = 4; + private static final int StateLocationForward = 3; + private static final int StateUserException = 4; private static final int StateLocalException = 5; private int _state; |