diff options
Diffstat (limited to 'java/src')
69 files changed, 2140 insertions, 2295 deletions
diff --git a/java/src/Ice/AsyncResult.java b/java/src/Ice/AsyncResult.java index 029e191336f..bf636fa6872 100644 --- a/java/src/Ice/AsyncResult.java +++ b/java/src/Ice/AsyncResult.java @@ -243,7 +243,7 @@ public class AsyncResult } } - public final void __invokeExceptionAsync(final LocalException ex) + public final void __invokeExceptionAsync(final Ice.Exception ex) { // // This is called when it's not safe to call the exception callback synchronously @@ -252,7 +252,7 @@ public class AsyncResult // try { - _instance.clientThreadPool().execute(new IceInternal.DispatchWorkItem(_instance) + _instance.clientThreadPool().execute(new IceInternal.DispatchWorkItem() { public void run() @@ -267,7 +267,7 @@ public class AsyncResult } } - public final void __invokeException(LocalException ex) + public final void __invokeException(Ice.Exception ex) { synchronized(_monitor) { @@ -342,6 +342,19 @@ public class AsyncResult } } + public void __attachCollocatedObserver(int requestId) + { + if(_observer != null) + { + _remoteObserver = _observer.getCollocatedObserver(requestId, + _os.size() - IceInternal.Protocol.headerSize - 4); + if(_remoteObserver != null) + { + _remoteObserver.attach(); + } + } + } + public Ice.Instrumentation.InvocationObserver __getObserver() { return _observer; @@ -356,7 +369,7 @@ public class AsyncResult // try { - _instance.clientThreadPool().execute(new IceInternal.DispatchWorkItem(_instance) + _instance.clientThreadPool().execute(new IceInternal.DispatchWorkItem() { public void run() @@ -476,7 +489,7 @@ public class AsyncResult { final IceInternal.RequestHandler h = handler; _instance.clientThreadPool().execute( - new IceInternal.DispatchWorkItem(_instance) + new IceInternal.DispatchWorkItem() { public void run() @@ -519,7 +532,7 @@ public class AsyncResult protected byte _state; protected boolean _sentSynchronously; - protected LocalException _exception; + protected Ice.Exception _exception; protected Ice.Instrumentation.InvocationObserver _observer; protected Ice.Instrumentation.RemoteObserver _remoteObserver; diff --git a/java/src/Ice/CommunicatorI.java b/java/src/Ice/CommunicatorI.java index af0ad562325..918f5bdffaf 100644 --- a/java/src/Ice/CommunicatorI.java +++ b/java/src/Ice/CommunicatorI.java @@ -202,11 +202,11 @@ public final class CommunicatorI implements Communicator public AsyncResult begin_flushBatchRequests(IceInternal.Functional_VoidCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __localExceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb) { return begin_flushBatchRequestsInternal( - new IceInternal.Functional_CallbackBase(false, __localExceptionCb, __sentCb) + new IceInternal.Functional_CallbackBase(false, __exceptionCb, __sentCb) { public final void __completed(AsyncResult __result) { @@ -214,9 +214,9 @@ public final class CommunicatorI implements Communicator { __result.getCommunicator().end_flushBatchRequests(__result); } - catch(LocalException __ex) + catch(Exception __ex) { - __localExceptionCb.apply(__ex); + __exceptionCb.apply(__ex); } } }); diff --git a/java/src/Ice/ConnectionI.java b/java/src/Ice/ConnectionI.java index a39905470ac..a2c9e9d1060 100644 --- a/java/src/Ice/ConnectionI.java +++ b/java/src/Ice/ConnectionI.java @@ -11,7 +11,7 @@ package Ice; import Ice.Instrumentation.InvocationObserver; -public final class ConnectionI extends IceInternal.EventHandler implements Connection +public final class ConnectionI extends IceInternal.EventHandler implements Connection, IceInternal.ResponseHandler { public interface StartCallback { @@ -339,7 +339,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne synchronized public boolean sendRequest(IceInternal.Outgoing out, boolean compress, boolean response) - throws IceInternal.LocalExceptionWrapper + throws IceInternal.RetryException { final IceInternal.BasicStream os = out.os(); @@ -350,7 +350,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne // to send our request, we always try to send the request // again. // - throw new IceInternal.LocalExceptionWrapper((Ice.LocalException)_exception.fillInStackTrace(), true); + throw new IceInternal.RetryException((Ice.LocalException)_exception.fillInStackTrace()); } assert(_state > StateNotValidated); @@ -416,7 +416,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne synchronized public int sendAsyncRequest(IceInternal.OutgoingAsync out, boolean compress, boolean response) - throws IceInternal.LocalExceptionWrapper + throws IceInternal.RetryException { final IceInternal.BasicStream os = out.__getOs(); @@ -427,7 +427,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne // to send our request, we always try to send the request // again. // - throw new IceInternal.LocalExceptionWrapper((Ice.LocalException)_exception.fillInStackTrace(), true); + throw new IceInternal.RetryException((Ice.LocalException)_exception.fillInStackTrace()); } assert(_state > StateNotValidated); @@ -486,7 +486,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne public synchronized void prepareBatchRequest(IceInternal.BasicStream os) - throws IceInternal.LocalExceptionWrapper + throws IceInternal.RetryException { // // Wait if flushing is currently in progress. @@ -511,7 +511,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne // if(_batchStream.isEmpty()) { - throw new IceInternal.LocalExceptionWrapper((Ice.LocalException)_exception.fillInStackTrace(), true); + throw new IceInternal.RetryException((Ice.LocalException)_exception.fillInStackTrace()); } else { @@ -559,7 +559,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne if(_exception != null) { - throw (Ice.LocalException)_exception.fillInStackTrace(); + return; } boolean flush = false; @@ -690,8 +690,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne public void flushBatchRequests() { - final InvocationObserver observer = IceInternal.ObserverHelper.get(_instance, __flushBatchRequests_name); - IceInternal.BatchOutgoing out = new IceInternal.BatchOutgoing(this, _instance, observer); + IceInternal.BatchOutgoing out = new IceInternal.BatchOutgoing(this, _instance, __flushBatchRequests_name); out.invoke(); } @@ -717,11 +716,11 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne public AsyncResult begin_flushBatchRequests(IceInternal.Functional_VoidCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __localExceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb) { return begin_flushBatchRequestsInternal( - new IceInternal.Functional_CallbackBase(false, __localExceptionCb, __sentCb) + new IceInternal.Functional_CallbackBase(false, __exceptionCb, __sentCb) { public final void __completed(AsyncResult __result) { @@ -729,9 +728,9 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne { __result.getConnection().end_flushBatchRequests(__result); } - catch(LocalException __ex) + catch(Exception __ex) { - __localExceptionCb.apply(__ex); + __exceptionCb.apply(__ex); } } }); @@ -950,15 +949,12 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne // If the request is being sent, don't remove it from the send streams, // it will be removed once the sending is finished. // - if(o == _sendStreams.getFirst()) - { - o.timedOut(); - } - else + boolean isSent = o.timedOut(); + if(o != _sendStreams.getFirst()) { it.remove(); } - o.finished(new InvocationTimeoutException()); + out.finished(new InvocationTimeoutException(), isSent); return; // We're done. } } @@ -979,55 +975,68 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne } } - synchronized public void + public void asyncRequestTimedOut(IceInternal.OutgoingAsyncMessageCallback outAsync) { - java.util.Iterator<OutgoingMessage> it = _sendStreams.iterator(); - while(it.hasNext()) + boolean isSent = false; + boolean finished = false; + + synchronized(this) { - OutgoingMessage o = it.next(); - if(o.outAsync == outAsync) + java.util.Iterator<OutgoingMessage> it = _sendStreams.iterator(); + while(it.hasNext()) { - if(o.requestId > 0) + OutgoingMessage o = it.next(); + if(o.outAsync == outAsync) { - _asyncRequests.remove(o.requestId); - } + if(o.requestId > 0) + { + _asyncRequests.remove(o.requestId); + } - // - // If the request is being sent, don't remove it from the send streams, - // it will be removed once the sending is finished. - // - if(o == _sendStreams.getFirst()) - { - o.timedOut(); - } - else - { - it.remove(); + // + // If the request is being sent, don't remove it from the send streams, + // it will be removed once the sending is finished. + // + isSent = o.timedOut(); + if(o != _sendStreams.getFirst()) + { + it.remove(); + } + finished = true; + break; // We're done. } - o.finished(new InvocationTimeoutException()); - return; // We're done. } } - if(outAsync instanceof IceInternal.OutgoingAsync) + if(!finished) { - IceInternal.OutgoingAsync o = (IceInternal.OutgoingAsync)outAsync; - java.util.Iterator<IceInternal.OutgoingAsync> it2 = _asyncRequests.values().iterator(); - while(it2.hasNext()) + if(outAsync instanceof IceInternal.OutgoingAsync) { - if(it2.next() == o) + IceInternal.OutgoingAsync o = (IceInternal.OutgoingAsync)outAsync; + java.util.Iterator<IceInternal.OutgoingAsync> it2 = _asyncRequests.values().iterator(); + while(it2.hasNext()) { - o.__finished(new InvocationTimeoutException(), true); - it2.remove(); - return; // We're done. + if(it2.next() == o) + { + it2.remove(); + finished = true; + isSent = true; + break; // We're done. + } } } } + + if(finished) + { + outAsync.__finished(new InvocationTimeoutException(), isSent); + } } + synchronized public void - sendResponse(IceInternal.BasicStream os, byte compressFlag) + sendResponse(int requestId, IceInternal.BasicStream os, byte compressFlag) { assert(_state > StateNotValidated); @@ -1748,7 +1757,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne } public synchronized void - invokeException(LocalException ex, int invokeNum) + invokeException(int requestId, LocalException ex, int invokeNum) { // // Fatal exception while invoking a request. Since sendResponse/sendNoResponse isn't @@ -2815,7 +2824,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne } catch(LocalException ex) { - invokeException(ex, invokeNum); + invokeException(requestId, ex, invokeNum); } catch(java.lang.AssertionError ex) // Upon assertion, we print the stack trace. { @@ -2826,7 +2835,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne pw.flush(); uex.unknown = sw.toString(); _logger.error(uex.unknown); - invokeException(uex, invokeNum); + invokeException(requestId, uex, invokeNum); } catch(java.lang.OutOfMemoryError ex) { @@ -2837,7 +2846,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne pw.flush(); uex.unknown = sw.toString(); _logger.error(uex.unknown); - invokeException(uex, invokeNum); + invokeException(requestId, uex, invokeNum); } finally { @@ -2959,7 +2968,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne } private void - warning(String msg, Exception ex) + warning(String msg, java.lang.Exception ex) { java.io.StringWriter sw = new java.io.StringWriter(); java.io.PrintWriter pw = new java.io.PrintWriter(sw); @@ -3028,20 +3037,20 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne { if(_incomingCache == null) { - in = new IceInternal.Incoming(_instance, this, adapter, response, compress, requestId); + in = new IceInternal.Incoming(_instance, this, this, adapter, response, compress, requestId); } else { in = _incomingCache; _incomingCache = _incomingCache.next; - in.reset(_instance, this, adapter, response, compress, requestId); + in.reset(_instance, this, this, adapter, response, compress, requestId); in.next = null; } } } else { - in = new IceInternal.Incoming(_instance, this, adapter, response, compress, requestId); + in = new IceInternal.Incoming(_instance, this, this, adapter, response, compress, requestId); } return in; @@ -3077,56 +3086,6 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne } } - public IceInternal.Outgoing - getOutgoing(IceInternal.RequestHandler handler, String operation, OperationMode mode, - java.util.Map<String, String> context, InvocationObserver observer) - throws IceInternal.LocalExceptionWrapper - { - IceInternal.Outgoing out = null; - - if(_cacheBuffers > 0) - { - synchronized(_outgoingCacheMutex) - { - if(_outgoingCache == null) - { - out = new IceInternal.Outgoing(handler, operation, mode, context, observer); - } - else - { - out = _outgoingCache; - _outgoingCache = _outgoingCache.next; - out.reset(handler, operation, mode, context, observer); - out.next = null; - } - } - } - else - { - out = new IceInternal.Outgoing(handler, operation, mode, context, observer); - } - - return out; - } - - public void - reclaimOutgoing(IceInternal.Outgoing out) - { - if(_cacheBuffers > 0) - { - // - // Clear references to Ice objects as soon as possible. - // - out.reclaim(); - - synchronized(_outgoingCacheMutex) - { - out.next = _outgoingCache; - _outgoingCache = out; - } - } - } - private static class OutgoingMessage { OutgoingMessage(IceInternal.BasicStream stream, boolean compress, boolean adopt) @@ -3158,12 +3117,13 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne this.isSent = false; } - public void + public boolean timedOut() { assert((out != null || outAsync != null) && !isSent); out = null; outAsync = null; + return isSent; } public void @@ -3289,9 +3249,6 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne private IceInternal.Incoming _incomingCache; private java.lang.Object _incomingCacheMutex = new java.lang.Object(); - private IceInternal.Outgoing _outgoingCache; - private java.lang.Object _outgoingCacheMutex = new java.lang.Object(); - private Ice.ProtocolVersion _readProtocol = new Ice.ProtocolVersion(); private Ice.EncodingVersion _readProtocolEncoding = new Ice.EncodingVersion(); diff --git a/java/src/Ice/DispatchInterceptor.java b/java/src/Ice/DispatchInterceptor.java index f7e9cc4fc8f..38f89f2ec3b 100644 --- a/java/src/Ice/DispatchInterceptor.java +++ b/java/src/Ice/DispatchInterceptor.java @@ -67,13 +67,4 @@ public abstract class DispatchInterceptor extends ObjectImpl } } } - - public DispatchStatus - __collocDispatch(IceInternal.Direct request) - { - // - // Should only return DispatchOK or DispatchUserException - // - return dispatch(request); - } } diff --git a/java/src/Ice/Exception.java b/java/src/Ice/Exception.java new file mode 100644 index 00000000000..00ed87da5df --- /dev/null +++ b/java/src/Ice/Exception.java @@ -0,0 +1,74 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package Ice; + +/** + * Base class for Ice local and system exceptions. Those exceptions + * are not checked so we inherit from java.lang.RuntimeException. User + * exceptions are checked exceptions and therefore inherit directly + * from java.lang.Exception. + **/ +public abstract class Exception extends RuntimeException implements Cloneable +{ + public Exception() + { + } + + public Exception(Throwable cause) + { + super(cause); + } + + /** + * Creates a copy of this exception. + * + * @return The copy of this exception. + **/ + public java.lang.Object clone() + { + java.lang.Object o = null; + try + { + o = super.clone(); + } + catch(CloneNotSupportedException ex) + { + assert false; // Impossible + } + return o; + } + + /** + * Returns the name of this exception. + * + * @return The name of this exception. + **/ + public abstract String + ice_name(); + + /** + * Returns a string representation of this exception. + * + * @return A string representation of this exception. + **/ + public String + toString() + { + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + IceUtilInternal.OutputBase out = new IceUtilInternal.OutputBase(pw); + out.setUseTab(false); + out.print(getClass().getName()); + out.inc(); + IceInternal.ValueWriter.write(this, out); + pw.flush(); + return sw.toString(); + } +} diff --git a/java/src/Ice/LocalException.java b/java/src/Ice/LocalException.java index 9564e1df2ac..f521ce01fe5 100644 --- a/java/src/Ice/LocalException.java +++ b/java/src/Ice/LocalException.java @@ -12,7 +12,7 @@ package Ice; /** * Base class for all Ice run-time exceptions. **/ -public abstract class LocalException extends RuntimeException implements Cloneable +public abstract class LocalException extends Exception { public LocalException() { @@ -22,50 +22,4 @@ public abstract class LocalException extends RuntimeException implements Cloneab { super(cause); } - - /** - * Creates a copy of this exception. - * - * @return The copy of this exception. - **/ - public java.lang.Object clone() - { - java.lang.Object o = null; - try - { - o = super.clone(); - } - catch(CloneNotSupportedException ex) - { - assert false; // Impossible - } - return o; - } - - /** - * Returns the name of this exception. - * - * @return The name of this exception. - **/ - public abstract String - ice_name(); - - /** - * Returns a string representation of this exception. - * - * @return A string representation of this exception. - **/ - public String - toString() - { - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - IceUtilInternal.OutputBase out = new IceUtilInternal.OutputBase(pw); - out.setUseTab(false); - out.print(getClass().getName()); - out.inc(); - IceInternal.ValueWriter.write(this, out); - pw.flush(); - return sw.toString(); - } } diff --git a/java/src/Ice/Object.java b/java/src/Ice/Object.java index 9fac75feaa2..e4c4bbf0d79 100644 --- a/java/src/Ice/Object.java +++ b/java/src/Ice/Object.java @@ -155,8 +155,6 @@ public interface Object DispatchStatus __dispatch(IceInternal.Incoming in, Current current); - DispatchStatus __collocDispatch(IceInternal.Direct request); - void __write(IceInternal.BasicStream __os); void __read(IceInternal.BasicStream __is); diff --git a/java/src/Ice/ObjectImpl.java b/java/src/Ice/ObjectImpl.java index 6b051e2a4b0..dcc4acdd52d 100644 --- a/java/src/Ice/ObjectImpl.java +++ b/java/src/Ice/ObjectImpl.java @@ -269,28 +269,21 @@ public abstract class ObjectImpl implements Object, java.lang.Cloneable, java.io public DispatchStatus ice_dispatch(Request request, DispatchInterceptorAsyncCallback cb) { - if(request.isCollocated()) + IceInternal.Incoming in = (IceInternal.Incoming)request; + if(cb != null) { - return __collocDispatch((IceInternal.Direct)request); + in.push(cb); } - else + try + { + in.startOver(); // may raise ResponseSentException + return __dispatch(in, in.getCurrent()); + } + finally { - IceInternal.Incoming in = (IceInternal.Incoming)request; if(cb != null) { - in.push(cb); - } - try - { - in.startOver(); // may raise ResponseSentException - return __dispatch(in, in.getCurrent()); - } - finally - { - if(cb != null) - { - in.pop(); - } + in.pop(); } } } @@ -344,12 +337,6 @@ public abstract class ObjectImpl implements Object, java.lang.Cloneable, java.io throw new Ice.OperationNotExistException(current.id, current.facet, current.operation); } - public DispatchStatus - __collocDispatch(IceInternal.Direct request) - { - return request.run(this); - } - public void __write(IceInternal.BasicStream os) { diff --git a/java/src/Ice/ObjectPrx.java b/java/src/Ice/ObjectPrx.java index 74735d75265..113addd7daf 100644 --- a/java/src/Ice/ObjectPrx.java +++ b/java/src/Ice/ObjectPrx.java @@ -106,7 +106,7 @@ public interface ObjectPrx * @return The asynchronous result object. **/ AsyncResult begin_ice_isA(String __id, IceInternal.Functional_BoolCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb); + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb); /** * Tests whether this proxy supports a given interface. @@ -118,7 +118,7 @@ public interface ObjectPrx * @return The asynchronous result object. **/ AsyncResult begin_ice_isA(String __id, IceInternal.Functional_BoolCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb); /** @@ -132,7 +132,7 @@ public interface ObjectPrx **/ AsyncResult begin_ice_isA(String __id, java.util.Map<String, String> __context, IceInternal.Functional_BoolCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb); + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb); /** * Tests whether this proxy supports a given interface. @@ -146,7 +146,7 @@ public interface ObjectPrx **/ AsyncResult begin_ice_isA(String __id, java.util.Map<String, String> __context, IceInternal.Functional_BoolCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb); /** @@ -226,7 +226,7 @@ public interface ObjectPrx * @return The asynchronous result object. **/ AsyncResult begin_ice_ping(IceInternal.Functional_VoidCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb); + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb); /** * Tests whether the target object of this proxy can be reached. @@ -237,7 +237,7 @@ public interface ObjectPrx * @return The asynchronous result object. **/ AsyncResult begin_ice_ping(IceInternal.Functional_VoidCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb); /** @@ -250,7 +250,7 @@ public interface ObjectPrx **/ AsyncResult begin_ice_ping(java.util.Map<String, String> __context, IceInternal.Functional_VoidCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb); + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb); /** * Tests whether the target object of this proxy can be reached. @@ -263,7 +263,7 @@ public interface ObjectPrx **/ AsyncResult begin_ice_ping(java.util.Map<String, String> __context, IceInternal.Functional_VoidCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb); /** @@ -347,7 +347,7 @@ public interface ObjectPrx * @return The asynchronous result object. **/ AsyncResult begin_ice_ids(IceInternal.Functional_GenericCallback1<String[]> __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb); + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb); /** * Returns the Slice type IDs of the interfaces supported by the target object of this proxy. @@ -358,7 +358,7 @@ public interface ObjectPrx * @return The asynchronous result object. **/ AsyncResult begin_ice_ids(IceInternal.Functional_GenericCallback1<String[]> __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb); /** @@ -371,7 +371,7 @@ public interface ObjectPrx **/ AsyncResult begin_ice_ids(java.util.Map<String, String> __context, IceInternal.Functional_GenericCallback1<String[]> __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb); + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb); /** * Returns the Slice type IDs of the interfaces supported by the target object of this proxy. @@ -384,7 +384,7 @@ public interface ObjectPrx **/ AsyncResult begin_ice_ids(java.util.Map<String, String> __context, IceInternal.Functional_GenericCallback1<String[]> __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb); /** @@ -468,7 +468,7 @@ public interface ObjectPrx * @return The asynchronous result object. **/ AsyncResult begin_ice_id(IceInternal.Functional_GenericCallback1<String> __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb); + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb); /** * Returns the Slice type ID of the most-derived interface supported by the target object of this proxy. @@ -479,7 +479,7 @@ public interface ObjectPrx * @return The asynchronous result object. **/ AsyncResult begin_ice_id(IceInternal.Functional_GenericCallback1<String> __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb); /** @@ -492,7 +492,7 @@ public interface ObjectPrx **/ AsyncResult begin_ice_id(java.util.Map<String, String> __context, IceInternal.Functional_GenericCallback1<String> __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb); + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb); /** * Returns the Slice type ID of the most-derived interface supported by the target object of this proxy. @@ -505,7 +505,7 @@ public interface ObjectPrx **/ AsyncResult begin_ice_id(java.util.Map<String, String> __context, IceInternal.Functional_GenericCallback1<String> __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb); /** @@ -672,7 +672,7 @@ public interface ObjectPrx **/ AsyncResult begin_ice_invoke(String operation, OperationMode mode, byte[] inParams, FunctionalCallback_Object_ice_invoke_Response __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb); /** @@ -691,7 +691,7 @@ public interface ObjectPrx **/ AsyncResult begin_ice_invoke(String operation, OperationMode mode, byte[] inParams, FunctionalCallback_Object_ice_invoke_Response __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb); + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb); /** * Invokes an operation dynamically and asynchronously. @@ -712,7 +712,7 @@ public interface ObjectPrx AsyncResult begin_ice_invoke(String operation, OperationMode mode, byte[] inParams, java.util.Map<String, String> __context, FunctionalCallback_Object_ice_invoke_Response __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb); /** @@ -733,7 +733,7 @@ public interface ObjectPrx AsyncResult begin_ice_invoke(String operation, OperationMode mode, byte[] inParams, java.util.Map<String, String> __context, FunctionalCallback_Object_ice_invoke_Response __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb); + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb); /** * Completes the asynchronous ice_invoke request. @@ -1191,7 +1191,7 @@ public interface ObjectPrx * @return The asynchronous result object. **/ AsyncResult begin_ice_flushBatchRequests(IceInternal.Functional_VoidCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb); /** diff --git a/java/src/Ice/ObjectPrxHelperBase.java b/java/src/Ice/ObjectPrxHelperBase.java index 8bf9d9ec26d..af4db1468fc 100644 --- a/java/src/Ice/ObjectPrxHelperBase.java +++ b/java/src/Ice/ObjectPrxHelperBase.java @@ -79,40 +79,39 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable private boolean ice_isA(String __id, java.util.Map<String, String> __context, boolean __explicitCtx) { - if(__explicitCtx && __context == null) - { - __context = _emptyContext; - } - - final InvocationObserver __observer = IceInternal.ObserverHelper.get(this, __ice_isA_name, __context); - int __cnt = 0; + __checkTwowayOnly(__ice_isA_name); + IceInternal.Outgoing __og = getOutgoing(__ice_isA_name, OperationMode.Nonmutating, __context, __explicitCtx); try { - while(true) + try + { + IceInternal.BasicStream __os = __og.startWriteParams(Ice.FormatType.DefaultFormat); + __os.writeString(__id); + __og.endWriteParams(); + } + catch(LocalException __ex) + { + __og.abort(__ex); + } + if(!__og.invoke()) { - _ObjectDel __del = null; try { - __checkTwowayOnly(__ice_isA_name); - __del = __getDelegate(false); - return __del.ice_isA(__id, __context, __observer); - } - catch(IceInternal.LocalExceptionWrapper __ex) - { - __cnt = __handleExceptionWrapperRelaxed(__del, __ex, null, __cnt, __observer); + __og.throwUserException(); } - catch(LocalException __ex) + catch(UserException __ex) { - __cnt = __handleException(__del, __ex, null, __cnt, __observer); + throw new UnknownUserException(__ex.ice_name(), __ex); } } + IceInternal.BasicStream __is = __og.startReadParams(); + boolean __ret = __is.readBool(); + __og.endReadParams(); + return __ret; } finally { - if(__observer != null) - { - __observer.detach(); - } + reclaimOutgoing(__og); } } @@ -206,7 +205,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable public final AsyncResult begin_ice_isA(String __id, IceInternal.Functional_BoolCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb) + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb) { return begin_ice_isA(__id, null, false, __responseCb, __exceptionCb, null); } @@ -223,7 +222,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable public final AsyncResult begin_ice_isA(String __id, IceInternal.Functional_BoolCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb) { return begin_ice_isA(__id, null, false, __responseCb, __exceptionCb, __sentCb); @@ -242,7 +241,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable begin_ice_isA(String __id, java.util.Map<String, String> __context, IceInternal.Functional_BoolCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb) + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb) { return begin_ice_isA(__id, __context, true, __responseCb, __exceptionCb, null); } @@ -261,7 +260,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable begin_ice_isA(String __id, java.util.Map<String, String> __context, IceInternal.Functional_BoolCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb) { return begin_ice_isA(__id, __context, true, __responseCb, __exceptionCb, __sentCb); @@ -272,7 +271,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable java.util.Map<String, String> __context, boolean __explicitCtx, IceInternal.Functional_BoolCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb) { return begin_ice_isA(__id, __context, __explicitCtx, @@ -289,8 +288,8 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable begin_ice_isA(String __id, java.util.Map<String, String> __context, boolean __explicitCtx, IceInternal.CallbackBase __cb) { - IceInternal.OutgoingAsync __result = new IceInternal.OutgoingAsync(this, __ice_isA_name, __cb); __checkAsyncTwowayOnly(__ice_isA_name); + IceInternal.OutgoingAsync __result = new IceInternal.OutgoingAsync(this, __ice_isA_name, __cb); try { __result.__prepare(__ice_isA_name, OperationMode.Nonmutating, __context, __explicitCtx); @@ -299,7 +298,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable __result.__endWriteParams(); __result.__invoke(true); } - catch(LocalException __ex) + catch(Exception __ex) { __result.__invokeExceptionAsync(__ex); } @@ -316,35 +315,22 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable end_ice_isA(AsyncResult __result) { AsyncResult.__check(__result, this, __ice_isA_name); - boolean __ok = __result.__wait(); - try + if(!__result.__wait()) { - if(!__ok) + try { - try - { - __result.__throwUserException(); - } - catch(UserException __ex) - { - throw new UnknownUserException(__ex.ice_name(), __ex); - } + __result.__throwUserException(); } - boolean __ret; - IceInternal.BasicStream __is = __result.__startReadParams(); - __ret = __is.readBool(); - __result.__endReadParams(); - return __ret; - } - catch(Ice.LocalException ex) - { - InvocationObserver obsv = __result.__getObserver(); - if(obsv != null) + catch(UserException __ex) { - obsv.failed(ex.ice_name()); + throw new UnknownUserException(__ex.ice_name(), __ex); } - throw ex; } + boolean __ret; + IceInternal.BasicStream __is = __result.__startReadParams(); + __ret = __is.readBool(); + __result.__endReadParams(); + return __ret; } static public final void __ice_isA_completed(TwowayCallbackBool __cb, Ice.AsyncResult __result) @@ -359,6 +345,11 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable __cb.exception(__ex); return; } + catch(SystemException __ex) + { + __cb.exception(__ex); + return; + } __cb.response(__ret); } @@ -387,40 +378,15 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable private void ice_ping(java.util.Map<String, String> __context, boolean __explicitCtx) { - if(__explicitCtx && __context == null) - { - __context = _emptyContext; - } - - final InvocationObserver __observer = IceInternal.ObserverHelper.get(this, __ice_ping_name, __context); - int __cnt = 0; + IceInternal.Outgoing __og = getOutgoing(__ice_ping_name, OperationMode.Nonmutating, __context, __explicitCtx); try { - while(true) - { - _ObjectDel __del = null; - try - { - __del = __getDelegate(false); - __del.ice_ping(__context, __observer); - return; - } - catch(IceInternal.LocalExceptionWrapper __ex) - { - __cnt = __handleExceptionWrapperRelaxed(__del, __ex, null, __cnt, __observer); - } - catch(LocalException __ex) - { - __cnt = __handleException(__del, __ex, null, __cnt, __observer); - } - } + __og.writeEmptyParams(); + __invoke(__og); } finally { - if(__observer != null) - { - __observer.detach(); - } + reclaimOutgoing(__og); } } @@ -506,7 +472,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable **/ public final AsyncResult begin_ice_ping(IceInternal.Functional_VoidCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb) + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb) { return begin_ice_ping(null, false, new IceInternal.Functional_OnewayCallback(__responseCb, __exceptionCb, null)); @@ -522,7 +488,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable **/ public final AsyncResult begin_ice_ping(IceInternal.Functional_VoidCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb) { return begin_ice_ping(null, false, new @@ -540,7 +506,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable public final AsyncResult begin_ice_ping(java.util.Map<String, String> __context, IceInternal.Functional_VoidCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb) + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb) { return begin_ice_ping(__context, true, new IceInternal.Functional_OnewayCallback(__responseCb, __exceptionCb, null)); @@ -558,7 +524,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable public final AsyncResult begin_ice_ping(java.util.Map<String, String> __context, IceInternal.Functional_VoidCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb) { return begin_ice_ping(__context, true, @@ -575,7 +541,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable __result.__writeEmptyParams(); __result.__invoke(true); } - catch(LocalException __ex) + catch(Exception __ex) { __result.__invokeExceptionAsync(__ex); } @@ -623,40 +589,30 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable private String[] ice_ids(java.util.Map<String, String> __context, boolean __explicitCtx) { - if(__explicitCtx && __context == null) - { - __context = _emptyContext; - } - - final InvocationObserver __observer = IceInternal.ObserverHelper.get(this, __ice_ids_name, __context); - int __cnt = 0; + __checkTwowayOnly(__ice_id_name); + IceInternal.Outgoing __og = getOutgoing(__ice_ids_name, OperationMode.Nonmutating, __context, __explicitCtx); try { - while(true) + __og.writeEmptyParams(); + if(!__og.invoke()) { - _ObjectDel __del = null; try { - __checkTwowayOnly(__ice_ids_name); - __del = __getDelegate(false); - return __del.ice_ids(__context, __observer); + __og.throwUserException(); } - catch(IceInternal.LocalExceptionWrapper __ex) - { - __cnt = __handleExceptionWrapperRelaxed(__del, __ex, null, __cnt, __observer); - } - catch(LocalException __ex) + catch(UserException __ex) { - __cnt = __handleException(__del, __ex, null, __cnt, __observer); + throw new UnknownUserException(__ex.ice_name(), __ex); } } + IceInternal.BasicStream __is = __og.startReadParams(); + String[] __ret = __is.readStringSeq(); + __og.endReadParams(); + return __ret; } finally { - if(__observer != null) - { - __observer.detach(); - } + reclaimOutgoing(__og); } } @@ -736,7 +692,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable class FunctionalCallback_Object_ice_ids extends IceInternal.Functional_TwowayCallbackArg1<String[]> { FunctionalCallback_Object_ice_ids(IceInternal.Functional_GenericCallback1<String[]> __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb) { super(__responseCb, __exceptionCb, __sentCb); @@ -757,7 +713,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable **/ public final AsyncResult begin_ice_ids(IceInternal.Functional_GenericCallback1<String[]> __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb) + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb) { return begin_ice_ids(null, false, new FunctionalCallback_Object_ice_ids(__responseCb, __exceptionCb, null)); } @@ -772,7 +728,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable **/ public final AsyncResult begin_ice_ids(IceInternal.Functional_GenericCallback1<String[]> __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb) { return begin_ice_ids(null, false, @@ -790,7 +746,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable public final AsyncResult begin_ice_ids(java.util.Map<String, String> __context, IceInternal.Functional_GenericCallback1<String[]> __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb) + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb) { return begin_ice_ids(__context, true, new FunctionalCallback_Object_ice_ids(__responseCb, __exceptionCb, null)); @@ -808,7 +764,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable public final AsyncResult begin_ice_ids(java.util.Map<String, String> __context, IceInternal.Functional_GenericCallback1<String[]> __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb) { return begin_ice_ids(__context, true, @@ -819,7 +775,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable begin_ice_ids(java.util.Map<String, String> __context, boolean __explicitCtx, IceInternal.Functional_GenericCallback1<String[]> __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb) { return begin_ice_ids(__context, true, @@ -835,15 +791,15 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable private AsyncResult begin_ice_ids(java.util.Map<String, String> __context, boolean __explicitCtx, IceInternal.CallbackBase __cb) { - IceInternal.OutgoingAsync __result = new IceInternal.OutgoingAsync(this, __ice_ids_name, __cb); __checkAsyncTwowayOnly(__ice_ids_name); + IceInternal.OutgoingAsync __result = new IceInternal.OutgoingAsync(this, __ice_ids_name, __cb); try { __result.__prepare(__ice_ids_name, OperationMode.Nonmutating, __context, __explicitCtx); __result.__writeEmptyParams(); __result.__invoke(true); } - catch(LocalException __ex) + catch(Exception __ex) { __result.__invokeExceptionAsync(__ex); } @@ -861,35 +817,22 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable end_ice_ids(AsyncResult __result) { AsyncResult.__check(__result, this, __ice_ids_name); - boolean __ok = __result.__wait(); - try + if(!__result.__wait()) { - if(!__ok) + try { - try - { - __result.__throwUserException(); - } - catch(UserException __ex) - { - throw new UnknownUserException(__ex.ice_name(), __ex); - } + __result.__throwUserException(); } - String[] __ret = null; - IceInternal.BasicStream __is = __result.__startReadParams(); - __ret = StringSeqHelper.read(__is); - __result.__endReadParams(); - return __ret; - } - catch(Ice.LocalException ex) - { - InvocationObserver obsv = __result.__getObserver(); - if(obsv != null) + catch(UserException __ex) { - obsv.failed(ex.ice_name()); + throw new UnknownUserException(__ex.ice_name(), __ex); } - throw ex; } + String[] __ret = null; + IceInternal.BasicStream __is = __result.__startReadParams(); + __ret = StringSeqHelper.read(__is); + __result.__endReadParams(); + return __ret; } static public final void __ice_ids_completed(TwowayCallbackArg1<String[]> __cb, AsyncResult __result) @@ -904,6 +847,11 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable __cb.exception(__ex); return; } + catch(SystemException __ex) + { + __cb.exception(__ex); + return; + } __cb.response(__ret); } @@ -935,40 +883,30 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable private String ice_id(java.util.Map<String, String> __context, boolean __explicitCtx) { - if(__explicitCtx && __context == null) - { - __context = _emptyContext; - } - - final InvocationObserver __observer = IceInternal.ObserverHelper.get(this, __ice_id_name, __context); - int __cnt = 0; + __checkTwowayOnly(__ice_id_name); + IceInternal.Outgoing __og = getOutgoing(__ice_id_name, OperationMode.Nonmutating, __context, __explicitCtx); try { - while(true) + __og.writeEmptyParams(); + if(!__og.invoke()) { - _ObjectDel __del = null; try { - __checkTwowayOnly(__ice_id_name); - __del = __getDelegate(false); - return __del.ice_id(__context, __observer); - } - catch(IceInternal.LocalExceptionWrapper __ex) - { - __cnt = __handleExceptionWrapperRelaxed(__del, __ex, null, __cnt, __observer); + __og.throwUserException(); } - catch(LocalException __ex) + catch(UserException __ex) { - __cnt = __handleException(__del, __ex, null, __cnt, __observer); + throw new UnknownUserException(__ex.ice_name(), __ex); } } + IceInternal.BasicStream __is = __og.startReadParams(); + String __ret = __is.readString(); + __og.endReadParams(); + return __ret; } finally { - if(__observer != null) - { - __observer.detach(); - } + reclaimOutgoing(__og); } } @@ -1048,7 +986,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable class FunctionalCallback_Object_ice_id extends IceInternal.Functional_TwowayCallbackArg1<String> { FunctionalCallback_Object_ice_id(IceInternal.Functional_GenericCallback1<String> responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> exceptionCb, IceInternal.Functional_BoolCallback sentCb) { super(responseCb, exceptionCb, sentCb); @@ -1069,7 +1007,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable **/ public final AsyncResult begin_ice_id(IceInternal.Functional_GenericCallback1<String> __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb) + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb) { return begin_ice_id(null, false, new FunctionalCallback_Object_ice_id(__responseCb, __exceptionCb, null)); } @@ -1084,7 +1022,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable **/ public final AsyncResult begin_ice_id(IceInternal.Functional_GenericCallback1<String> __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb) { return begin_ice_id(null, false, new FunctionalCallback_Object_ice_id(__responseCb, __exceptionCb, __sentCb)); @@ -1101,7 +1039,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable public final AsyncResult begin_ice_id(java.util.Map<String, String> __context, IceInternal.Functional_GenericCallback1<String> __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb) + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb) { return begin_ice_id(__context, true, new FunctionalCallback_Object_ice_id(__responseCb, __exceptionCb, null)); } @@ -1118,7 +1056,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable public final AsyncResult begin_ice_id(java.util.Map<String, String> __context, IceInternal.Functional_GenericCallback1<String> __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb) { return begin_ice_id(__context, true, @@ -1128,15 +1066,15 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable private AsyncResult begin_ice_id(java.util.Map<String, String> __context, boolean __explicitCtx, IceInternal.CallbackBase __cb) { - IceInternal.OutgoingAsync __result = new IceInternal.OutgoingAsync(this, __ice_id_name, __cb); __checkAsyncTwowayOnly(__ice_id_name); + IceInternal.OutgoingAsync __result = new IceInternal.OutgoingAsync(this, __ice_id_name, __cb); try { __result.__prepare(__ice_id_name, OperationMode.Nonmutating, __context, __explicitCtx); __result.__writeEmptyParams(); __result.__invoke(true); } - catch(LocalException __ex) + catch(Exception __ex) { __result.__invokeExceptionAsync(__ex); } @@ -1153,35 +1091,22 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable end_ice_id(AsyncResult __result) { AsyncResult.__check(__result, this, __ice_id_name); - boolean __ok = __result.__wait(); - try + if(!__result.__wait()) { - if(!__ok) + try { - try - { - __result.__throwUserException(); - } - catch(UserException __ex) - { - throw new UnknownUserException(__ex.ice_name(), __ex); - } + __result.__throwUserException(); } - String __ret = null; - IceInternal.BasicStream __is = __result.__startReadParams(); - __ret = __is.readString(); - __result.__endReadParams(); - return __ret; - } - catch(Ice.LocalException ex) - { - InvocationObserver obsv = __result.__getObserver(); - if(obsv != null) + catch(UserException __ex) { - obsv.failed(ex.ice_name()); + throw new UnknownUserException(__ex.ice_name(), __ex); } - throw ex; } + String __ret = null; + IceInternal.BasicStream __is = __result.__startReadParams(); + __ret = __is.readString(); + __result.__endReadParams(); + return __ret; } static public final void __ice_id_completed(TwowayCallbackArg1<String> __cb, AsyncResult __result) @@ -1196,6 +1121,11 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable __cb.exception(__ex); return; } + catch(SystemException __ex) + { + __cb.exception(__ex); + return; + } __cb.response(__ret); } @@ -1249,46 +1179,23 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable ice_invoke(String operation, OperationMode mode, byte[] inParams, ByteSeqHolder outParams, java.util.Map<String, String> context, boolean explicitCtx) { - if(explicitCtx && context == null) - { - context = _emptyContext; - } - - final InvocationObserver __observer = IceInternal.ObserverHelper.get(this, operation, context); - int __cnt = 0; + IceInternal.Outgoing __og = getOutgoing(operation, mode, context, explicitCtx); try { - while(true) + __og.writeParamEncaps(inParams); + boolean ok = __og.invoke(); + if(_reference.getMode() == IceInternal.Reference.ModeTwoway) { - _ObjectDel __del = null; - try - { - __del = __getDelegate(false); - return __del.ice_invoke(operation, mode, inParams, outParams, context, __observer); - } - catch(IceInternal.LocalExceptionWrapper __ex) - { - if(mode == OperationMode.Nonmutating || mode == OperationMode.Idempotent) - { - __cnt = __handleExceptionWrapperRelaxed(__del, __ex, null, __cnt, __observer); - } - else - { - __handleExceptionWrapper(__del, __ex, __observer); - } - } - catch(LocalException __ex) + if(outParams != null) { - __cnt = __handleException(__del, __ex, null, __cnt, __observer); + outParams.value = __og.readParamEncaps(); } } + return ok; } finally { - if(__observer != null) - { - __observer.detach(); - } + reclaimOutgoing(__og); } } @@ -1428,7 +1335,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable **/ public final AsyncResult begin_ice_invoke(String operation, OperationMode mode, byte[] inParams, FunctionalCallback_Object_ice_invoke_Response responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> exceptionCb, IceInternal.Functional_BoolCallback sentCb) { return begin_ice_invoke(operation, mode, inParams, null, false, responseCb, exceptionCb, sentCb); @@ -1450,7 +1357,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable **/ public final AsyncResult begin_ice_invoke(String operation, OperationMode mode, byte[] inParams, FunctionalCallback_Object_ice_invoke_Response responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> exceptionCb) + IceInternal.Functional_GenericCallback1<Ice.Exception> exceptionCb) { return begin_ice_invoke(operation, mode, inParams, null, false, responseCb, exceptionCb, null); } @@ -1474,7 +1381,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable public final AsyncResult begin_ice_invoke(String operation, OperationMode mode, byte[] inParams, java.util.Map<String, String> context, FunctionalCallback_Object_ice_invoke_Response responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> exceptionCb, IceInternal.Functional_BoolCallback sentCb) { return begin_ice_invoke(operation, mode, inParams, context, true, responseCb, exceptionCb, sentCb); @@ -1498,7 +1405,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable public final AsyncResult begin_ice_invoke(String operation, OperationMode mode, byte[] inParams, java.util.Map<String, String> context, FunctionalCallback_Object_ice_invoke_Response responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> exceptionCb) + IceInternal.Functional_GenericCallback1<Ice.Exception> exceptionCb) { return begin_ice_invoke(operation, mode, inParams, context, true, responseCb, exceptionCb, null); } @@ -1507,13 +1414,13 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable java.util.Map<String, String> __context, boolean __explicitCtx, FunctionalCallback_Object_ice_invoke_Response __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb) { class CB extends IceInternal.Functional_TwowayCallback implements _Callback_Object_ice_invoke { CB(FunctionalCallback_Object_ice_invoke_Response responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> exceptionCb, IceInternal.Functional_BoolCallback sentCb) { super(responseCb != null, exceptionCb, sentCb); @@ -1547,7 +1454,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable __result.__writeParamEncaps(inParams); __result.__invoke(true); } - catch(LocalException __ex) + catch(Exception __ex) { __result.__invokeExceptionAsync(__ex); } @@ -1572,21 +1479,9 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable boolean ok = __result.__wait(); if(_reference.getMode() == IceInternal.Reference.ModeTwoway) { - try + if(outParams != null) { - if(outParams != null) - { - outParams.value = __result.__readParamEncaps(); - } - } - catch(Ice.LocalException ex) - { - InvocationObserver obsv = __result.__getObserver(); - if(obsv != null) - { - obsv.failed(ex.ice_name()); - } - throw ex; + outParams.value = __result.__readParamEncaps(); } } return ok; @@ -1605,6 +1500,11 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable __cb.exception(__ex); return; } + catch(SystemException __ex) + { + __cb.exception(__ex); + return; + } __cb.response(__ret, outParams.value); } @@ -1683,7 +1583,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable else { ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(_reference.changeIdentity(newIdentity)); + proxy.__setup(_reference.changeIdentity(newIdentity)); return proxy; } } @@ -1744,7 +1644,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable else { ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(_reference.changeFacet(newFacet)); + proxy.__setup(_reference.changeFacet(newFacet)); return proxy; } } @@ -2361,31 +2261,55 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable public final Connection ice_getConnection() { - final InvocationObserver __observer = IceInternal.ObserverHelper.get(this, "ice_getConnection"); - int __cnt = 0; + final InvocationObserver observer = IceInternal.ObserverHelper.get(this, "ice_getConnection"); + int cnt = 0; try { while(true) { - _ObjectDel __del = null; + IceInternal.RequestHandler handler = null; try { - __del = __getDelegate(false); - // Wait for the connection to be established. - return __del.__getRequestHandler().getConnection(true); - + handler = __getRequestHandler(false); + return handler.getConnection(true); } - catch(LocalException __ex) + catch(Ice.Exception ex) { - __cnt = __handleException(__del, __ex, null, __cnt, __observer); + try + { + Ice.IntHolder interval = new Ice.IntHolder(); + cnt = __handleException(ex, handler, OperationMode.Idempotent, false, interval, cnt); + if(observer != null) + { + observer.retried(); + } + if(interval.value > 0) + { + try + { + Thread.sleep(interval.value); + } + catch(InterruptedException ex1) + { + } + } + } + catch(Ice.Exception exc) + { + if(observer != null) + { + observer.failed(exc.ice_name()); + } + throw exc; + } } } } finally { - if(__observer != null) + if(observer != null) { - __observer.detach(); + observer.detach(); } } } @@ -2404,18 +2328,17 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable public final Connection ice_getCachedConnection() { - _ObjectDel __del = null; + IceInternal.RequestHandler handler = null; synchronized(this) { - __del = _delegate; + handler = _requestHandler; } - if(__del != null) + if(handler != null) { try { - // Don't wait for the connection to be established. - return __del.__getRequestHandler().getConnection(false); + return handler.getConnection(false); } catch(LocalException ex) { @@ -2430,23 +2353,8 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable public void ice_flushBatchRequests() { - // - // We don't automatically retry if ice_flushBatchRequests fails. Otherwise, if some batch - // requests were queued with the connection, they would be lost without being noticed. - // - final InvocationObserver __observer = IceInternal.ObserverHelper.get(this, __ice_flushBatchRequests_name); - _ObjectDel __del = null; - int __cnt = -1; // Don't retry. - try - { - __del = __getDelegate(false); - __del.ice_flushBatchRequests(__observer); - return; - } - catch(LocalException __ex) - { - __cnt = __handleException(__del, __ex, null, __cnt, __observer); - } + IceInternal.BatchOutgoing __og = new IceInternal.BatchOutgoing(this, __ice_flushBatchRequests_name); + __og.invoke(); } /** @@ -2511,7 +2419,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable **/ public AsyncResult begin_ice_flushBatchRequests(IceInternal.Functional_VoidCallback __responseCb, - IceInternal.Functional_GenericCallback1<Ice.LocalException> __exceptionCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, IceInternal.Functional_BoolCallback __sentCb) { return begin_ice_flushBatchRequestsInternal( @@ -2529,7 +2437,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable { __result.__invoke(); } - catch(LocalException __ex) + catch(Exception __ex) { __result.__invokeExceptionAsync(__ex); } @@ -2575,156 +2483,58 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable public final void __copyFrom(ObjectPrx from) { - ObjectPrxHelperBase h = (ObjectPrxHelperBase)from; - IceInternal.Reference ref = null; - _ObjectDelM delegateM = null; - _ObjectDelD delegateD = null; - synchronized(from) { - ref = h._reference; - try - { - delegateM = (_ObjectDelM)h._delegate; - } - catch(ClassCastException ex) - { - } - try - { - delegateD = (_ObjectDelD)h._delegate; - } - catch(ClassCastException ex) - { - } - } - - // - // No need to synchronize "*this", as this operation is only - // called upon initialization. - // - - assert(_reference == null); - assert(_delegate == null); - - _reference = ref; - - if(_reference.getCacheConnection()) - { - // - // The _delegate attribute is only used if "cache connection" - // is enabled. If it's not enabled, we don't keep track of the - // delegate -- a new delegate is created for each invocation. - // - - if(delegateD != null) - { - _ObjectDelD delegate = __createDelegateD(); - delegate.__copyFrom(delegateD); - _delegate = delegate; - } - else if(delegateM != null) - { - _ObjectDelM delegate = __createDelegateM(); - delegate.__copyFrom(delegateM); - _delegate = delegate; - } + ObjectPrxHelperBase h = (ObjectPrxHelperBase)from; + _reference = h._reference; + _requestHandler = h._requestHandler; } } public final int - __handleException(_ObjectDel delegate, LocalException ex, Ice.IntHolder interval, int cnt, - InvocationObserver obsv) + __handleException(Exception ex, IceInternal.RequestHandler handler, OperationMode mode, boolean sent, Ice.IntHolder interval, + int cnt) { + __setRequestHandler(handler, null); // Clear the request handler + // - // Only _delegate needs to be mutex protected here. + // We only retry local exception, system exceptions aren't retried. // - synchronized(this) - { - if(delegate == _delegate) - { - _delegate = null; - } - } - - try + // A CloseConnectionException indicates graceful server shutdown, and is therefore + // always repeatable without violating "at-most-once". That's because by sending a + // close connection message, the server guarantees that all outstanding requests + // can safely be repeated. + // + // An ObjectNotExistException can always be retried as well without violating + // "at-most-once" (see the implementation of the checkRetryAfterException method + // of the ProxyFactory class for the reasons why it can be useful). + // + // If the request didn't get sent or if it's non-mutating or idempotent it can + // also always be retried if the retry count isn't reached. + // + if(ex instanceof LocalException && (!sent || + mode == OperationMode.Nonmutating || mode == OperationMode.Idempotent || + ex instanceof CloseConnectionException || + ex instanceof ObjectNotExistException)) { - if(cnt == -1) // Don't retry if the retry count is -1. - { - throw ex; - } - try { - cnt = _reference.getInstance().proxyFactory().checkRetryAfterException(ex, _reference, interval, - cnt); + return _reference.getInstance().proxyFactory().checkRetryAfterException((LocalException)ex, + _reference, + interval, + cnt); } - catch(CommunicatorDestroyedException e) + catch(CommunicatorDestroyedException exc) { // - // The communicator is already destroyed, so we cannot - // retry. + // The communicator is already destroyed, so we cannot retry. // - throw e; - } - if(obsv != null) - { - obsv.retried(); - } - return cnt; - } - catch(Ice.LocalException e) - { - if(obsv != null) - { - obsv.failed(e.ice_name()); - } - throw e; - } - } - - public final void - __handleExceptionWrapper(_ObjectDel delegate, IceInternal.LocalExceptionWrapper ex, InvocationObserver obsv) - { - synchronized(this) - { - if(delegate == _delegate) - { - _delegate = null; - } - } - - if(!ex.retry()) - { - if(obsv != null) - { - obsv.failed(ex.get().ice_name()); + throw ex; } - throw ex.get(); - } - } - - public final int - __handleExceptionWrapperRelaxed(_ObjectDel delegate, - IceInternal.LocalExceptionWrapper ex, - Ice.IntHolder interval, - int cnt, - InvocationObserver obsv) - { - if(!ex.retry()) - { - return __handleException(delegate, ex.get(), interval, cnt, obsv); } else { - synchronized(this) - { - if(delegate == _delegate) - { - _delegate = null; - } - } - return cnt; + throw ex; // Retry could break at-most-once semantics, don't retry. } } @@ -2758,122 +2568,137 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable } } - public final _ObjectDel - __getDelegate(boolean ami) + public void + __invoke(IceInternal.Outgoing __og) { - if(_reference.getCacheConnection()) + // + // Helper for operations without out/return parameters and user + // exceptions. + // + boolean __ok = __og.invoke(); + if(__og.hasResponse()) { - synchronized(this) + if(!__ok) { - if(_delegate != null) + try + { + __og.throwUserException(); + } + catch(UserException __ex) { - return _delegate; + throw new UnknownUserException(__ex.ice_name(), __ex); } - // Connect asynchrously to avoid blocking with the proxy mutex locked. - _delegate = createDelegate(true); - return _delegate; } + __og.readEmptyParams(); } - else + } + + public final void + __end(AsyncResult __result, String operation) + { + AsyncResult.__check(__result, this, operation); + boolean ok = __result.__wait(); + if(_reference.getMode() == IceInternal.Reference.ModeTwoway) { - final int mode = _reference.getMode(); - return createDelegate(ami || - mode == IceInternal.Reference.ModeBatchOneway || - mode == IceInternal.Reference.ModeBatchDatagram); + if(!ok) + { + try + { + __result.__throwUserException(); + } + catch(UserException __ex) + { + throw new UnknownUserException(__ex.ice_name(), __ex); + } + } + __result.__readEmptyParams(); } } - synchronized public void - __setRequestHandler(_ObjectDel delegate, IceInternal.RequestHandler handler) + public final IceInternal.RequestHandler + __getRequestHandler(boolean async) { if(_reference.getCacheConnection()) { - if(delegate == _delegate) + synchronized(this) { - if(_delegate instanceof _ObjectDelM) + if(_requestHandler != null) { - _delegate = __createDelegateM(); - _delegate.__setRequestHandler(handler); - } - else if(_delegate instanceof _ObjectDelD) - { - _delegate = __createDelegateD(); - _delegate.__setRequestHandler(handler); + return _requestHandler; } + // async = true to avoid blocking with the proxy mutex locked. + _requestHandler = createRequestHandler(true); + return _requestHandler; } } + + final int mode = _reference.getMode(); + return createRequestHandler(async || + mode == IceInternal.Reference.ModeBatchOneway || + mode == IceInternal.Reference.ModeBatchDatagram); } - public final void - __end(AsyncResult __result, String operation) + public void + __setRequestHandler(IceInternal.RequestHandler previous, IceInternal.RequestHandler handler) { - AsyncResult.__check(__result, this, operation); - boolean ok = __result.__wait(); - if(_reference.getMode() == IceInternal.Reference.ModeTwoway) + if(_reference.getCacheConnection()) { - try + synchronized(this) { - if(!ok) + if(previous == _requestHandler) + { + _requestHandler = handler; + } + else if(previous != null && _requestHandler != null) { try { - __result.__throwUserException(); + // + // If both request handlers point to the same connection, we also + // update the request handler. See bug ICE-5489 for reasons why + // this can be useful. + // + if(previous.getConnection(false) == _requestHandler.getConnection(false)) + { + _requestHandler = handler; + } } - catch(UserException __ex) + catch(Ice.Exception ex) { - throw new UnknownUserException(__ex.ice_name(), __ex); + // Ignore } } - __result.__readEmptyParams(); - } - catch(Ice.LocalException ex) - { - InvocationObserver obsv = __result.__getObserver(); - if(obsv != null) - { - obsv.failed(ex.ice_name()); - } - throw ex; } } } - protected _ObjectDelM - __createDelegateM() - { - return new _ObjectDelM(); - } - - protected _ObjectDelD - __createDelegateD() - { - return new _ObjectDelD(); - } - - _ObjectDel - createDelegate(boolean async) + private IceInternal.RequestHandler + createRequestHandler(boolean async) { if(_reference.getCollocationOptimized()) { ObjectAdapter adapter = _reference.getInstance().objectAdapterFactory().findObjectAdapter(this); if(adapter != null) { - _ObjectDelD d = __createDelegateD(); - d.setup(_reference, adapter); - return d; + return new IceInternal.CollocatedRequestHandler(_reference, adapter); } } - _ObjectDelM d = __createDelegateM(); - d.setup(_reference, this, async); - return d; + if(async) + { + return (new IceInternal.ConnectRequestHandler(_reference, this)).connect(); + } + else + { + return new IceInternal.ConnectionRequestHandler(_reference, this); + } } // // Only for use by IceInternal.ProxyFactory // public final void - setup(IceInternal.Reference ref) + __setup(IceInternal.Reference ref) { // // No need to synchronize, as this operation is only called @@ -2881,7 +2706,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable // assert(_reference == null); - assert(_delegate == null); + assert(_requestHandler == null); _reference = ref; } @@ -2892,7 +2717,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable try { ObjectPrxHelperBase proxy = (ObjectPrxHelperBase)getClass().newInstance(); - proxy.setup(ref); + proxy.__setup(ref); return proxy; } catch(InstantiationException e) @@ -2934,7 +2759,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable } ObjectPrxHelperBase proxy = (ObjectPrxHelperBase)communicator.stringToProxy(s); _reference = proxy._reference; - assert(proxy._delegate == null); + assert(proxy._requestHandler == null); } catch(ClassCastException ex) { @@ -2951,9 +2776,55 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable } } - protected static final java.util.Map<String, String> _emptyContext = new java.util.HashMap<String, String>(); + protected IceInternal.Outgoing + getOutgoing(String operation, OperationMode mode, java.util.Map<String, String> context, boolean explicitCtx) + { + IceInternal.Outgoing out = null; + if(_reference.getInstance().cacheMessageBuffers() > 0) + { + synchronized(this) + { + if(_outgoingCache != null) + { + out = _outgoingCache; + _outgoingCache = _outgoingCache.next; + out.next = null; + } + } + } + if(out == null) + { + out = new IceInternal.Outgoing(this, operation, mode, context, explicitCtx); + } + else + { + out.reset(this, operation, mode, context, explicitCtx); + } + return out; + } + + protected void + reclaimOutgoing(IceInternal.Outgoing out) + { + out.detach(); + + if(_reference.getInstance().cacheMessageBuffers() > 0) + { + // + // Clear references to Ice objects as soon as possible. + // + out.reclaim(); + + synchronized(this) + { + out.next = _outgoingCache; + _outgoingCache = out; + } + } + } private transient IceInternal.Reference _reference; - private transient _ObjectDel _delegate; + private transient IceInternal.RequestHandler _requestHandler; + private transient IceInternal.Outgoing _outgoingCache; public static final long serialVersionUID = 0L; } diff --git a/java/src/Ice/OnewayCallback.java b/java/src/Ice/OnewayCallback.java index 71a50e268aa..c5cd16592a4 100644 --- a/java/src/Ice/OnewayCallback.java +++ b/java/src/Ice/OnewayCallback.java @@ -27,6 +27,16 @@ public abstract class OnewayCallback extends IceInternal.CallbackBase public abstract void exception(LocalException ex); /** + * Called when the invocation raises an Ice system exception. + * + * @param ex The Ice system exception raised by the operation. + **/ + public void exception(SystemException ex) + { + exception(new Ice.UnknownException(ex)); + } + + /** * Called when a queued invocation is sent successfully. **/ public void sent(boolean sentSynchronously) @@ -49,6 +59,11 @@ public abstract class OnewayCallback extends IceInternal.CallbackBase exception(__ex); return; } + catch(SystemException __ex) + { + exception(__ex); + return; + } response(); } } diff --git a/java/src/Ice/PropertiesI.java b/java/src/Ice/PropertiesI.java index 30575fdfd1e..6a6c9ec8ac6 100644 --- a/java/src/Ice/PropertiesI.java +++ b/java/src/Ice/PropertiesI.java @@ -378,7 +378,7 @@ public final class PropertiesI implements Properties { throw ex; } - catch(Exception ex) + catch(java.lang.Exception ex) { throw new InitializationException("Could not read Windows registry key `" + file + "'", ex); } diff --git a/java/src/Ice/Request.java b/java/src/Ice/Request.java index a0d2b0456a8..0cce04cbaf2 100644 --- a/java/src/Ice/Request.java +++ b/java/src/Ice/Request.java @@ -15,14 +15,6 @@ package Ice; public interface Request { /** - * Returns whether this request is collocated. - * - * @return <code>true</code> if the invocation was made via proxy created by the same communicator - * that hosts the target's object adapter; <code>false</code>, otherwise. - **/ - boolean isCollocated(); - - /** * Returns the {@link Current} object for this the request. * * @return The {@link Current} object for this request. diff --git a/java/src/Ice/SystemException.java b/java/src/Ice/SystemException.java index a5383e9a5cf..c00492fc6d0 100644 --- a/java/src/Ice/SystemException.java +++ b/java/src/Ice/SystemException.java @@ -9,36 +9,17 @@ package Ice; -public abstract class SystemException extends RuntimeException implements Cloneable +/** + * Base class for all Ice system exceptions. + **/ +public abstract class SystemException extends Exception { - public java.lang.Object clone() + public SystemException() { - java.lang.Object o = null; - try - { - o = super.clone(); - } - catch(CloneNotSupportedException ex) - { - assert false; // Impossible - } - return o; } - public abstract String - ice_name(); - - public String - toString() + public SystemException(Throwable cause) { - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - IceUtilInternal.OutputBase out = new IceUtilInternal.OutputBase(pw); - out.setUseTab(false); - out.print(getClass().getName()); - out.inc(); - IceInternal.ValueWriter.write(this, out); - pw.flush(); - return sw.toString(); + super(cause); } } diff --git a/java/src/Ice/TwowayCallback.java b/java/src/Ice/TwowayCallback.java index a5d5928e769..fbb035ca408 100644 --- a/java/src/Ice/TwowayCallback.java +++ b/java/src/Ice/TwowayCallback.java @@ -20,4 +20,11 @@ public interface TwowayCallback * @param ex The Ice run-time exception raised by the operation. **/ public void exception(LocalException __ex); + + /** + * Called when the invocation raises an Ice system exception. + * + * @param ex The Ice system exception raised by the operation. + **/ + public void exception(SystemException __ex); } diff --git a/java/src/Ice/UserException.java b/java/src/Ice/UserException.java index c5b91de3eb0..a46767287ef 100644 --- a/java/src/Ice/UserException.java +++ b/java/src/Ice/UserException.java @@ -12,7 +12,7 @@ package Ice; /** * Base class for Slice user exceptions. **/ -public abstract class UserException extends Exception implements Cloneable +public abstract class UserException extends java.lang.Exception implements Cloneable { public UserException() { diff --git a/java/src/Ice/_ObjectDel.java b/java/src/Ice/_ObjectDel.java deleted file mode 100644 index aa827e0fc58..00000000000 --- a/java/src/Ice/_ObjectDel.java +++ /dev/null @@ -1,36 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -package Ice; - -import Ice.Instrumentation.InvocationObserver; - -public interface _ObjectDel -{ - boolean ice_isA(String id, java.util.Map<String, String> context, InvocationObserver obsv) - throws IceInternal.LocalExceptionWrapper; - - void ice_ping(java.util.Map<String, String> context, InvocationObserver obsv) - throws IceInternal.LocalExceptionWrapper; - - String[] ice_ids(java.util.Map<String, String> context, InvocationObserver obsv) - throws IceInternal.LocalExceptionWrapper; - - String ice_id(java.util.Map<String, String> context, InvocationObserver obsv) - throws IceInternal.LocalExceptionWrapper; - - boolean ice_invoke(String operation, Ice.OperationMode mode, byte[] inParams, ByteSeqHolder outParams, - java.util.Map<String, String> context, InvocationObserver obsv) - throws IceInternal.LocalExceptionWrapper; - - void ice_flushBatchRequests(InvocationObserver obsv); - - IceInternal.RequestHandler __getRequestHandler(); - void __setRequestHandler(IceInternal.RequestHandler handler); -} diff --git a/java/src/Ice/_ObjectDelD.java b/java/src/Ice/_ObjectDelD.java deleted file mode 100644 index a784dde95a3..00000000000 --- a/java/src/Ice/_ObjectDelD.java +++ /dev/null @@ -1,314 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -package Ice; - -import Ice.Instrumentation.InvocationObserver; - -public class _ObjectDelD implements _ObjectDel -{ - public boolean - ice_isA(final String __id, java.util.Map<String, String> __context, InvocationObserver __observer) - throws IceInternal.LocalExceptionWrapper - { - final Current __current = new Current(); - __initCurrent(__current, "ice_isA", OperationMode.Nonmutating, __context); - - final BooleanHolder __result = new BooleanHolder(); - - IceInternal.Direct __direct = null; - try - { - __direct = new IceInternal.Direct(__current) - { - public DispatchStatus run(Ice.Object __servant) - { - __result.value = __servant.ice_isA(__id, __current); - return DispatchStatus.DispatchOK; - } - }; - } - catch(Throwable __ex) - { - IceInternal.LocalExceptionWrapper.throwWrapper(__ex); - } - - try - { - DispatchStatus __status = __direct.getServant().__collocDispatch(__direct); - assert __status == DispatchStatus.DispatchOK; - return __result.value; - } - catch(java.lang.Throwable __ex) - { - IceInternal.LocalExceptionWrapper.throwWrapper(__ex); - } - finally - { - try - { - __direct.destroy(); - } - catch(Throwable __ex) - { - IceInternal.LocalExceptionWrapper.throwWrapper(__ex); - } - } - return false; // Keep compiler happy. - } - - public void - ice_ping(java.util.Map<String, String> __context, InvocationObserver __observer) - throws IceInternal.LocalExceptionWrapper - { - final Current __current = new Current(); - __initCurrent(__current, "ice_ping", OperationMode.Nonmutating, __context); - - IceInternal.Direct __direct = null; - try - { - __direct = new IceInternal.Direct(__current) - { - public DispatchStatus run(Ice.Object __servant) - { - __servant.ice_ping(__current); - return DispatchStatus.DispatchOK; - } - }; - } - catch(Ice.UserException __ex) - { - UnknownUserException ex = new UnknownUserException(__ex.ice_name(), __ex); - throw new IceInternal.LocalExceptionWrapper(ex, false); - } - - try - { - DispatchStatus __status = __direct.getServant().__collocDispatch(__direct); - assert __status == DispatchStatus.DispatchOK; - } - catch(Throwable __ex) - { - IceInternal.LocalExceptionWrapper.throwWrapper(__ex); - } - finally - { - try - { - __direct.destroy(); - } - catch(Throwable __ex) - { - IceInternal.LocalExceptionWrapper.throwWrapper(__ex); - } - } - } - - public String[] - ice_ids(java.util.Map<String, String> __context, InvocationObserver __observer) - throws IceInternal.LocalExceptionWrapper - { - final Current __current = new Current(); - __initCurrent(__current, "ice_ids", OperationMode.Nonmutating, __context); - - final Ice.StringSeqHolder __result = new Ice.StringSeqHolder(); - - IceInternal.Direct __direct = null; - try - { - __direct = new IceInternal.Direct(__current) - { - - public DispatchStatus run(Ice.Object __servant) - { - __result.value = __servant.ice_ids(__current); - return DispatchStatus.DispatchOK; - } - }; - } - catch(Throwable __ex) - { - IceInternal.LocalExceptionWrapper.throwWrapper(__ex); - } - - try - { - DispatchStatus __status = __direct.getServant().__collocDispatch(__direct); - assert __status == DispatchStatus.DispatchOK; - return __result.value; - } - catch(Throwable __ex) - { - IceInternal.LocalExceptionWrapper.throwWrapper(__ex); - } - finally - { - try - { - __direct.destroy(); - } - catch(Throwable __ex) - { - IceInternal.LocalExceptionWrapper.throwWrapper(__ex); - } - } - return __result.value; // Keep compiler happy. - } - - public String - ice_id(java.util.Map<String, String> __context, InvocationObserver __observer) - throws IceInternal.LocalExceptionWrapper - { - final Current __current = new Current(); - __initCurrent(__current, "ice_id", OperationMode.Nonmutating, __context); - - final Ice.StringHolder __result = new Ice.StringHolder(); - - IceInternal.Direct __direct = null; - try - { - __direct = new IceInternal.Direct(__current) - { - public DispatchStatus run(Ice.Object __servant) - { - __result.value = __servant.ice_id(__current); - return DispatchStatus.DispatchOK; - } - }; - } - catch(Throwable __ex) - { - IceInternal.LocalExceptionWrapper.throwWrapper(__ex); - } - - try - { - DispatchStatus __status = __direct.getServant().__collocDispatch(__direct); - assert __status == DispatchStatus.DispatchOK; - return __result.value; - } - catch(Throwable __ex) - { - IceInternal.LocalExceptionWrapper.throwWrapper(__ex); - } - finally - { - try - { - __direct.destroy(); - } - catch(Throwable __ex) - { - IceInternal.LocalExceptionWrapper.throwWrapper(__ex); - } - } - return __result.value; // Keep compiler happy. - } - - public boolean - ice_invoke(String operation, Ice.OperationMode mode, byte[] inParams, ByteSeqHolder outParams, - java.util.Map<String, String> context, InvocationObserver observer) - { - throw new CollocationOptimizationException(); - } - - public void - ice_flushBatchRequests(InvocationObserver observer) - { - throw new CollocationOptimizationException(); - } - - public IceInternal.RequestHandler - __getRequestHandler() - { - throw new CollocationOptimizationException(); - } - - public void - __setRequestHandler(IceInternal.RequestHandler handler) - { - throw new CollocationOptimizationException(); - } - - // - // Only for use by ObjectPrx. - // - final void - __copyFrom(_ObjectDelD from) - { - // - // No need to synchronize "from", as the delegate is immutable - // after creation. - // - - // - // No need to synchronize, as this operation is only called - // upon initialization. - // - - assert(__reference == null); - assert(__adapter == null); - - __reference = from.__reference; - __adapter = from.__adapter; - } - - protected IceInternal.Reference __reference; - protected Ice.ObjectAdapter __adapter; - - protected final void - __initCurrent(Current current, String op, Ice.OperationMode mode, java.util.Map<String, String> context) - { - current.adapter = __adapter; - current.id = __reference.getIdentity(); - current.facet = __reference.getFacet(); - current.operation = op; - current.mode = mode; - - if(context != null) - { - current.ctx = context; - } - else - { - // - // Implicit context - // - ImplicitContextI implicitContext = - __reference.getInstance().getImplicitContext(); - - java.util.Map<String, String> prxContext = __reference.getContext(); - - if(implicitContext == null) - { - current.ctx = new java.util.HashMap<String, String>(prxContext); - } - else - { - current.ctx = implicitContext.combine(prxContext); - } - } - current.requestId = -1; - } - - public void - setup(IceInternal.Reference ref, Ice.ObjectAdapter adapter) - { - // - // No need to synchronize, as this operation is only called - // upon initialization. - // - - assert(__reference == null); - assert(__adapter == null); - - __reference = ref; - __adapter = adapter; - } -} diff --git a/java/src/Ice/_ObjectDelM.java b/java/src/Ice/_ObjectDelM.java deleted file mode 100644 index 069cccf2d4f..00000000000 --- a/java/src/Ice/_ObjectDelM.java +++ /dev/null @@ -1,271 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -package Ice; - -import Ice.Instrumentation.InvocationObserver; - -public class _ObjectDelM implements _ObjectDel -{ - public boolean - ice_isA(String __id, java.util.Map<String, String> __context, InvocationObserver __observer) - throws IceInternal.LocalExceptionWrapper - { - IceInternal.Outgoing __og = __handler.getOutgoing("ice_isA", OperationMode.Nonmutating, __context, __observer); - try - { - try - { - IceInternal.BasicStream __os = __og.startWriteParams(Ice.FormatType.DefaultFormat); - __os.writeString(__id); - __og.endWriteParams(); - } - catch(LocalException __ex) - { - __og.abort(__ex); - } - boolean __ok = __og.invoke(); - try - { - if(!__ok) - { - try - { - __og.throwUserException(); - } - catch(UserException __ex) - { - throw new UnknownUserException(__ex.ice_name(), __ex); - } - } - IceInternal.BasicStream __is = __og.startReadParams(); - boolean __ret = __is.readBool(); - __og.endReadParams(); - return __ret; - } - catch(LocalException __ex) - { - throw new IceInternal.LocalExceptionWrapper(__ex, false); - } - } - finally - { - __handler.reclaimOutgoing(__og); - } - } - - public void - ice_ping(java.util.Map<String, String> __context, InvocationObserver __observer) - throws IceInternal.LocalExceptionWrapper - { - IceInternal.Outgoing __og = __handler.getOutgoing("ice_ping", OperationMode.Nonmutating, __context, __observer); - try - { - __og.writeEmptyParams(); - boolean __ok = __og.invoke(); - if(__og.hasResponse()) - { - try - { - if(!__ok) - { - try - { - __og.throwUserException(); - } - catch(UserException __ex) - { - throw new UnknownUserException(__ex.ice_name(), __ex); - } - } - __og.readEmptyParams(); - } - catch(LocalException __ex) - { - throw new IceInternal.LocalExceptionWrapper(__ex, false); - } - } - } - finally - { - __handler.reclaimOutgoing(__og); - } - } - - public String[] - ice_ids(java.util.Map<String, String> __context, InvocationObserver __observer) - throws IceInternal.LocalExceptionWrapper - { - IceInternal.Outgoing __og = __handler.getOutgoing("ice_ids", OperationMode.Nonmutating, __context, __observer); - try - { - __og.writeEmptyParams(); - boolean __ok = __og.invoke(); - try - { - if(!__ok) - { - try - { - __og.throwUserException(); - } - catch(UserException __ex) - { - throw new UnknownUserException(__ex.ice_name(), __ex); - } - } - IceInternal.BasicStream __is = __og.startReadParams(); - String[] __ret = __is.readStringSeq(); - __og.endReadParams(); - return __ret; - } - catch(LocalException __ex) - { - throw new IceInternal.LocalExceptionWrapper(__ex, false); - } - } - finally - { - __handler.reclaimOutgoing(__og); - } - } - - public String - ice_id(java.util.Map<String, String> __context, InvocationObserver __observer) - throws IceInternal.LocalExceptionWrapper - { - IceInternal.Outgoing __og = __handler.getOutgoing("ice_id", OperationMode.Nonmutating, __context, __observer); - try - { - __og.writeEmptyParams(); - boolean __ok = __og.invoke(); - try - { - if(!__ok) - { - try - { - __og.throwUserException(); - } - catch(UserException __ex) - { - throw new UnknownUserException(__ex.ice_name(), __ex); - } - } - IceInternal.BasicStream __is = __og.startReadParams(); - String __ret = __is.readString(); - __og.endReadParams(); - return __ret; - } - catch(LocalException __ex) - { - throw new IceInternal.LocalExceptionWrapper(__ex, false); - } - } - finally - { - __handler.reclaimOutgoing(__og); - } - } - - public boolean - ice_invoke(String operation, OperationMode mode, byte[] inParams, ByteSeqHolder outParams, - java.util.Map<String, String> __context, InvocationObserver __observer) - throws IceInternal.LocalExceptionWrapper - { - IceInternal.Outgoing __og = __handler.getOutgoing(operation, mode, __context, __observer); - try - { - __og.writeParamEncaps(inParams); - boolean ok = __og.invoke(); - if(__handler.getReference().getMode() == IceInternal.Reference.ModeTwoway) - { - try - { - if(outParams != null) - { - outParams.value = __og.readParamEncaps(); - } - } - catch(LocalException __ex) - { - throw new IceInternal.LocalExceptionWrapper(__ex, false); - } - } - return ok; - } - finally - { - __handler.reclaimOutgoing(__og); - } - } - - public void - ice_flushBatchRequests(InvocationObserver observer) - { - IceInternal.BatchOutgoing out = new IceInternal.BatchOutgoing(__handler, observer); - out.invoke(); - } - - public IceInternal.RequestHandler - __getRequestHandler() - { - return __handler; - } - - public void - __setRequestHandler(IceInternal.RequestHandler handler) - { - __handler = handler; - } - - // - // Only for use by ObjectPrx - // - final void - __copyFrom(_ObjectDelM from) - { - // - // No need to synchronize "from", as the delegate is immutable - // after creation. - // - - // - // No need to synchronize, as this operation is only called - // upon initialization. - // - - assert(__handler == null); - - __handler = from.__handler; - } - - protected IceInternal.RequestHandler __handler; - - public void - setup(IceInternal.Reference ref, Ice.ObjectPrx proxy, boolean async) - { - // - // No need to synchronize, as this operation is only called - // upon initialization. - // - - assert(__handler == null); - - if(async) - { - IceInternal.ConnectRequestHandler handler = new IceInternal.ConnectRequestHandler(ref, proxy, this); - __handler = handler.connect(); - } - else - { - __handler = new IceInternal.ConnectionRequestHandler(ref, proxy); - } - } -} diff --git a/java/src/IceDiscovery/PluginI.java b/java/src/IceDiscovery/PluginI.java index f11f0f366cf..e78517cb068 100644 --- a/java/src/IceDiscovery/PluginI.java +++ b/java/src/IceDiscovery/PluginI.java @@ -15,22 +15,12 @@ public class PluginI implements Ice.Plugin PluginI(Ice.Communicator communicator) { _communicator = communicator; - - Ice.InitializationData initData = new Ice.InitializationData(); - initData.properties = communicator.getProperties()._clone(); - initData.properties.setProperty("Ice.Default.CollocationOptimized", "0"); - java.util.Map<String, String> props = initData.properties.getPropertiesForPrefix("Ice.Plugin."); - for(String key : props.keySet()) - { - initData.properties.setProperty(key, ""); - } - _pluginCommunicator = Ice.Util.initialize(initData); } public void initialize() { - Ice.Properties properties = _pluginCommunicator.getProperties(); + Ice.Properties properties = _communicator.getProperties(); boolean ipv4 = properties.getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0; String address; @@ -67,19 +57,19 @@ public class PluginI implements Ice.Plugin } if(properties.getProperty("IceDiscovery.Locator.Endpoints").isEmpty()) { - properties.setProperty("IceDiscovery.Locator.Endpoints", "tcp -h 127.0.0.1"); + properties.setProperty("IceDiscovery.Locator.AdapterId", java.util.UUID.randomUUID().toString()); } - Ice.ObjectAdapter multicastAdapter = _pluginCommunicator.createObjectAdapter("IceDiscovery.Multicast"); - Ice.ObjectAdapter replyAdapter = _pluginCommunicator.createObjectAdapter("IceDiscovery.Reply"); - Ice.ObjectAdapter locatorAdapter = _pluginCommunicator.createObjectAdapter("IceDiscovery.Locator"); + _multicastAdapter = _communicator.createObjectAdapter("IceDiscovery.Multicast"); + _replyAdapter = _communicator.createObjectAdapter("IceDiscovery.Reply"); + _locatorAdapter = _communicator.createObjectAdapter("IceDiscovery.Locator"); // // Setup locatory registry. // LocatorRegistryI locatorRegistry = new LocatorRegistryI(_communicator); Ice.LocatorRegistryPrx locatorRegistryPrx = Ice.LocatorRegistryPrxHelper.uncheckedCast( - locatorAdapter.addWithUUID(locatorRegistry)); + _locatorAdapter.addWithUUID(locatorRegistry)); String lookupEndpoints = properties.getProperty("IceDiscovery.Lookup"); if(lookupEndpoints.isEmpty()) @@ -93,36 +83,40 @@ public class PluginI implements Ice.Plugin lookupEndpoints = s.toString(); } - Ice.ObjectPrx lookupPrx = _pluginCommunicator.stringToProxy("IceDiscovery/Lookup -d:" + lookupEndpoints); - lookupPrx = lookupPrx.ice_collocationOptimized(false); + Ice.ObjectPrx lookupPrx = _communicator.stringToProxy("IceDiscovery/Lookup -d:" + lookupEndpoints); + lookupPrx = lookupPrx.ice_collocationOptimized(false); // No collocation optimization for the multicast proxy! // // Add lookup and lookup reply Ice objects // LookupI lookup = new LookupI(locatorRegistry, LookupPrxHelper.uncheckedCast(lookupPrx), properties); - multicastAdapter.add(lookup, _pluginCommunicator.stringToIdentity("IceDiscovery/Lookup")); + _multicastAdapter.add(lookup, _communicator.stringToIdentity("IceDiscovery/Lookup")); - Ice.ObjectPrx lookupReply = replyAdapter.addWithUUID(new LookupReplyI(lookup)).ice_datagram(); + Ice.ObjectPrx lookupReply = _replyAdapter.addWithUUID(new LookupReplyI(lookup)).ice_datagram(); lookup.setLookupReply(LookupReplyPrxHelper.uncheckedCast(lookupReply)); // // Setup locator on the communicator. // - Ice.ObjectPrx locator = locatorAdapter.addWithUUID(new LocatorI(lookup, locatorRegistryPrx)); + Ice.ObjectPrx locator = _locatorAdapter.addWithUUID(new LocatorI(lookup, locatorRegistryPrx)); _communicator.setDefaultLocator( Ice.LocatorPrxHelper.uncheckedCast(_communicator.stringToProxy(locator.toString()))); - multicastAdapter.activate(); - replyAdapter.activate(); - locatorAdapter.activate(); + _multicastAdapter.activate(); + _replyAdapter.activate(); + _locatorAdapter.activate(); } public void destroy() { - _pluginCommunicator.destroy(); + _multicastAdapter.destroy(); + _replyAdapter.destroy(); + _locatorAdapter.destroy(); } private Ice.Communicator _communicator; - private Ice.Communicator _pluginCommunicator; + private Ice.ObjectAdapter _multicastAdapter; + private Ice.ObjectAdapter _replyAdapter; + private Ice.ObjectAdapter _locatorAdapter; } diff --git a/java/src/IceInternal/BatchOutgoing.java b/java/src/IceInternal/BatchOutgoing.java index 65795d25c92..b60e29268aa 100644 --- a/java/src/IceInternal/BatchOutgoing.java +++ b/java/src/IceInternal/BatchOutgoing.java @@ -15,102 +15,145 @@ import Ice.Instrumentation.InvocationObserver; public final class BatchOutgoing implements OutgoingMessageCallback { public - BatchOutgoing(Ice.ConnectionI connection, Instance instance, InvocationObserver observer) + BatchOutgoing(Ice.ConnectionI connection, Instance instance, String op) { _connection = connection; _sent = false; _os = new BasicStream(instance, Protocol.currentProtocolEncoding); - _observer = observer; + _observer = IceInternal.ObserverHelper.get(instance, op); } public - BatchOutgoing(RequestHandler handler, InvocationObserver observer) + BatchOutgoing(Ice.ObjectPrxHelperBase proxy, String op) { - _handler = handler; + _proxy = proxy; _sent = false; - _os = new BasicStream(handler.getReference().getInstance(), Protocol.currentProtocolEncoding); - _observer = observer; - Protocol.checkSupportedProtocol(_handler.getReference().getProtocol()); + _os = new BasicStream(proxy.__reference().getInstance(), Protocol.currentProtocolEncoding); + _observer = IceInternal.ObserverHelper.get(proxy, op); + Protocol.checkSupportedProtocol(_proxy.__reference().getProtocol()); } public void invoke() { - assert(_handler != null || _connection != null); + assert(_proxy != null || _connection != null); - int timeout; if(_connection != null) { if(_connection.flushBatchRequests(this)) { return; } - timeout = -1; - } - else - { - try + + synchronized(this) { - if(_handler.sendRequest(this)) + while(_exception == null && !_sent) { - return; + try + { + wait(); + } + catch(InterruptedException ex) + { + } + } + if(_exception != null) + { + throw _exception; } } - catch(IceInternal.LocalExceptionWrapper ex) - { - throw ex.get(); - } - timeout = _handler.getReference().getInvocationTimeout(); + return; } - boolean timedOut = false; - synchronized(this) + RequestHandler handler = null; + try { - if(timeout > 0) + handler = _proxy.__getRequestHandler(false); + if(handler.sendRequest(this)) { - long now = Time.currentMonotonicTimeMillis(); - long deadline = now + timeout; - while(_exception == null && !_sent && !timedOut) + return; + } + + boolean timedOut = false; + synchronized(this) + { + int timeout = _proxy.__reference().getInvocationTimeout(); + if(timeout > 0) { - try + long now = Time.currentMonotonicTimeMillis(); + long deadline = now + timeout; + while(_exception == null && !_sent && !timedOut) { - wait(deadline - now); - if(_exception == null && !_sent) + try + { + wait(deadline - now); + if(_exception == null && !_sent) + { + now = Time.currentMonotonicTimeMillis(); + timedOut = now >= deadline; + } + } + catch(InterruptedException ex) { - now = Time.currentMonotonicTimeMillis(); - timedOut = now >= deadline; } } - catch(InterruptedException ex) + } + else + { + while(_exception == null && !_sent) { + try + { + wait(); + } + catch(InterruptedException ex) + { + } } } } - else + + if(timedOut) { - while(_exception == null && !_sent) + handler.requestTimedOut(this); + + synchronized(this) { - try - { - wait(); - } - catch(InterruptedException ex) + while(_exception == null) { + try + { + wait(); + } + catch(InterruptedException ex) + { + } } } } + + if(_exception != null) + { + throw (Ice.Exception)_exception.fillInStackTrace(); + } } - - if(timedOut) + catch(RetryException ex) { - _handler.requestTimedOut(this); - assert(_exception != null); + // + // Clear request handler but don't retry or throw. Retrying + // isn't useful, there were no batch requests associated with + // the proxy's request handler. + // + _proxy.__setRequestHandler(handler, null); } - - if(_exception != null) + catch(Ice.Exception ex) { - _exception.fillInStackTrace(); - throw _exception; + _proxy.__setRequestHandler(handler, null); // Clear request handler + if(_observer != null) + { + _observer.failed(ex.ice_name()); + } + throw ex; // Throw to notify the user that batch requests were potentially lost. } } @@ -120,6 +163,12 @@ public final class BatchOutgoing implements OutgoingMessageCallback return connection.flushBatchRequests(this); } + public void + invokeCollocated(CollocatedRequestHandler handler) + { + handler.invokeBatchRequests(this); + } + synchronized public void sent() { @@ -133,7 +182,7 @@ public final class BatchOutgoing implements OutgoingMessageCallback } public synchronized void - finished(Ice.LocalException ex, boolean sent) + finished(Ice.Exception ex, boolean sent) { if(_remoteObserver != null) { @@ -164,11 +213,23 @@ public final class BatchOutgoing implements OutgoingMessageCallback } } - private RequestHandler _handler; + public void attachCollocatedObserver(int requestId) + { + if(_observer != null) + { + _remoteObserver = _observer.getCollocatedObserver(requestId, _os.size() - Protocol.headerSize - 4); + if(_remoteObserver != null) + { + _remoteObserver.attach(); + } + } + } + + private Ice.ObjectPrxHelperBase _proxy; private Ice.ConnectionI _connection; private BasicStream _os; private boolean _sent; - private Ice.LocalException _exception; + private Ice.Exception _exception; private InvocationObserver _observer; private Observer _remoteObserver; diff --git a/java/src/IceInternal/BatchOutgoingAsync.java b/java/src/IceInternal/BatchOutgoingAsync.java index cfec8416234..6153624c88e 100644 --- a/java/src/IceInternal/BatchOutgoingAsync.java +++ b/java/src/IceInternal/BatchOutgoingAsync.java @@ -22,13 +22,19 @@ public class BatchOutgoingAsync extends Ice.AsyncResult implements OutgoingAsync return connection.flushAsyncBatchRequests(this); } + public int + __invokeCollocated(CollocatedRequestHandler handler) + { + return handler.invokeAsyncBatchRequests(this); + } + public boolean __sent() { synchronized(_monitor) { _state |= Done | OK | Sent; - _os.resize(0, false); // Clear buffer now, instead of waiting for AsyncResult deallocation + //_os.resize(0, false); // Don't clear the buffer now, it's needed for the collocation optimization if(_remoteObserver != null) { _remoteObserver.detach(); @@ -51,7 +57,7 @@ public class BatchOutgoingAsync extends Ice.AsyncResult implements OutgoingAsync } public void - __finished(Ice.LocalException exc, boolean sent) + __finished(Ice.Exception exc, boolean sent) { if(_remoteObserver != null) { diff --git a/java/src/IceInternal/CollocatedRequestHandler.java b/java/src/IceInternal/CollocatedRequestHandler.java new file mode 100644 index 00000000000..13965c3c10b --- /dev/null +++ b/java/src/IceInternal/CollocatedRequestHandler.java @@ -0,0 +1,735 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package IceInternal; + +import Ice.Instrumentation.InvocationObserver; + +public class CollocatedRequestHandler implements RequestHandler, ResponseHandler +{ + class InvokeAll extends DispatchWorkItem + { + public + InvokeAll(OutgoingMessageCallback out, BasicStream os, int requestId, int invokeNum, boolean batch) + { + _out = out; + _os = os; + _requestId = requestId; + _invokeNum = invokeNum; + _batch = batch; + } + + public void + run() + { + if(sent(_out)) + { + invokeAll(_os, _requestId, _invokeNum, _batch); + } + } + + private final OutgoingMessageCallback _out; + private final BasicStream _os; + private final int _requestId; + private final int _invokeNum; + private final boolean _batch; + }; + + class InvokeAllAsync extends DispatchWorkItem + { + public InvokeAllAsync(OutgoingAsyncMessageCallback outAsync, BasicStream os, int requestId, int invokeNum, + boolean batch) + { + _outAsync = outAsync; + _os = os; + _requestId = requestId; + _invokeNum = invokeNum; + _batch = batch; + } + + public void + run() + { + if(sentAsync(_outAsync)) + { + invokeAll(_os, _requestId, _invokeNum, _batch); + } + } + + private final OutgoingAsyncMessageCallback _outAsync; + private final BasicStream _os; + private final int _requestId; + private final int _invokeNum; + private final boolean _batch; + }; + + private void + fillInValue(BasicStream os, int pos, int value) + { + os.pos(pos); + os.writeInt(value); + } + + public + CollocatedRequestHandler(Reference ref, Ice.ObjectAdapter adapter) + { + _reference = ref; + _response = _reference.getMode() == Reference.ModeTwoway; + _adapter = (Ice.ObjectAdapterI)adapter; + + _logger = _reference.getInstance().initializationData().logger; // Cached for better performance. + _traceLevels = _reference.getInstance().traceLevels(); // Cached for better performance. + _batchAutoFlush = ref.getInstance().initializationData().properties.getPropertyAsIntWithDefault( + "Ice.BatchAutoFlush", 1) > 0; + _requestId = 0; + _batchStreamInUse = false; + _batchRequestNum = 0; + _batchStream = new BasicStream(ref.getInstance(), Protocol.currentProtocolEncoding, _batchAutoFlush); + } + + synchronized public void + prepareBatchRequest(BasicStream os) + { + while(_batchStreamInUse) + { + try + { + wait(); + } + catch(java.lang.InterruptedException ex) + { + } + } + + if(_batchStream.isEmpty()) + { + try + { + _batchStream.writeBlob(Protocol.requestBatchHdr); + } + catch(Ice.LocalException ex) + { + throw ex; + } + } + + _batchStreamInUse = true; + _batchMarker = _batchStream.size(); + _batchStream.swap(os); + } + + public void + finishBatchRequest(BasicStream os) + { + try + { + synchronized(this) + { + _batchStream.swap(os); + + if(_batchAutoFlush & (_batchStream.size() > _reference.getInstance().messageSizeMax())) + { + // + // Temporarily save the last request. + // + byte[] lastRequest = new byte[_batchStream.size() - _batchMarker]; + Buffer buffer = _batchStream.getBuffer(); + buffer.b.position(_batchMarker); + buffer.b.get(lastRequest); + _batchStream.resize(_batchMarker, false); + + final int invokeNum = _batchRequestNum; + final BasicStream stream = new BasicStream(_reference.getInstance(), + Protocol.currentProtocolEncoding, + _batchAutoFlush); + stream.swap(_batchStream); + + _adapter.getThreadPool().execute( + new DispatchWorkItem() + { + public void + run() + { + CollocatedRequestHandler.this.invokeAll(stream, 0, invokeNum, true); + } + }); + + // + // Reset the batch. + // + _batchRequestNum = 0; + _batchMarker = 0; + + // + // Check again if the last request doesn't exceed what we can send with the auto flush + // + if(Protocol.requestBatchHdr.length + lastRequest.length > _reference.getInstance().messageSizeMax()) + { + Ex.throwMemoryLimitException(Protocol.requestBatchHdr.length + lastRequest.length, + _reference.getInstance().messageSizeMax()); + } + + // + // Start a new batch with the last message that caused us to go over the limit. + // + _batchStream.writeBlob(Protocol.requestBatchHdr); + _batchStream.writeBlob(lastRequest); + } + + // + // Increment the number of requests in the batch. + // + assert(_batchStreamInUse); + ++_batchRequestNum; + _batchStreamInUse = false; + notifyAll(); + } + } + catch(Ice.LocalException ex) + { + abortBatchRequest(); + throw ex; + } + } + + synchronized public void + abortBatchRequest() + { + BasicStream dummy = new BasicStream(_reference.getInstance(), Protocol.currentProtocolEncoding, + _batchAutoFlush); + _batchStream.swap(dummy); + _batchRequestNum = 0; + _batchMarker = 0; + + assert(_batchStreamInUse); + _batchStreamInUse = false; + notifyAll(); + } + + public boolean + sendRequest(OutgoingMessageCallback out) + { + out.invokeCollocated(this); + return !_response && _reference.getInvocationTimeout() == 0; + } + + public int + sendAsyncRequest(OutgoingAsyncMessageCallback outAsync) + { + return outAsync.__invokeCollocated(this); + } + + synchronized public void + requestTimedOut(OutgoingMessageCallback out) + { + Integer requestId = _sendRequests.get(out); + if(requestId != null) + { + if(requestId > 0) + { + _requests.remove(requestId); + } + out.finished(new Ice.InvocationTimeoutException(), false); + _sendRequests.remove(out); + } + else if(out instanceof Outgoing) + { + Outgoing o = (Outgoing)out; + assert(o != null); + for(java.util.Map.Entry<Integer, Outgoing> e : _requests.entrySet()) + { + if(e.getValue() == o) + { + o.finished(new Ice.InvocationTimeoutException(), true); + _requests.remove(e.getKey()); + return; // We're done. + } + } + } + } + + public void + asyncRequestTimedOut(OutgoingAsyncMessageCallback outAsync) + { + OutgoingAsyncMessageCallback out = null; + boolean sent = false; + synchronized(this) + { + Integer requestId = _sendAsyncRequests.get(outAsync); + if(requestId != null) + { + if(requestId > 0) + { + _asyncRequests.remove(requestId); + } + out = outAsync; + sent = false; + _sendAsyncRequests.remove(outAsync); + } + else if(outAsync instanceof OutgoingAsync) + { + OutgoingAsync o = (OutgoingAsync)outAsync; + assert(o != null); + for(java.util.Map.Entry<Integer, OutgoingAsync> e : _asyncRequests.entrySet()) + { + if(e.getValue() == o) + { + out = o; + sent = true; + _asyncRequests.remove(e.getKey()); + break; + } + } + } + } + + if(out != null) + { + out.__finished(new Ice.InvocationTimeoutException(), sent); + } + } + + public void + invokeRequest(Outgoing out) + { + int requestId = 0; + if(_reference.getInvocationTimeout() > 0 || _response) + { + synchronized(this) + { + if(_response) + { + requestId = ++_requestId; + _requests.put(requestId, out); + } + if(_reference.getInvocationTimeout() > 0) + { + _sendRequests.put(out, requestId); + } + } + } + + out.attachCollocatedObserver(requestId); + + if(_reference.getInvocationTimeout() > 0) + { + _adapter.getThreadPool().execute(new InvokeAll(out, out.os(), requestId, 1, false)); + } + else + { + out.sent(); + invokeAll(out.os(), requestId, 1, false); + } + } + + public int + invokeAsyncRequest(OutgoingAsync outAsync) + { + int requestId = 0; + if(_reference.getInvocationTimeout() > 0 || _response) + { + synchronized(this) + { + if(_response) + { + requestId = ++_requestId; + _asyncRequests.put(requestId, outAsync); + } + if(_reference.getInvocationTimeout() > 0) + { + _sendAsyncRequests.put(outAsync, requestId); + } + } + } + + outAsync.__attachCollocatedObserver(requestId); + + _adapter.getThreadPool().execute(new InvokeAllAsync(outAsync, outAsync.__getOs(), requestId, 1, false)); + + return AsyncStatus.Queued; + } + + public void + invokeBatchRequests(BatchOutgoing out) + { + int invokeNum; + synchronized(this) + { + while(_batchStreamInUse) + { + try + { + wait(); + } + catch(java.lang.InterruptedException ex) + { + } + } + + invokeNum = _batchRequestNum; + + if(_batchRequestNum > 0) + { + if(_reference.getInvocationTimeout() > 0) + { + _sendRequests.put(out, 0); + } + + assert(!_batchStream.isEmpty()); + _batchStream.swap(out.os()); + + // + // Reset the batch stream. + // + BasicStream dummy = new BasicStream(_reference.getInstance(), Protocol.currentProtocolEncoding, + _batchAutoFlush); + _batchStream.swap(dummy); + _batchRequestNum = 0; + _batchMarker = 0; + } + } + + out.attachCollocatedObserver(0); + + if(invokeNum > 0) + { + if(_reference.getInvocationTimeout() > 0) + { + _adapter.getThreadPool().execute(new InvokeAll(out, out.os(), 0, invokeNum, true)); + } + else + { + out.sent(); + invokeAll(out.os(), 0, invokeNum, true); + } + } + else + { + out.sent(); + } + } + + public int + invokeAsyncBatchRequests(BatchOutgoingAsync outAsync) + { + int invokeNum; + synchronized(this) + { + while(_batchStreamInUse) + { + try + { + wait(); + } + catch(java.lang.InterruptedException ex) + { + } + } + + invokeNum = _batchRequestNum; + if(_batchRequestNum > 0) + { + if(_reference.getInvocationTimeout() > 0) + { + _sendAsyncRequests.put(outAsync, 0); + } + + assert(!_batchStream.isEmpty()); + _batchStream.swap(outAsync.__getOs()); + + // + // Reset the batch stream. + // + BasicStream dummy = new BasicStream(_reference.getInstance(), Protocol.currentProtocolEncoding, + _batchAutoFlush); + _batchStream.swap(dummy); + _batchRequestNum = 0; + _batchMarker = 0; + } + } + + outAsync.__attachCollocatedObserver(0); + + if(invokeNum > 0) + { + _adapter.getThreadPool().execute(new InvokeAllAsync(outAsync, outAsync.__getOs(), 0, invokeNum, true)); + return AsyncStatus.Queued; + } + else if(outAsync.__sent()) + { + return AsyncStatus.Sent | AsyncStatus.InvokeSentCallback; + } + else + { + return AsyncStatus.Sent; + } + } + + public void + sendResponse(int requestId, BasicStream os, byte status) + { + OutgoingAsync outAsync = null; + synchronized(this) + { + assert(_response); + + os.pos(Protocol.replyHdr.length + 4); + + if(_traceLevels.protocol >= 1) + { + fillInValue(os, 10, os.size()); + TraceUtil.traceRecv(os, _logger, _traceLevels); + } + + Outgoing out = _requests.get(requestId); + if(out != null) + { + out.finished(os); + _requests.remove(requestId); + } + else + { + outAsync = _asyncRequests.get(requestId); + if(outAsync != null) + { + _asyncRequests.remove(requestId); + } + } + } + + if(outAsync != null) + { + outAsync.__finished(os); + } + _adapter.decDirectCount(); + } + + public void + sendNoResponse() + { + _adapter.decDirectCount(); + } + + public void + invokeException(int requestId, Ice.LocalException ex, int invokeNum) + { + if(requestId > 0) + { + OutgoingAsync outAsync = null; + synchronized(this) + { + Outgoing out = _requests.remove(requestId); + if(out != null) + { + out.finished(ex, true); + } + else + { + outAsync = _asyncRequests.remove(requestId); + } + } + if(outAsync != null) + { + outAsync.__finished(ex, true); + } + } + _adapter.decDirectCount(); + } + + public Reference + getReference() + { + return _reference; + } + + public Ice.ConnectionI + getConnection(boolean wait) + { + return null; + } + + boolean + sent(OutgoingMessageCallback out) + { + if(_reference.getInvocationTimeout() > 0) + { + synchronized(this) + { + if(_sendRequests.remove(out) == null) + { + return false; // The request timed-out. + } + out.sent(); + } + } + else + { + out.sent(); + } + return true; + } + + boolean + sentAsync(OutgoingAsyncMessageCallback outAsync) + { + if(_reference.getInvocationTimeout() > 0) + { + synchronized(this) + { + if(_sendAsyncRequests.remove(outAsync) == null) + { + return false; // The request timed-out. + } + } + } + if(outAsync.__sent()) + { + outAsync.__invokeSent(); + } + return true; + } + + void + invokeAll(BasicStream os, int requestId, int invokeNum, boolean batch) + { + if(batch) + { + os.pos(Protocol.requestBatchHdr.length); + } + else + { + os.pos(Protocol.requestHdr.length); + } + + if(_traceLevels.protocol >= 1) + { + fillInValue(os, 10, os.size()); + if(requestId > 0) + { + fillInValue(os, Protocol.headerSize, requestId); + } + else if(batch) + { + fillInValue(os, Protocol.headerSize, invokeNum); + } + TraceUtil.traceSend(os, _logger, _traceLevels); + } + + ServantManager servantManager = _adapter.getServantManager(); + try + { + while(invokeNum > 0) + { + try + { + _adapter.incDirectCount(); + } + catch(Ice.ObjectAdapterDeactivatedException ex) + { + handleException(requestId, ex, false); + return; + } + + Incoming in = new Incoming(_reference.getInstance(), this, null, _adapter, _response, (byte)0, + requestId); + try + { + in.invoke(servantManager, os); + } + catch(Ice.SystemException ex) + { + handleException(requestId, ex, true); + _adapter.decDirectCount(); + } + --invokeNum; + } + } + catch(Ice.LocalException ex) + { + invokeException(requestId, ex, invokeNum); // Fatal invocation exception + } + catch(java.lang.AssertionError ex) // Upon assertion, we print the stack trace. + { + Ice.UnknownException uex = new Ice.UnknownException(ex); + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + ex.printStackTrace(pw); + pw.flush(); + uex.unknown = sw.toString(); + _logger.error(uex.unknown); + invokeException(requestId, uex, invokeNum); + } + catch(java.lang.OutOfMemoryError ex) + { + Ice.UnknownException uex = new Ice.UnknownException(ex); + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + ex.printStackTrace(pw); + pw.flush(); + uex.unknown = sw.toString(); + _logger.error(uex.unknown); + invokeException(requestId, uex, invokeNum); + } + } + + void + handleException(int requestId, Ice.Exception ex, boolean sent) + { + if(requestId == 0) + { + return; // Ignore exception for oneway messages. + } + + OutgoingAsync outAsync = null; + synchronized(this) + { + Outgoing out = _requests.get(requestId); + if(out != null) + { + out.finished(ex, sent); + _requests.remove(requestId); + } + else + { + outAsync = _asyncRequests.get(requestId); + if(outAsync != null) + { + _asyncRequests.remove(requestId); + } + } + } + + if(outAsync != null) + { + outAsync.__finished(ex, sent); + } + } + + private final Reference _reference; + private final boolean _response; + private final Ice.ObjectAdapterI _adapter; + private final Ice.Logger _logger; + private final TraceLevels _traceLevels; + private boolean _batchAutoFlush; + + private int _requestId; + + private java.util.Map<OutgoingMessageCallback, Integer> _sendRequests = + new java.util.HashMap<OutgoingMessageCallback, Integer>(); + private java.util.Map<OutgoingAsyncMessageCallback, Integer> _sendAsyncRequests = + new java.util.HashMap<OutgoingAsyncMessageCallback, Integer>(); + + private java.util.Map<Integer, Outgoing> _requests = new java.util.HashMap<Integer, Outgoing>(); + private java.util.Map<Integer, OutgoingAsync> _asyncRequests = new java.util.HashMap<Integer, OutgoingAsync>(); + + private BasicStream _batchStream; + private boolean _batchStreamInUse; + private int _batchRequestNum; + private int _batchMarker; +} diff --git a/java/src/IceInternal/CommunicatorObserverI.java b/java/src/IceInternal/CommunicatorObserverI.java index b63ba033633..bf23296294a 100644 --- a/java/src/IceInternal/CommunicatorObserverI.java +++ b/java/src/IceInternal/CommunicatorObserverI.java @@ -262,13 +262,21 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb public Ice.ConnectionInfo getConnectionInfo() { - return _current.con.getInfo(); + if(_current.con != null) + { + return _current.con.getInfo(); + } + return null; } public Ice.Endpoint getEndpoint() { - return _current.con.getEndpoint(); + if(_current.con != null) + { + return _current.con.getEndpoint(); + } + return null; } public Ice.Connection @@ -280,7 +288,7 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb public Ice.EndpointInfo getEndpointInfo() { - if(_endpointInfo == null) + if(_current.con != null && _endpointInfo == null) { _endpointInfo = _current.con.getEndpoint().getInfo(); } diff --git a/java/src/IceInternal/ConnectRequestHandler.java b/java/src/IceInternal/ConnectRequestHandler.java index 0cfe4e61aac..8b2f346a997 100644 --- a/java/src/IceInternal/ConnectRequestHandler.java +++ b/java/src/IceInternal/ConnectRequestHandler.java @@ -59,7 +59,7 @@ public class ConnectRequestHandler public void prepareBatchRequest(BasicStream os) - throws LocalExceptionWrapper + throws RetryException { synchronized(this) { @@ -74,11 +74,18 @@ public class ConnectRequestHandler } } - if(!initialized()) + try { - _batchRequestInProgress = true; - _batchStream.swap(os); - return; + if(!initialized()) + { + _batchRequestInProgress = true; + _batchStream.swap(os); + return; + } + } + catch(Ice.LocalException ex) + { + throw new RetryException(ex); } } @@ -90,7 +97,7 @@ public class ConnectRequestHandler { synchronized(this) { - if(!initialized()) + if(!initialized()) // This can't throw until _batchRequestInProgress = false { assert(_batchRequestInProgress); _batchRequestInProgress = false; @@ -117,7 +124,7 @@ public class ConnectRequestHandler { synchronized(this) { - if(!initialized()) + if(!initialized()) // This can't throw until _batchRequestInProgress = false { assert(_batchRequestInProgress); _batchRequestInProgress = false; @@ -136,14 +143,21 @@ public class ConnectRequestHandler public boolean sendRequest(OutgoingMessageCallback out) - throws LocalExceptionWrapper + throws RetryException { synchronized(this) { - if(!initialized()) + try + { + if(!initialized()) + { + _requests.add(new Request(out)); + return false; // Not sent + } + } + catch(Ice.LocalException ex) { - _requests.add(new Request(out)); - return false; // Not sent + throw new RetryException(ex); } } return out.send(_connection, _compress, _response) && !_response; // Finished if sent and no response. @@ -151,14 +165,21 @@ public class ConnectRequestHandler public int sendAsyncRequest(OutgoingAsyncMessageCallback out) - throws LocalExceptionWrapper + throws RetryException { synchronized(this) { - if(!initialized()) + try { - _requests.add(new Request(out)); - return AsyncStatus.Queued; + if(!initialized()) + { + _requests.add(new Request(out)); + return AsyncStatus.Queued; + } + } + catch(Ice.LocalException ex) + { + throw new RetryException(ex); } } return out.__send(_connection, _compress, _response); @@ -169,6 +190,11 @@ public class ConnectRequestHandler { synchronized(this) { + if(_exception != null) + { + return; // The request has been notified of a failure already. + } + if(!initialized()) { java.util.Iterator<Request> it = _requests.iterator(); @@ -191,8 +217,14 @@ public class ConnectRequestHandler public void asyncRequestTimedOut(OutgoingAsyncMessageCallback outAsync) { + boolean timedOut = false; synchronized(this) { + if(_exception != null) + { + return; // The request has been notified of a failure already. + } + if(!initialized()) { java.util.Iterator<Request> it = _requests.iterator(); @@ -201,45 +233,19 @@ public class ConnectRequestHandler Request request = it.next(); if(request.outAsync == outAsync) { - outAsync.__finished(new Ice.InvocationTimeoutException(), false); it.remove(); - return; + timedOut = true; + break; } } - assert(false); // The request has to be queued if it timed out and we're not initialized yet. - } - } - _connection.asyncRequestTimedOut(outAsync); - } - - public Outgoing - getOutgoing(String operation, Ice.OperationMode mode, java.util.Map<String, String> context, - InvocationObserver observer) - throws LocalExceptionWrapper - { - synchronized(this) - { - if(!initialized()) - { - return new IceInternal.Outgoing(this, operation, mode, context, observer); } } - - return _connection.getOutgoing(this, operation, mode, context, observer); - } - - public void - reclaimOutgoing(Outgoing out) - { - synchronized(this) + if(timedOut) { - if(_connection == null) - { - return; - } + outAsync.__finished(new Ice.InvocationTimeoutException(), false); + return; } - - _connection.reclaimOutgoing(out); + _connection.asyncRequestTimedOut(outAsync); } public Reference @@ -319,7 +325,6 @@ public class ConnectRequestHandler _exception = ex; _proxy = null; // Break cyclic reference count. - _delegate = null; // Break cyclic reference count. // // If some requests were queued, we notify them of the failure. This is done from a thread @@ -328,14 +333,14 @@ public class ConnectRequestHandler // if(!_requests.isEmpty()) { - _reference.getInstance().clientThreadPool().execute(new DispatchWorkItem(_reference.getInstance()) - { - public void - run() - { - flushRequestsWithException(ex); - }; - }); + _reference.getInstance().clientThreadPool().execute(new DispatchWorkItem() + { + public void + run() + { + flushRequestsWithException(); + }; + }); } notifyAll(); @@ -355,12 +360,11 @@ public class ConnectRequestHandler } public - ConnectRequestHandler(Reference ref, Ice.ObjectPrx proxy, Ice._ObjectDelM delegate) + ConnectRequestHandler(Reference ref, Ice.ObjectPrx proxy) { _reference = ref; _response = _reference.getMode() == Reference.ModeTwoway; _proxy = (Ice.ObjectPrxHelperBase)proxy; - _delegate = delegate; _batchAutoFlush = ref.getInstance().initializationData().properties.getPropertyAsIntWithDefault( "Ice.BatchAutoFlush", 1) > 0 ? true : false; _initialized = false; @@ -470,18 +474,25 @@ public class ConnectRequestHandler p.remove(); } } - catch(final LocalExceptionWrapper ex) + catch(final RetryException ex) { + // + // If the connection dies shortly after connection + // establishment, we don't systematically retry on + // RetryException. We handle the exception like it + // was an exception that occured while sending the + // request. + // synchronized(this) { assert(_exception == null && !_requests.isEmpty()); _exception = ex.get(); - _reference.getInstance().clientThreadPool().execute(new DispatchWorkItem(_reference.getInstance()) + _reference.getInstance().clientThreadPool().execute(new DispatchWorkItem() { public void run() { - flushRequestsWithException(ex); + flushRequestsWithException(); }; }); } @@ -492,12 +503,12 @@ public class ConnectRequestHandler { assert(_exception == null && !_requests.isEmpty()); _exception = ex; - _reference.getInstance().clientThreadPool().execute(new DispatchWorkItem(_reference.getInstance()) + _reference.getInstance().clientThreadPool().execute(new DispatchWorkItem() { public void run() { - flushRequestsWithException(ex); + flushRequestsWithException(); }; }); } @@ -505,20 +516,20 @@ public class ConnectRequestHandler if(!sentCallbacks.isEmpty()) { - final Instance instance = _reference.getInstance(); - instance.clientThreadPool().execute(new DispatchWorkItem(instance) - { - public void - run() - { - for(OutgoingAsyncMessageCallback callback : sentCallbacks) - { - callback.__invokeSent(); - } - }; - }); + _reference.getInstance().clientThreadPool().execute( + new DispatchWorkItem() + { + public void + run() + { + for(OutgoingAsyncMessageCallback callback : sentCallbacks) + { + callback.__invokeSent(); + } + }; + }); } - + // // We've finished sending the queued requests and the request handler now send // the requests over the connection directly. It's time to substitute the @@ -530,7 +541,7 @@ public class ConnectRequestHandler // if(_updateRequestHandler && _exception == null) { - _proxy.__setRequestHandler(_delegate, new ConnectionRequestHandler(_reference, _connection, _compress)); + _proxy.__setRequestHandler(this, new ConnectionRequestHandler(_reference, _connection, _compress)); } synchronized(this) @@ -542,54 +553,22 @@ public class ConnectRequestHandler _flushing = false; } _proxy = null; // Break cyclic reference count. - _delegate = null; // Break cyclic reference count. notifyAll(); } } void - flushRequestsWithException(Ice.LocalException ex) - { - for(Request request : _requests) - { - if(request.out != null) - { - request.out.finished(ex, false); - } - else if(request.outAsync != null) - { - request.outAsync.__finished(ex, false); - } - } - _requests.clear(); - } - - void - flushRequestsWithException(LocalExceptionWrapper ex) + flushRequestsWithException() { for(Request request : _requests) { if(request.out != null) { - if(request.out instanceof Outgoing) - { - ((Outgoing)request.out).finished(ex); - } - else - { - request.out.finished(ex.get(), false); - } + request.out.finished(_exception, false); } else if(request.outAsync != null) { - if(request.outAsync instanceof OutgoingAsync) - { - ((OutgoingAsync)request.outAsync).__finished(ex); - } - else - { - request.outAsync.__finished(ex.get(), false); - } + request.outAsync.__finished(_exception, false); } } _requests.clear(); @@ -599,7 +578,6 @@ public class ConnectRequestHandler private boolean _response; private Ice.ObjectPrxHelperBase _proxy; - private Ice._ObjectDelM _delegate; private final boolean _batchAutoFlush; diff --git a/java/src/IceInternal/ConnectionRequestHandler.java b/java/src/IceInternal/ConnectionRequestHandler.java index 07a8d9c43e0..7820790e794 100644 --- a/java/src/IceInternal/ConnectionRequestHandler.java +++ b/java/src/IceInternal/ConnectionRequestHandler.java @@ -15,7 +15,7 @@ public class ConnectionRequestHandler implements RequestHandler { public void prepareBatchRequest(BasicStream out) - throws LocalExceptionWrapper + throws RetryException { _connection.prepareBatchRequest(out); } @@ -34,14 +34,14 @@ public class ConnectionRequestHandler implements RequestHandler public boolean sendRequest(OutgoingMessageCallback out) - throws LocalExceptionWrapper + throws RetryException { return out.send(_connection, _compress, _response) && !_response; // Finished if sent and no response } public int sendAsyncRequest(OutgoingAsyncMessageCallback out) - throws LocalExceptionWrapper + throws RetryException { return out.__send(_connection, _compress, _response); } @@ -58,20 +58,6 @@ public class ConnectionRequestHandler implements RequestHandler _connection.asyncRequestTimedOut(outAsync); } - public Outgoing - getOutgoing(String operation, Ice.OperationMode mode, java.util.Map<String, String> context, - InvocationObserver observer) - throws LocalExceptionWrapper - { - return _connection.getOutgoing(this, operation, mode, context, observer); - } - - public void - reclaimOutgoing(Outgoing out) - { - _connection.reclaimOutgoing(out); - } - public Reference getReference() { diff --git a/java/src/IceInternal/Direct.java b/java/src/IceInternal/Direct.java deleted file mode 100644 index 8456939a295..00000000000 --- a/java/src/IceInternal/Direct.java +++ /dev/null @@ -1,140 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -package IceInternal; - -public abstract class Direct implements Ice.Request -{ - public abstract Ice.DispatchStatus run(Ice.Object target); - - public final boolean isCollocated() - { - return true; - } - - public final Ice.Current getCurrent() - { - return _current; - } - - - public - Direct(Ice.Current current) throws Ice.UserException - { - _current = current; - - Ice.ObjectAdapterI adapter = (Ice.ObjectAdapterI)_current.adapter; - assert(adapter != null); - - // - // Must call incDirectCount() first, because it checks for - // adapter deactivation, and prevents deactivation completion - // until decDirectCount() is called. This is important, - // because getServantManager() may not be called afer - // deactivation completion. - // - adapter.incDirectCount(); - - ServantManager servantManager = adapter.getServantManager(); - assert(servantManager != null); - - _servant = servantManager.findServant(_current.id, _current.facet); - if(_servant == null) - { - _locator = servantManager.findServantLocator(_current.id.category); - if(_locator == null && _current.id.category.length() > 0) - { - _locator = servantManager.findServantLocator(""); - } - if(_locator != null) - { - _cookie = new Ice.LocalObjectHolder(); // Lazy creation. - try - { - _servant = _locator.locate(_current, _cookie); - } - catch(Ice.UserException ex) - { - adapter.decDirectCount(); - throw ex; - } - catch(java.lang.RuntimeException ex) - { - adapter.decDirectCount(); - throw ex; - } - } - } - - if(_servant == null) - { - adapter.decDirectCount(); - if(servantManager != null && servantManager.hasServant(_current.id)) - { - Ice.FacetNotExistException ex = new Ice.FacetNotExistException(); - ex.id = _current.id; - ex.facet = _current.facet; - ex.operation = _current.operation; - throw ex; - } - else - { - Ice.ObjectNotExistException ex = new Ice.ObjectNotExistException(); - ex.id = _current.id; - ex.facet = _current.facet; - ex.operation = _current.operation; - throw ex; - } - } - } - - public void - destroy() throws Ice.UserException - { - Ice.ObjectAdapterI adapter = (Ice.ObjectAdapterI)_current.adapter; - assert(adapter != null); - - try - { - if(_locator != null && _servant != null) - { - _locator.finished(_current, _servant, _cookie.value); - } - } - finally - { - adapter.decDirectCount(); - } - } - - public Ice.Object - getServant() - { - return _servant; - } - - public void - throwUserException() throws Ice.UserException - { - assert _userException != null; - throw _userException; - } - - public void - setUserException(Ice.UserException ex) - { - _userException = ex; - } - - private final Ice.Current _current; - private Ice.Object _servant; - private Ice.UserException _userException; - private Ice.ServantLocator _locator; - private Ice.LocalObjectHolder _cookie; -} diff --git a/java/src/IceInternal/DispatchObserverI.java b/java/src/IceInternal/DispatchObserverI.java index 21442a85414..97b739cb5f2 100644 --- a/java/src/IceInternal/DispatchObserverI.java +++ b/java/src/IceInternal/DispatchObserverI.java @@ -41,11 +41,11 @@ public class DispatchObserverI } final MetricsUpdate<IceMX.DispatchMetrics> _userException = new MetricsUpdate<IceMX.DispatchMetrics>() + { + public void + update(IceMX.DispatchMetrics v) { - public void - update(IceMX.DispatchMetrics v) - { - ++v.userException; - } - }; -}
\ No newline at end of file + ++v.userException; + } + }; +} diff --git a/java/src/IceInternal/DispatchWorkItem.java b/java/src/IceInternal/DispatchWorkItem.java index dd770c720a8..84a9c438453 100644 --- a/java/src/IceInternal/DispatchWorkItem.java +++ b/java/src/IceInternal/DispatchWorkItem.java @@ -17,14 +17,10 @@ package IceInternal; // abstract public class DispatchWorkItem implements ThreadPoolWorkItem, Runnable { - public DispatchWorkItem(Instance instance) - { - _instance = instance; - } - final public void execute(ThreadPoolCurrent current) { - Ice.Dispatcher dispatcher = _instance.initializationData().dispatcher; + Instance instance = current.stream.instance(); + Ice.Dispatcher dispatcher = instance.initializationData().dispatcher; if(dispatcher != null) { try @@ -33,13 +29,13 @@ abstract public class DispatchWorkItem implements ThreadPoolWorkItem, Runnable } catch(java.lang.Exception ex) { - if(_instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 1) + if(instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 1) { java.io.StringWriter sw = new java.io.StringWriter(); java.io.PrintWriter pw = new java.io.PrintWriter(sw); ex.printStackTrace(pw); pw.flush(); - _instance.initializationData().logger.warning("dispatch exception:\n" + sw.toString()); + instance.initializationData().logger.warning("dispatch exception:\n" + sw.toString()); } } } @@ -49,6 +45,4 @@ abstract public class DispatchWorkItem implements ThreadPoolWorkItem, Runnable this.run(); } } - - private Instance _instance; } diff --git a/java/src/IceInternal/Functional_CallbackBase.java b/java/src/IceInternal/Functional_CallbackBase.java index e66a5938bb0..1e61ca2e506 100644 --- a/java/src/IceInternal/Functional_CallbackBase.java +++ b/java/src/IceInternal/Functional_CallbackBase.java @@ -12,18 +12,18 @@ package IceInternal; public abstract class Functional_CallbackBase extends IceInternal.CallbackBase { public Functional_CallbackBase(boolean responseCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - CallbackBase.check(responseCb || localExceptionCb != null); - __localExceptionCb = localExceptionCb; + CallbackBase.check(responseCb || exceptionCb != null); + __exceptionCb = exceptionCb; __sentCb = sentCb; } - protected Functional_CallbackBase(Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + protected Functional_CallbackBase(Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - __localExceptionCb = localExceptionCb; + __exceptionCb = exceptionCb; __sentCb = sentCb; } @@ -37,6 +37,6 @@ public abstract class Functional_CallbackBase extends IceInternal.CallbackBase public abstract void __completed(Ice.AsyncResult __result); - protected final Functional_GenericCallback1<Ice.LocalException> __localExceptionCb; + protected final Functional_GenericCallback1<Ice.Exception> __exceptionCb; protected final Functional_BoolCallback __sentCb; } diff --git a/java/src/IceInternal/Functional_OnewayCallback.java b/java/src/IceInternal/Functional_OnewayCallback.java index a9d7aa842f7..4b7da7baa07 100644 --- a/java/src/IceInternal/Functional_OnewayCallback.java +++ b/java/src/IceInternal/Functional_OnewayCallback.java @@ -12,11 +12,11 @@ package IceInternal; public class Functional_OnewayCallback extends IceInternal.Functional_CallbackBase { public Functional_OnewayCallback(Functional_VoidCallback responseCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(localExceptionCb, sentCb); - CallbackBase.check(responseCb != null || localExceptionCb != null); + super(exceptionCb, sentCb); + CallbackBase.check(responseCb != null || exceptionCb != null); __responseCb = responseCb; } @@ -30,11 +30,11 @@ public class Functional_OnewayCallback extends IceInternal.Functional_CallbackBa __responseCb.apply(); } } - catch(Ice.LocalException __ex) + catch(Ice.Exception __ex) { - if(__localExceptionCb != null) + if(__exceptionCb != null) { - __localExceptionCb.apply(__ex); + __exceptionCb.apply(__ex); } } } diff --git a/java/src/IceInternal/Functional_TwowayCallback.java b/java/src/IceInternal/Functional_TwowayCallback.java index a03f73378c2..91d02d81a37 100644 --- a/java/src/IceInternal/Functional_TwowayCallback.java +++ b/java/src/IceInternal/Functional_TwowayCallback.java @@ -12,23 +12,31 @@ package IceInternal; public abstract class Functional_TwowayCallback extends IceInternal.Functional_CallbackBase implements Ice.TwowayCallback { public Functional_TwowayCallback(boolean responseCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(responseCb, localExceptionCb, sentCb); + super(responseCb, exceptionCb, sentCb); } - protected Functional_TwowayCallback(Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + protected Functional_TwowayCallback(Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(localExceptionCb, sentCb); + super(exceptionCb, sentCb); } + public void exception(Ice.SystemException ex) + { + if(__exceptionCb != null) + { + __exceptionCb.apply(ex); + } + } + public final void exception(Ice.LocalException ex) { - if(__localExceptionCb != null) + if(__exceptionCb != null) { - __localExceptionCb.apply(ex); + __exceptionCb.apply(ex); } } } diff --git a/java/src/IceInternal/Functional_TwowayCallbackArg1.java b/java/src/IceInternal/Functional_TwowayCallbackArg1.java index e944e138fb2..5afa99612c4 100644 --- a/java/src/IceInternal/Functional_TwowayCallbackArg1.java +++ b/java/src/IceInternal/Functional_TwowayCallbackArg1.java @@ -13,20 +13,20 @@ public abstract class Functional_TwowayCallbackArg1<T> extends Functional_Twoway implements Ice.TwowayCallbackArg1<T> { public Functional_TwowayCallbackArg1(Functional_GenericCallback1<T> responseCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(responseCb != null, localExceptionCb, sentCb); + super(responseCb != null, exceptionCb, sentCb); __responseCb = responseCb; } protected Functional_TwowayCallbackArg1(boolean userExceptionCb, Functional_GenericCallback1<T> responseCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(localExceptionCb, sentCb); - CallbackBase.check(responseCb != null || (userExceptionCb && localExceptionCb != null)); + super(exceptionCb, sentCb); + CallbackBase.check(responseCb != null || (userExceptionCb && exceptionCb != null)); __responseCb = responseCb; } diff --git a/java/src/IceInternal/Functional_TwowayCallbackArg1UE.java b/java/src/IceInternal/Functional_TwowayCallbackArg1UE.java index f217661ee58..93e81bdf82f 100644 --- a/java/src/IceInternal/Functional_TwowayCallbackArg1UE.java +++ b/java/src/IceInternal/Functional_TwowayCallbackArg1UE.java @@ -15,10 +15,10 @@ public abstract class Functional_TwowayCallbackArg1UE<T> public Functional_TwowayCallbackArg1UE( Functional_GenericCallback1<T> responseCb, Functional_GenericCallback1<Ice.UserException> userExceptionCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(userExceptionCb != null, responseCb, localExceptionCb, sentCb); + super(userExceptionCb != null, responseCb, exceptionCb, sentCb); __userExceptionCb = userExceptionCb; } diff --git a/java/src/IceInternal/Functional_TwowayCallbackBool.java b/java/src/IceInternal/Functional_TwowayCallbackBool.java index 6014deb7132..b755ee062ce 100644 --- a/java/src/IceInternal/Functional_TwowayCallbackBool.java +++ b/java/src/IceInternal/Functional_TwowayCallbackBool.java @@ -12,20 +12,20 @@ package IceInternal; public abstract class Functional_TwowayCallbackBool extends Functional_TwowayCallback implements Ice.TwowayCallbackBool { public Functional_TwowayCallbackBool(Functional_BoolCallback responseCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(responseCb != null, localExceptionCb, sentCb); + super(responseCb != null, exceptionCb, sentCb); this.__responseCb = responseCb; } protected Functional_TwowayCallbackBool(boolean userExceptionCb, Functional_BoolCallback responseCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(localExceptionCb, sentCb); - CallbackBase.check(responseCb != null || (userExceptionCb && localExceptionCb != null)); + super(exceptionCb, sentCb); + CallbackBase.check(responseCb != null || (userExceptionCb && exceptionCb != null)); this.__responseCb = responseCb; } diff --git a/java/src/IceInternal/Functional_TwowayCallbackBoolUE.java b/java/src/IceInternal/Functional_TwowayCallbackBoolUE.java index 7644dceb259..513b6f211f8 100644 --- a/java/src/IceInternal/Functional_TwowayCallbackBoolUE.java +++ b/java/src/IceInternal/Functional_TwowayCallbackBoolUE.java @@ -15,10 +15,10 @@ public abstract class Functional_TwowayCallbackBoolUE public Functional_TwowayCallbackBoolUE( Functional_BoolCallback responseCb, Functional_GenericCallback1<Ice.UserException> userExceptionCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(userExceptionCb != null, responseCb, localExceptionCb, sentCb); + super(userExceptionCb != null, responseCb, exceptionCb, sentCb); __userExceptionCb = userExceptionCb; } diff --git a/java/src/IceInternal/Functional_TwowayCallbackByte.java b/java/src/IceInternal/Functional_TwowayCallbackByte.java index bbbda5685bd..cd7e9b0d3d1 100644 --- a/java/src/IceInternal/Functional_TwowayCallbackByte.java +++ b/java/src/IceInternal/Functional_TwowayCallbackByte.java @@ -12,20 +12,20 @@ package IceInternal; public abstract class Functional_TwowayCallbackByte extends Functional_TwowayCallback implements Ice.TwowayCallbackByte { public Functional_TwowayCallbackByte(Functional_ByteCallback responseCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(responseCb != null, localExceptionCb, sentCb); + super(responseCb != null, exceptionCb, sentCb); __responseCb = responseCb; } protected Functional_TwowayCallbackByte(boolean userExceptionCb, Functional_ByteCallback responseCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(localExceptionCb, sentCb); - CallbackBase.check(responseCb != null || (userExceptionCb && localExceptionCb != null)); + super(exceptionCb, sentCb); + CallbackBase.check(responseCb != null || (userExceptionCb && exceptionCb != null)); __responseCb = responseCb; } diff --git a/java/src/IceInternal/Functional_TwowayCallbackByteUE.java b/java/src/IceInternal/Functional_TwowayCallbackByteUE.java index 7f91af08792..18004621033 100644 --- a/java/src/IceInternal/Functional_TwowayCallbackByteUE.java +++ b/java/src/IceInternal/Functional_TwowayCallbackByteUE.java @@ -15,10 +15,10 @@ public abstract class Functional_TwowayCallbackByteUE public Functional_TwowayCallbackByteUE( Functional_ByteCallback responseCb, Functional_GenericCallback1<Ice.UserException> userExceptionCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(userExceptionCb != null, responseCb, localExceptionCb, sentCb); + super(userExceptionCb != null, responseCb, exceptionCb, sentCb); __userExceptionCb = userExceptionCb; } diff --git a/java/src/IceInternal/Functional_TwowayCallbackDouble.java b/java/src/IceInternal/Functional_TwowayCallbackDouble.java index 3e48dd6c9f3..e580abb91aa 100644 --- a/java/src/IceInternal/Functional_TwowayCallbackDouble.java +++ b/java/src/IceInternal/Functional_TwowayCallbackDouble.java @@ -13,20 +13,20 @@ public abstract class Functional_TwowayCallbackDouble extends Functional_TwowayCallback implements Ice.TwowayCallbackDouble { public Functional_TwowayCallbackDouble(Functional_DoubleCallback responseCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(responseCb != null, localExceptionCb, sentCb); + super(responseCb != null, exceptionCb, sentCb); __responseCb = responseCb; } protected Functional_TwowayCallbackDouble(boolean userExceptionCb, Functional_DoubleCallback responseCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(localExceptionCb, sentCb); - CallbackBase.check(responseCb != null || (userExceptionCb && localExceptionCb != null)); + super(exceptionCb, sentCb); + CallbackBase.check(responseCb != null || (userExceptionCb && exceptionCb != null)); __responseCb = responseCb; } diff --git a/java/src/IceInternal/Functional_TwowayCallbackDoubleUE.java b/java/src/IceInternal/Functional_TwowayCallbackDoubleUE.java index 0a7b4959d29..c7643b0960d 100644 --- a/java/src/IceInternal/Functional_TwowayCallbackDoubleUE.java +++ b/java/src/IceInternal/Functional_TwowayCallbackDoubleUE.java @@ -15,10 +15,10 @@ public abstract class Functional_TwowayCallbackDoubleUE public Functional_TwowayCallbackDoubleUE( Functional_DoubleCallback responseCb, Functional_GenericCallback1<Ice.UserException> userExceptionCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(userExceptionCb != null, responseCb, localExceptionCb, sentCb); + super(userExceptionCb != null, responseCb, exceptionCb, sentCb); __userExceptionCb = userExceptionCb; } diff --git a/java/src/IceInternal/Functional_TwowayCallbackFloat.java b/java/src/IceInternal/Functional_TwowayCallbackFloat.java index cd9ba700acb..a5cc8018e23 100644 --- a/java/src/IceInternal/Functional_TwowayCallbackFloat.java +++ b/java/src/IceInternal/Functional_TwowayCallbackFloat.java @@ -13,20 +13,20 @@ public abstract class Functional_TwowayCallbackFloat extends Functional_TwowayCallback implements Ice.TwowayCallbackFloat { public Functional_TwowayCallbackFloat(Functional_FloatCallback responseCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(responseCb != null, localExceptionCb, sentCb); + super(responseCb != null, exceptionCb, sentCb); __responseCb = responseCb; } protected Functional_TwowayCallbackFloat(boolean userExceptionCb, Functional_FloatCallback responseCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(localExceptionCb, sentCb); - CallbackBase.check(responseCb != null || (userExceptionCb && localExceptionCb != null)); + super(exceptionCb, sentCb); + CallbackBase.check(responseCb != null || (userExceptionCb && exceptionCb != null)); __responseCb = responseCb; } diff --git a/java/src/IceInternal/Functional_TwowayCallbackFloatUE.java b/java/src/IceInternal/Functional_TwowayCallbackFloatUE.java index 1bc9213a1e0..4df55515af8 100644 --- a/java/src/IceInternal/Functional_TwowayCallbackFloatUE.java +++ b/java/src/IceInternal/Functional_TwowayCallbackFloatUE.java @@ -14,10 +14,10 @@ public abstract class Functional_TwowayCallbackFloatUE { public Functional_TwowayCallbackFloatUE(Functional_FloatCallback responseCb, Functional_GenericCallback1<Ice.UserException> userExceptionCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(userExceptionCb != null, responseCb, localExceptionCb, sentCb); + super(userExceptionCb != null, responseCb, exceptionCb, sentCb); __userExceptionCb = userExceptionCb; } diff --git a/java/src/IceInternal/Functional_TwowayCallbackInt.java b/java/src/IceInternal/Functional_TwowayCallbackInt.java index a37c4b0d167..6724c7fc7c1 100644 --- a/java/src/IceInternal/Functional_TwowayCallbackInt.java +++ b/java/src/IceInternal/Functional_TwowayCallbackInt.java @@ -13,20 +13,20 @@ public abstract class Functional_TwowayCallbackInt extends Functional_TwowayCallback implements Ice.TwowayCallbackInt { public Functional_TwowayCallbackInt(Functional_IntCallback responseCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(responseCb != null, localExceptionCb, sentCb); + super(responseCb != null, exceptionCb, sentCb); __responseCb = responseCb; } protected Functional_TwowayCallbackInt(boolean userExceptionCb, Functional_IntCallback responseCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(localExceptionCb, sentCb); - CallbackBase.check(responseCb != null || (userExceptionCb && localExceptionCb != null)); + super(exceptionCb, sentCb); + CallbackBase.check(responseCb != null || (userExceptionCb && exceptionCb != null)); __responseCb = responseCb; } diff --git a/java/src/IceInternal/Functional_TwowayCallbackIntUE.java b/java/src/IceInternal/Functional_TwowayCallbackIntUE.java index 65f111e49bd..30693f7361d 100644 --- a/java/src/IceInternal/Functional_TwowayCallbackIntUE.java +++ b/java/src/IceInternal/Functional_TwowayCallbackIntUE.java @@ -15,10 +15,10 @@ public abstract class Functional_TwowayCallbackIntUE public Functional_TwowayCallbackIntUE( Functional_IntCallback responseCb, Functional_GenericCallback1<Ice.UserException> userExceptionCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(userExceptionCb != null, responseCb, localExceptionCb, sentCb); + super(userExceptionCb != null, responseCb, exceptionCb, sentCb); __userExceptionCb = userExceptionCb; } diff --git a/java/src/IceInternal/Functional_TwowayCallbackLong.java b/java/src/IceInternal/Functional_TwowayCallbackLong.java index 2a0233ed32d..c82268691a4 100644 --- a/java/src/IceInternal/Functional_TwowayCallbackLong.java +++ b/java/src/IceInternal/Functional_TwowayCallbackLong.java @@ -13,20 +13,20 @@ public abstract class Functional_TwowayCallbackLong extends Functional_TwowayCallback implements Ice.TwowayCallbackLong { public Functional_TwowayCallbackLong(Functional_LongCallback responseCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(responseCb != null, localExceptionCb, sentCb); + super(responseCb != null, exceptionCb, sentCb); __responseCb = responseCb; } protected Functional_TwowayCallbackLong(boolean userExceptionCb, Functional_LongCallback responseCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(localExceptionCb, sentCb); - CallbackBase.check(responseCb != null || (userExceptionCb && localExceptionCb != null)); + super(exceptionCb, sentCb); + CallbackBase.check(responseCb != null || (userExceptionCb && exceptionCb != null)); __responseCb = responseCb; } diff --git a/java/src/IceInternal/Functional_TwowayCallbackLongUE.java b/java/src/IceInternal/Functional_TwowayCallbackLongUE.java index 63417055f41..d8d7cd09933 100644 --- a/java/src/IceInternal/Functional_TwowayCallbackLongUE.java +++ b/java/src/IceInternal/Functional_TwowayCallbackLongUE.java @@ -15,10 +15,10 @@ public abstract class Functional_TwowayCallbackLongUE public Functional_TwowayCallbackLongUE( Functional_LongCallback responseCb, Functional_GenericCallback1<Ice.UserException> userExceptionCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(responseCb, localExceptionCb, sentCb); + super(responseCb, exceptionCb, sentCb); __userExceptionCb = userExceptionCb; } diff --git a/java/src/IceInternal/Functional_TwowayCallbackShort.java b/java/src/IceInternal/Functional_TwowayCallbackShort.java index c73f4c78593..7a72c8a1470 100644 --- a/java/src/IceInternal/Functional_TwowayCallbackShort.java +++ b/java/src/IceInternal/Functional_TwowayCallbackShort.java @@ -13,20 +13,20 @@ public abstract class Functional_TwowayCallbackShort extends Functional_TwowayCallback implements Ice.TwowayCallbackShort { public Functional_TwowayCallbackShort(Functional_ShortCallback responseCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(responseCb != null, localExceptionCb, sentCb); + super(responseCb != null, exceptionCb, sentCb); __responseCb = responseCb; } protected Functional_TwowayCallbackShort(boolean userExceptionCb, Functional_ShortCallback responseCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(localExceptionCb, sentCb); - CallbackBase.check(responseCb != null || (userExceptionCb && localExceptionCb != null)); + super(exceptionCb, sentCb); + CallbackBase.check(responseCb != null || (userExceptionCb && exceptionCb != null)); __responseCb = responseCb; } diff --git a/java/src/IceInternal/Functional_TwowayCallbackShortUE.java b/java/src/IceInternal/Functional_TwowayCallbackShortUE.java index 8943a0a5803..f8bda4114c7 100644 --- a/java/src/IceInternal/Functional_TwowayCallbackShortUE.java +++ b/java/src/IceInternal/Functional_TwowayCallbackShortUE.java @@ -15,10 +15,10 @@ public abstract class Functional_TwowayCallbackShortUE public Functional_TwowayCallbackShortUE( Functional_ShortCallback responseCb, Functional_GenericCallback1<Ice.UserException> userExceptionCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(responseCb, localExceptionCb, sentCb); + super(responseCb, exceptionCb, sentCb); __userExceptionCb = userExceptionCb; } diff --git a/java/src/IceInternal/Functional_TwowayCallbackUE.java b/java/src/IceInternal/Functional_TwowayCallbackUE.java index e3271ed8f2c..e0469547199 100644 --- a/java/src/IceInternal/Functional_TwowayCallbackUE.java +++ b/java/src/IceInternal/Functional_TwowayCallbackUE.java @@ -13,11 +13,11 @@ public abstract class Functional_TwowayCallbackUE extends Functional_TwowayCallb { public Functional_TwowayCallbackUE(boolean responseCb, Functional_GenericCallback1<Ice.UserException> userExceptionCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(localExceptionCb, sentCb); - CallbackBase.check(responseCb || (userExceptionCb != null && localExceptionCb != null)); + super(exceptionCb, sentCb); + CallbackBase.check(responseCb || (userExceptionCb != null && exceptionCb != null)); __userExceptionCb = userExceptionCb; } diff --git a/java/src/IceInternal/Functional_TwowayCallbackVoidUE.java b/java/src/IceInternal/Functional_TwowayCallbackVoidUE.java index 3591d694ccd..53854b6eadf 100644 --- a/java/src/IceInternal/Functional_TwowayCallbackVoidUE.java +++ b/java/src/IceInternal/Functional_TwowayCallbackVoidUE.java @@ -15,10 +15,10 @@ public abstract class Functional_TwowayCallbackVoidUE public Functional_TwowayCallbackVoidUE( Functional_VoidCallback responseCb, Functional_GenericCallback1<Ice.UserException> userExceptionCb, - Functional_GenericCallback1<Ice.LocalException> localExceptionCb, + Functional_GenericCallback1<Ice.Exception> exceptionCb, Functional_BoolCallback sentCb) { - super(responseCb != null, userExceptionCb, localExceptionCb, sentCb); + super(responseCb != null, userExceptionCb, exceptionCb, sentCb); __responseCb = responseCb; } diff --git a/java/src/IceInternal/IPEndpointI.java b/java/src/IceInternal/IPEndpointI.java index e887fb95770..3375b51d36c 100644 --- a/java/src/IceInternal/IPEndpointI.java +++ b/java/src/IceInternal/IPEndpointI.java @@ -267,6 +267,11 @@ public abstract class IPEndpointI extends EndpointI throw new Ice.EndpointParseException("`-h *' not valid for proxy endpoint `" + toString() + "'"); } } + + if(_host == null) + { + _host = ""; + } } protected boolean checkOption(String option, String argument, String endpoint) diff --git a/java/src/IceInternal/Incoming.java b/java/src/IceInternal/Incoming.java index 88a12ddf906..f8c3e0e9d64 100644 --- a/java/src/IceInternal/Incoming.java +++ b/java/src/IceInternal/Incoming.java @@ -14,10 +14,10 @@ import Ice.Instrumentation.CommunicatorObserver; final public class Incoming extends IncomingBase implements Ice.Request { public - Incoming(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, boolean response, byte compress, - int requestId) + Incoming(Instance instance, ResponseHandler responseHandler, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, + boolean response, byte compress, int requestId) { - super(instance, connection, adapter, response, compress, requestId); + super(instance, responseHandler, connection, adapter, response, compress, requestId); // // Prepare the response if necessary. @@ -33,15 +33,6 @@ final public class Incoming extends IncomingBase implements Ice.Request } } - // - // Request implementation - // - public boolean - isCollocated() - { - return false; - } - public Ice.Current getCurrent() { @@ -52,13 +43,13 @@ final public class Incoming extends IncomingBase implements Ice.Request // These functions allow this object to be reused, rather than reallocated. // public void - reset(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, boolean response, byte compress, - int requestId) + reset(Instance instance, ResponseHandler handler, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, + boolean response, byte compress, int requestId) { _cb = null; _inParamPos = -1; - super.reset(instance, connection, adapter, response, compress, requestId); + super.reset(instance, handler, connection, adapter, response, compress, requestId); // // Prepare the response if necessary. @@ -179,11 +170,11 @@ final public class Incoming extends IncomingBase implements Ice.Request { _observer.reply(_os.size() - Protocol.headerSize - 4); } - _connection.sendResponse(_os, _compress); + _responseHandler.sendResponse(_current.requestId, _os, _compress); } else { - _connection.sendNoResponse(); + _responseHandler.sendNoResponse(); } if(_observer != null) @@ -191,7 +182,7 @@ final public class Incoming extends IncomingBase implements Ice.Request _observer.detach(); _observer = null; } - _connection = null; + _responseHandler = null; return; } catch(java.lang.Exception ex) @@ -274,7 +265,7 @@ final public class Incoming extends IncomingBase implements Ice.Request // the caller of this operation. // - assert(_connection != null); + assert(_responseHandler != null); if(_response) { @@ -282,11 +273,11 @@ final public class Incoming extends IncomingBase implements Ice.Request { _observer.reply(_os.size() - Protocol.headerSize - 4); } - _connection.sendResponse(_os, _compress); + _responseHandler.sendResponse(_current.requestId, _os, _compress); } else { - _connection.sendNoResponse(); + _responseHandler.sendNoResponse(); } if(_observer != null) @@ -294,7 +285,7 @@ final public class Incoming extends IncomingBase implements Ice.Request _observer.detach(); _observer = null; } - _connection = null; + _responseHandler = null; } public final void diff --git a/java/src/IceInternal/IncomingAsync.java b/java/src/IceInternal/IncomingAsync.java index cbcc6693e22..2ab2d0fc335 100644 --- a/java/src/IceInternal/IncomingAsync.java +++ b/java/src/IceInternal/IncomingAsync.java @@ -63,7 +63,7 @@ public class IncomingAsync extends IncomingBase implements Ice.AMDCallback } } - if(_connection != null) + if(_responseHandler != null) { __exception(ex); } @@ -110,7 +110,7 @@ public class IncomingAsync extends IncomingBase implements Ice.AMDCallback return; } - assert(_connection != null); + assert(_responseHandler != null); if(_response) { @@ -118,11 +118,11 @@ public class IncomingAsync extends IncomingBase implements Ice.AMDCallback { _observer.reply(_os.size() - Protocol.headerSize - 4); } - _connection.sendResponse(_os, _compress); + _responseHandler.sendResponse(_current.requestId, _os, _compress); } else { - _connection.sendNoResponse(); + _responseHandler.sendNoResponse(); } if(_observer != null) @@ -130,11 +130,11 @@ public class IncomingAsync extends IncomingBase implements Ice.AMDCallback _observer.detach(); _observer = null; } - _connection = null; + _responseHandler = null; } catch(Ice.LocalException ex) { - _connection.invokeException(ex, 1); + _responseHandler.invokeException(_current.requestId, ex, 1); } } @@ -152,7 +152,7 @@ public class IncomingAsync extends IncomingBase implements Ice.AMDCallback } catch(Ice.LocalException ex) { - _connection.invokeException(ex, 1); + _responseHandler.invokeException(_current.requestId, ex, 1); } } diff --git a/java/src/IceInternal/IncomingBase.java b/java/src/IceInternal/IncomingBase.java index 79cff091a58..5190769b6ae 100644 --- a/java/src/IceInternal/IncomingBase.java +++ b/java/src/IceInternal/IncomingBase.java @@ -12,22 +12,22 @@ package IceInternal; public class IncomingBase { protected - IncomingBase(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, boolean response, - byte compress, int requestId) + IncomingBase(Instance instance, ResponseHandler handler, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, + boolean response, byte compress, int requestId) { _instance = instance; + _responseHandler = handler; _response = response; _compress = compress; if(_response) { _os = new BasicStream(instance, Protocol.currentProtocolEncoding); } - _connection = connection; _current = new Ice.Current(); _current.id = new Ice.Identity(); _current.adapter = adapter; - _current.con = _connection; + _current.con = connection; _current.requestId = requestId; _cookie = new Ice.LocalObjectHolder(); @@ -86,8 +86,8 @@ public class IncomingBase _os = other._os; other._os = null; - _connection = other._connection; - other._connection = null; + _responseHandler = other._responseHandler; + other._responseHandler = null; } public BasicStream @@ -177,8 +177,8 @@ public class IncomingBase // These functions allow this object to be reused, rather than reallocated. // public void - reset(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, boolean response, byte compress, - int requestId) + reset(Instance instance, ResponseHandler handler, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, + boolean response, byte compress, int requestId) { _instance = instance; @@ -205,7 +205,7 @@ public class IncomingBase _os = new BasicStream(instance, Protocol.currentProtocolEncoding); } - _connection = connection; + _responseHandler = handler; _interceptorAsyncCallbackList = null; } @@ -245,9 +245,9 @@ public class IncomingBase out.print("\nidentity: " + _instance.identityToString(_current.id)); out.print("\nfacet: " + IceUtilInternal.StringUtil.escapeString(_current.facet, "")); out.print("\noperation: " + _current.operation); - if(_connection != null) + if(_current.con != null) { - Ice.ConnectionInfo connInfo = _connection.getInfo(); + Ice.ConnectionInfo connInfo = _current.con.getInfo(); if(connInfo instanceof Ice.IPConnectionInfo) { Ice.IPConnectionInfo ipConnInfo = (Ice.IPConnectionInfo)connInfo; @@ -272,7 +272,7 @@ public class IncomingBase } catch(Ice.UserException ex) { - assert(_connection != null); + assert(_responseHandler != null); if(_observer != null) { @@ -293,11 +293,11 @@ public class IncomingBase { _observer.reply(_os.size() - Protocol.headerSize - 4); } - _connection.sendResponse(_os, _compress); + _responseHandler.sendResponse(_current.requestId, _os, _compress); } else { - _connection.sendNoResponse(); + _responseHandler.sendNoResponse(); } if(_observer != null) @@ -305,7 +305,7 @@ public class IncomingBase _observer.detach(); _observer = null; } - _connection = null; + _responseHandler = null; } catch(java.lang.Exception ex) { @@ -317,7 +317,7 @@ public class IncomingBase final protected void __handleException(java.lang.Exception exc) { - assert(_connection != null); + assert(_responseHandler != null); try { @@ -390,11 +390,11 @@ public class IncomingBase { _observer.reply(_os.size() - Protocol.headerSize - 4); } - _connection.sendResponse(_os, _compress); + _responseHandler.sendResponse(_current.requestId, _os, _compress); } else { - _connection.sendNoResponse(); + _responseHandler.sendNoResponse(); } } catch(Ice.UnknownLocalException ex) @@ -418,11 +418,11 @@ public class IncomingBase { _observer.reply(_os.size() - Protocol.headerSize - 4); } - _connection.sendResponse(_os, _compress); + _responseHandler.sendResponse(_current.requestId, _os, _compress); } else { - _connection.sendNoResponse(); + _responseHandler.sendNoResponse(); } } catch(Ice.UnknownUserException ex) @@ -446,11 +446,11 @@ public class IncomingBase { _observer.reply(_os.size() - Protocol.headerSize - 4); } - _connection.sendResponse(_os, _compress); + _responseHandler.sendResponse(_current.requestId, _os, _compress); } else { - _connection.sendNoResponse(); + _responseHandler.sendNoResponse(); } } catch(Ice.UnknownException ex) @@ -474,15 +474,28 @@ public class IncomingBase { _observer.reply(_os.size() - Protocol.headerSize - 4); } - _connection.sendResponse(_os, _compress); + _responseHandler.sendResponse(_current.requestId, _os, _compress); } else { - _connection.sendNoResponse(); + _responseHandler.sendNoResponse(); } } - catch(Ice.LocalException ex) + catch(Ice.Exception ex) { + if(ex instanceof Ice.SystemException) + { + // + // Only rethrow the system exception if it's a collocated + // call. For now, on-the-wire system exceptions aren't + // supported. + // + if(_current.con == null) + { + throw ex; + } + } + if(_instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) { __warning(ex); @@ -508,11 +521,11 @@ public class IncomingBase { _observer.reply(_os.size() - Protocol.headerSize - 4); } - _connection.sendResponse(_os, _compress); + _responseHandler.sendResponse(_current.requestId, _os, _compress); } else { - _connection.sendNoResponse(); + _responseHandler.sendNoResponse(); } } catch(Ice.UserException ex) @@ -542,11 +555,11 @@ public class IncomingBase { _observer.reply(_os.size() - Protocol.headerSize - 4); } - _connection.sendResponse(_os, _compress); + _responseHandler.sendResponse(_current.requestId, _os, _compress); } else { - _connection.sendNoResponse(); + _responseHandler.sendNoResponse(); } } catch(java.lang.Exception ex) @@ -575,11 +588,11 @@ public class IncomingBase { _observer.reply(_os.size() - Protocol.headerSize - 4); } - _connection.sendResponse(_os, _compress); + _responseHandler.sendResponse(_current.requestId, _os, _compress); } else { - _connection.sendNoResponse(); + _responseHandler.sendNoResponse(); } } @@ -588,7 +601,7 @@ public class IncomingBase _observer.detach(); _observer = null; } - _connection = null; + _responseHandler = null; } protected Instance _instance; @@ -603,7 +616,7 @@ public class IncomingBase protected BasicStream _os; - protected Ice.ConnectionI _connection; + protected ResponseHandler _responseHandler; protected java.util.LinkedList<Ice.DispatchInterceptorAsyncCallback> _interceptorAsyncCallbackList; } diff --git a/java/src/IceInternal/InvocationObserverI.java b/java/src/IceInternal/InvocationObserverI.java index e47f6670df3..7997a22d9d0 100644 --- a/java/src/IceInternal/InvocationObserverI.java +++ b/java/src/IceInternal/InvocationObserverI.java @@ -18,24 +18,24 @@ public class InvocationObserverI static public final class RemoteInvocationHelper extends MetricsHelper<RemoteMetrics> { static private final AttributeResolver _attributes = new AttributeResolver() - { + { + { + try { - try - { - Class<?> cl = RemoteInvocationHelper.class; - add("parent", cl.getDeclaredMethod("getParent")); - add("id", cl.getDeclaredMethod("getId")); - add("requestId", cl.getDeclaredMethod("getRequestId")); - CommunicatorObserverI.addConnectionAttributes(this, RemoteInvocationHelper.class); - } - catch(Exception ex) - { - ex.printStackTrace(); - assert(false); - } + Class<?> cl = RemoteInvocationHelper.class; + add("parent", cl.getDeclaredMethod("getParent")); + add("id", cl.getDeclaredMethod("getId")); + add("requestId", cl.getDeclaredMethod("getRequestId")); + CommunicatorObserverI.addConnectionAttributes(this, RemoteInvocationHelper.class); } - }; - + catch(Exception ex) + { + ex.printStackTrace(); + assert(false); + } + } + }; + RemoteInvocationHelper(Ice.ConnectionInfo con, Ice.Endpoint endpt, int requestId, int size) { super(_attributes); @@ -114,6 +114,66 @@ public class InvocationObserverI private Ice.EndpointInfo _endpointInfo; }; + static public final class CollocatedInvocationHelper extends MetricsHelper<RemoteMetrics> + { + static private final AttributeResolver _attributes = new AttributeResolver() + { + { + try + { + Class<?> cl = CollocatedInvocationHelper.class; + add("parent", cl.getDeclaredMethod("getParent")); + add("id", cl.getDeclaredMethod("getId")); + add("requestId", cl.getDeclaredMethod("getRequestId")); + } + catch(Exception ex) + { + ex.printStackTrace(); + assert(false); + } + } + }; + + CollocatedInvocationHelper(int requestId, int size) + { + super(_attributes); + _requestId = requestId; + _size = size; + } + + public void + initMetrics(RemoteMetrics v) + { + v.size += _size; + } + + public String + getId() + { + if(_id == null) + { + _id = Integer.toString(_requestId); + } + return _id; + } + + int + getRequestId() + { + return _requestId; + } + + public String + getParent() + { + return "Communicator"; + } + + final private int _requestId; + final private int _size; + private String _id; + }; + public void userException() { @@ -149,21 +209,36 @@ public class InvocationObserverI delegate); } + public Ice.Instrumentation.RemoteObserver + getCollocatedObserver(int requestId, int sz) + { + Ice.Instrumentation.RemoteObserver delegate = null; + if(_delegate != null) + { + delegate = _delegate.getCollocatedObserver(requestId, sz); + } + return (Ice.Instrumentation.RemoteObserver)getObserver("Collocated", + new CollocatedInvocationHelper(requestId, sz), + RemoteMetrics.class, + RemoteObserverI.class, + delegate); + } + final MetricsUpdate<InvocationMetrics> _incrementRetry = new MetricsUpdate<InvocationMetrics>() + { + public void + update(InvocationMetrics v) { - public void - update(InvocationMetrics v) - { - ++v.retry; - } - }; + ++v.retry; + } + }; final MetricsUpdate<InvocationMetrics> _userException = new MetricsUpdate<InvocationMetrics>() + { + public void + update(InvocationMetrics v) { - public void - update(InvocationMetrics v) - { - ++v.userException; - } - }; -}
\ No newline at end of file + ++v.userException; + } + }; +} diff --git a/java/src/IceInternal/LocalExceptionWrapper.java b/java/src/IceInternal/LocalExceptionWrapper.java deleted file mode 100644 index 868781ee8a3..00000000000 --- a/java/src/IceInternal/LocalExceptionWrapper.java +++ /dev/null @@ -1,71 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -package IceInternal; - -public class LocalExceptionWrapper extends Exception -{ - public - LocalExceptionWrapper(Ice.LocalException ex, boolean retry) - { - _ex = ex; - _retry = retry; - } - - public - LocalExceptionWrapper(IceInternal.LocalExceptionWrapper ex) - { - _ex = ex.get(); - _retry = ex._retry; - } - - public Ice.LocalException - get() - { - return _ex; - } - - // - // If true, always repeat the request. Don't take retry settings - // or "at-most-once" guarantees into account. - // - // If false, only repeat the request if the retry settings allow - // to do so, and if "at-most-once" does not need to be guaranteed. - // - public boolean - retry() - { - return _retry; - } - - public static void - throwWrapper(java.lang.Throwable ex) throws LocalExceptionWrapper - { - if(ex instanceof Ice.UserException) - { - throw new LocalExceptionWrapper(new Ice.UnknownUserException(((Ice.UserException)ex).ice_name()), false); - } - if(ex instanceof Ice.LocalException) - { - if(ex instanceof Ice.UnknownException || - ex instanceof Ice.ObjectNotExistException || - ex instanceof Ice.OperationNotExistException || - ex instanceof Ice.FacetNotExistException) - { - throw new LocalExceptionWrapper((Ice.LocalException)ex, false); - } - throw new LocalExceptionWrapper(new Ice.UnknownLocalException(((Ice.LocalException)ex).ice_name(), ex), - false); - } - throw new LocalExceptionWrapper(new Ice.UnknownException(Ex.toString(ex), ex), false); - } - - private Ice.LocalException _ex; - private boolean _retry; -} diff --git a/java/src/IceInternal/LocatorInfo.java b/java/src/IceInternal/LocatorInfo.java index 39091b78fad..21aee75be93 100644 --- a/java/src/IceInternal/LocatorInfo.java +++ b/java/src/IceInternal/LocatorInfo.java @@ -314,7 +314,7 @@ public final class LocatorInfo LocatorInfo(Ice.LocatorPrx locator, LocatorTable table, boolean background) { - _locator = (Ice.LocatorPrx)locator.ice_collocationOptimized(false); + _locator = locator; _table = table; _background = background; } @@ -371,8 +371,7 @@ public final class LocatorInfo // // Do not make locator calls from within sync. // - Ice.LocatorRegistryPrx locatorRegistry = - (Ice.LocatorRegistryPrx)_locator.getRegistry().ice_collocationOptimized(false); + Ice.LocatorRegistryPrx locatorRegistry = (Ice.LocatorRegistryPrx)_locator.getRegistry(); synchronized(this) { diff --git a/java/src/IceInternal/MetricsMap.java b/java/src/IceInternal/MetricsMap.java index 620d107ffec..604ed218486 100644 --- a/java/src/IceInternal/MetricsMap.java +++ b/java/src/IceInternal/MetricsMap.java @@ -513,4 +513,4 @@ public class MetricsMap<T extends IceMX.Metrics> final private java.util.Map<String, Entry> _objects = new java.util.HashMap<String, Entry>(); final private java.util.Map<String, SubMapCloneFactory<?>> _subMaps; private java.util.Deque<Entry> _detachedQueue; -};
\ No newline at end of file +}; diff --git a/java/src/IceInternal/Outgoing.java b/java/src/IceInternal/Outgoing.java index c00a99a2b2b..ac06172ce72 100644 --- a/java/src/IceInternal/Outgoing.java +++ b/java/src/IceInternal/Outgoing.java @@ -15,44 +15,53 @@ import Ice.Instrumentation.InvocationObserver; public final class Outgoing implements OutgoingMessageCallback { public - Outgoing(RequestHandler handler, String operation, Ice.OperationMode mode, java.util.Map<String, String> context, - InvocationObserver observer) - throws LocalExceptionWrapper + Outgoing(Ice.ObjectPrxHelperBase proxy, String op, Ice.OperationMode mode, java.util.Map<String, String> context, + boolean explicitCtx) { + Reference ref = proxy.__reference(); _state = StateUnsent; - _exceptionWrapper = false; - _exceptionWrapperRetry = false; _sent = false; - _handler = handler; - _observer = observer; - _encoding = Protocol.getCompatibleEncoding(handler.getReference().getEncoding()); - _os = new BasicStream(_handler.getReference().getInstance(), Protocol.currentProtocolEncoding); + _proxy = proxy; + _mode = mode; + _handler = null; + _observer = IceInternal.ObserverHelper.get(proxy, op, context); + _encoding = Protocol.getCompatibleEncoding(ref.getEncoding()); + _os = new BasicStream(ref.getInstance(), Protocol.currentProtocolEncoding); - Protocol.checkSupportedProtocol(Protocol.getCompatibleProtocol(_handler.getReference().getProtocol())); + Protocol.checkSupportedProtocol(Protocol.getCompatibleProtocol(ref.getProtocol())); - writeHeader(operation, mode, context); + writeHeader(op, mode, context, explicitCtx); } // // These functions allow this object to be reused, rather than reallocated. // public void - reset(RequestHandler handler, String operation, Ice.OperationMode mode, java.util.Map<String, String> context, - InvocationObserver observer) - throws LocalExceptionWrapper + reset(Ice.ObjectPrxHelperBase proxy, String op, Ice.OperationMode mode, java.util.Map<String, String> context, + boolean explicitCtx) { + Reference ref = proxy.__reference(); _state = StateUnsent; _exception = null; - _exceptionWrapper = false; - _exceptionWrapperRetry = false; _sent = false; - _handler = handler; - _observer = observer; - _encoding = Protocol.getCompatibleEncoding(handler.getReference().getEncoding()); + _proxy = proxy; + _mode = mode; + _handler = null; + _observer = IceInternal.ObserverHelper.get(proxy, op, context); + _encoding = Protocol.getCompatibleEncoding(ref.getEncoding()); - Protocol.checkSupportedProtocol(Protocol.getCompatibleProtocol(_handler.getReference().getProtocol())); + Protocol.checkSupportedProtocol(Protocol.getCompatibleProtocol(ref.getProtocol())); - writeHeader(operation, mode, context); + writeHeader(op, mode, context, explicitCtx); + } + + public void + detach() + { + if(_observer != null) + { + _observer.detach(); + } } public void @@ -68,17 +77,27 @@ public final class Outgoing implements OutgoingMessageCallback // Returns true if ok, false if user exception. public boolean invoke() - throws LocalExceptionWrapper { assert(_state == StateUnsent); - switch(_handler.getReference().getMode()) + int mode = _proxy.__reference().getMode(); + if(mode == Reference.ModeBatchOneway || mode == Reference.ModeBatchDatagram) { - case Reference.ModeOneway: - case Reference.ModeDatagram: - case Reference.ModeTwoway: + _state = StateInProgress; + _handler.finishBatchRequest(_os); + return true; + } + + int cnt = 0; + while(true) + { + try { _state = StateInProgress; + _exception = null; + _sent = false; + + _handler = _proxy.__getRequestHandler(false); if(_handler.sendRequest(this)) // Request sent and no response expected, we're done. { @@ -92,7 +111,7 @@ public final class Outgoing implements OutgoingMessageCallback // If the handler says it's not finished, we wait until we're done. // - int invocationTimeout = _handler.getReference().getInvocationTimeout(); + int invocationTimeout = _proxy.__reference().getInvocationTimeout(); if(invocationTimeout > 0) { long now = Time.currentMonotonicTimeMillis(); @@ -131,71 +150,76 @@ public final class Outgoing implements OutgoingMessageCallback if(timedOut) { _handler.requestTimedOut(this); - assert(_exception != null); + + // + // Wait for the exception to propagate. It's possible the request handler ignores + // the timeout if there was a failure shortly before requestTimedOut got called. + // In this case, the exception should be set on the Outgoing. + // + synchronized(this) + { + while(_exception == null) + { + try + { + wait(); + } + catch(InterruptedException ex) + { + } + } + } } if(_exception != null) { - _exception.fillInStackTrace(); - if(_exceptionWrapper) + throw (Ice.Exception)_exception.fillInStackTrace(); + } + else + { + assert(_state != StateInProgress); + return _state == StateOK; + } + } + catch(RetryException ex) + { + _proxy.__setRequestHandler(_handler, null); // Clear request handler and retry. + } + catch(Ice.Exception ex) + { + try + { + Ice.IntHolder interval = new Ice.IntHolder(); + cnt = _proxy.__handleException(ex, _handler, _mode, _sent, interval, cnt); + if(_observer != null) { - throw new LocalExceptionWrapper(_exception, _exceptionWrapperRetry); + _observer.retried(); // Invocation is being retried. } - - // - // A CloseConnectionException indicates graceful - // server shutdown, and is therefore always repeatable - // without violating "at-most-once". That's because by - // sending a close connection message, the server - // guarantees that all outstanding requests can safely - // be repeated. - // - // An ObjectNotExistException can always be retried as - // well without violating "at-most-once" (see the - // implementation of the checkRetryAfterException - // method of the ProxyFactory class for the reasons - // why it can be useful). - // - if(!_sent || - _exception instanceof Ice.CloseConnectionException || - _exception instanceof Ice.ObjectNotExistException) + if(interval.value > 0) { - throw _exception; + try + { + Thread.sleep(interval.value); + } + catch(InterruptedException exi) + { + } } - - // - // Throw the exception wrapped in a LocalExceptionWrapper, - // to indicate that the request cannot be resent without - // potentially violating the "at-most-once" principle. - // - throw new LocalExceptionWrapper(_exception, false); } - - assert(_state != StateInProgress); - return _state == StateOK; - } - - case Reference.ModeBatchOneway: - case Reference.ModeBatchDatagram: - { - // - // For batch oneways and datagrams, the same rules as for - // regular oneways and datagrams (see comment above) - // apply. - // - _state = StateInProgress; - _handler.finishBatchRequest(_os); - return true; + catch(Ice.Exception exc) + { + if(_observer != null) + { + _observer.failed(exc.ice_name()); + } + throw exc; + } } } - - assert(false); - return false; } public void abort(Ice.LocalException ex) - throws LocalExceptionWrapper { assert(_state == StateUnsent); @@ -204,7 +228,7 @@ public final class Outgoing implements OutgoingMessageCallback // must notify the connection about that we give up ownership // of the batch stream. // - int mode = _handler.getReference().getMode(); + int mode = _proxy.__reference().getMode(); if(mode == Reference.ModeBatchOneway || mode == Reference.ModeBatchDatagram) { _handler.abortBatchRequest(); @@ -215,15 +239,21 @@ public final class Outgoing implements OutgoingMessageCallback public boolean send(Ice.ConnectionI connection, boolean compress, boolean response) - throws LocalExceptionWrapper + throws RetryException { return connection.sendRequest(this, compress, response); } + public void + invokeCollocated(CollocatedRequestHandler handler) + { + handler.invokeRequest(this); + } + synchronized public void sent() { - if(_handler.getReference().getMode() != Reference.ModeTwoway) + if(_proxy.__reference().getMode() != Reference.ModeTwoway) { if(_remoteObserver != null) { @@ -239,7 +269,7 @@ public final class Outgoing implements OutgoingMessageCallback public synchronized void finished(BasicStream is) { - assert(_handler.getReference().getMode() == Reference.ModeTwoway); // Only for twoways. + assert(_proxy.__reference().getMode() == Reference.ModeTwoway); // Only for twoways. assert(_state <= StateInProgress); @@ -252,7 +282,7 @@ public final class Outgoing implements OutgoingMessageCallback if(_is == null) { - _is = new IceInternal.BasicStream(_handler.getReference().getInstance(), Protocol.currentProtocolEncoding); + _is = new IceInternal.BasicStream(_proxy.__reference().getInstance(), Protocol.currentProtocolEncoding); } _is.swap(is); byte replyStatus = _is.readByte(); @@ -385,7 +415,7 @@ public final class Outgoing implements OutgoingMessageCallback } public synchronized void - finished(Ice.LocalException ex, boolean sent) + finished(Ice.Exception ex, boolean sent) { assert(_state <= StateInProgress); if(_remoteObserver != null) @@ -399,24 +429,6 @@ public final class Outgoing implements OutgoingMessageCallback _sent = sent; notify(); } - - public synchronized void - finished(LocalExceptionWrapper ex) - { - if(_remoteObserver != null) - { - _remoteObserver.failed(ex.get().ice_name()); - _remoteObserver.detach(); - _remoteObserver = null; - } - - _state = StateFailed; - _exceptionWrapper = true; - _exceptionWrapperRetry = ex.retry(); - _exception = ex.get(); - _sent = false; - notify(); - } public BasicStream os() @@ -516,11 +528,28 @@ public final class Outgoing implements OutgoingMessageCallback } } + public void + attachCollocatedObserver(int requestId) + { + if(_observer != null) + { + _remoteObserver = _observer.getCollocatedObserver(requestId, _os.size() - Protocol.headerSize - 4); + if(_remoteObserver != null) + { + _remoteObserver.attach(); + } + } + } + private void - writeHeader(String operation, Ice.OperationMode mode, java.util.Map<String, String> context) - throws LocalExceptionWrapper + writeHeader(String operation, Ice.OperationMode mode, java.util.Map<String, String> context, boolean explicitCtx) { - switch(_handler.getReference().getMode()) + if(explicitCtx && context == null) + { + context = _emptyContext; + } + + switch(_proxy.__reference().getMode()) { case Reference.ModeTwoway: case Reference.ModeOneway: @@ -533,19 +562,40 @@ public final class Outgoing implements OutgoingMessageCallback case Reference.ModeBatchOneway: case Reference.ModeBatchDatagram: { - _handler.prepareBatchRequest(_os); + while(true) + { + try + { + _handler = _proxy.__getRequestHandler(true); + _handler.prepareBatchRequest(_os); + break; + } + catch(RetryException ex) + { + _proxy.__setRequestHandler(_handler, null); // Clear request handler and retry. + } + catch(Ice.LocalException ex) + { + if(_observer != null) + { + _observer.failed(ex.ice_name()); + } + _proxy.__setRequestHandler(_handler, null); // Clear request handler + throw ex; + } + } break; } } try { - _handler.getReference().getIdentity().__write(_os); + _proxy.__reference().getIdentity().__write(_os); // // For compatibility with the old FacetPath. // - String facet = _handler.getReference().getFacet(); + String facet = _proxy.__reference().getFacet(); if(facet == null || facet.length() == 0) { _os.writeStringSeq(null); @@ -572,8 +622,8 @@ public final class Outgoing implements OutgoingMessageCallback // // Implicit context // - Ice.ImplicitContextI implicitContext = _handler.getReference().getInstance().getImplicitContext(); - java.util.Map<String, String> prxContext = _handler.getReference().getContext(); + Ice.ImplicitContextI implicitContext = _proxy.__reference().getInstance().getImplicitContext(); + java.util.Map<String, String> prxContext = _proxy.__reference().getContext(); if(implicitContext == null) { @@ -591,15 +641,14 @@ public final class Outgoing implements OutgoingMessageCallback } } + private Ice.ObjectPrxHelperBase _proxy; + private Ice.OperationMode _mode; private RequestHandler _handler; private Ice.EncodingVersion _encoding; private BasicStream _is; private BasicStream _os; private boolean _sent; - - private Ice.LocalException _exception; - private boolean _exceptionWrapper; - private boolean _exceptionWrapperRetry; + private Ice.Exception _exception; private static final int StateUnsent = 0; private static final int StateInProgress = 1; @@ -612,5 +661,7 @@ public final class Outgoing implements OutgoingMessageCallback private InvocationObserver _observer; private RemoteObserver _remoteObserver; - public Outgoing next; // For use by Ice._ObjectDelM + public Outgoing next; // For use by Ice.ObjectPrxHelperBase + + private static final java.util.Map<String, String> _emptyContext = new java.util.HashMap<String, String>(); } diff --git a/java/src/IceInternal/OutgoingAsync.java b/java/src/IceInternal/OutgoingAsync.java index 699477d4607..41c56076a94 100644 --- a/java/src/IceInternal/OutgoingAsync.java +++ b/java/src/IceInternal/OutgoingAsync.java @@ -21,7 +21,7 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa public void __prepare(String operation, Ice.OperationMode mode, java.util.Map<String, String> ctx, boolean explicitCtx) { - _delegate = null; + _handler = null; _cnt = 0; _mode = mode; _sentSynchronously = false; @@ -101,11 +101,17 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa public int __send(Ice.ConnectionI connection, boolean compress, boolean response) - throws LocalExceptionWrapper + throws RetryException { return connection.sendAsyncRequest(this, compress, response); } + public int + __invokeCollocated(CollocatedRequestHandler handler) + { + return handler.invokeAsyncRequest(this); + } + public boolean __sent() { @@ -129,7 +135,7 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa _timeoutRequestHandler = null; } _state |= Done | OK; - _os.resize(0, false); // Clear buffer now, instead of waiting for AsyncResult deallocation + //_os.resize(0, false); // Don't clear the buffer now, it's needed for the collocation optimization } _monitor.notifyAll(); return !alreadySent; // Don't call the sent call is already sent. @@ -143,7 +149,7 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa } public void - __finished(Ice.LocalException exc, boolean sent) + __finished(Ice.Exception exc, boolean sent) { synchronized(_monitor) { @@ -165,56 +171,16 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa // NOTE: at this point, synchronization isn't needed, no other threads should be // calling on the callback. // - - try - { - int interval = handleException(exc, sent); // This will throw if the invocation can't be retried. - if(interval > 0) - { - _instance.retryQueue().add(this, interval); - } - else - { - __invoke(false); - } - } - catch(Ice.LocalException ex) - { - __invokeException(ex); - } - } - - public final void - __finished(LocalExceptionWrapper exc) - { - // - // NOTE: at this point, synchronization isn't needed, no other threads should be - // calling on the callback. The LocalExceptionWrapper exception is only called - // before the invocation is sent. - // - - if(_remoteObserver != null) - { - _remoteObserver.failed(exc.get().ice_name()); - _remoteObserver.detach(); - _remoteObserver = null; - } - - assert(_timeoutRequestHandler == null); - try { - int interval = handleException(exc); // This will throw if the invocation can't be retried. - if(interval > 0) - { - _instance.retryQueue().add(this, interval); - } - else + if(!handleException(exc, sent)) { - __invoke(false); + return; // Can't be retried immediately. } + + __invoke(false); // Retry the invocation } - catch(Ice.LocalException ex) + catch(Ice.Exception ex) { __invokeException(ex); } @@ -396,12 +362,10 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa { while(true) { - int interval = 0; try { - _delegate = _proxy.__getDelegate(true); - RequestHandler handler = _delegate.__getRequestHandler(); - int status = handler.sendAsyncRequest(this); + _handler = _proxy.__getRequestHandler(true); + int status = _handler.sendAsyncRequest(this); if((status & AsyncStatus.Sent) > 0) { if(synchronous) @@ -427,30 +391,27 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa { if((_state & Done) == 0) { - int invocationTimeout = handler.getReference().getInvocationTimeout(); + int invocationTimeout = _handler.getReference().getInvocationTimeout(); if(invocationTimeout > 0) { _instance.timer().schedule(this, invocationTimeout); - _timeoutRequestHandler = handler; + _timeoutRequestHandler = _handler; } } } } break; } - catch(LocalExceptionWrapper ex) - { - interval = handleException(ex); - } - catch(Ice.LocalException ex) + catch(RetryException ex) { - interval = handleException(ex, false); + _proxy.__setRequestHandler(_handler, null); // Clear request handler and retry. } - - if(interval > 0) + catch(Ice.Exception ex) { - _instance.retryQueue().add(this, interval); - return false; + if(!handleException(ex, false)) // This will throw if the invocation can't be retried. + { + break; // Can't be retried immediately. + } } } return _sentSynchronously; @@ -488,78 +449,52 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa } } + BasicStream + __getIs() + { + return _is; + } + public void runTimerTask() { __runTimerTask(); } - private int - handleException(Ice.LocalException exc, boolean sent) + private boolean + handleException(Ice.Exception exc, boolean sent) { - Ice.IntHolder interval = new Ice.IntHolder(0); try { - // - // A CloseConnectionException indicates graceful server shutdown, and is therefore - // always repeatable without violating "at-most-once". That's because by sending a - // close connection message, the server guarantees that all outstanding requests - // can safely be repeated. - // - // An ObjectNotExistException can always be retried as well without violating - // "at-most-once" (see the implementation of the checkRetryAfterException method of - // the ProxyFactory class for the reasons why it can be useful). - // - if(!sent || - exc instanceof Ice.CloseConnectionException || - exc instanceof Ice.ObjectNotExistException) + Ice.IntHolder interval = new Ice.IntHolder(); + _cnt = _proxy.__handleException(exc, _handler, _mode, sent, interval, _cnt); + if(_observer != null) { - throw exc; + _observer.retried(); // Invocation is being retried. } - - // - // Throw the exception wrapped in a LocalExceptionWrapper, to indicate that the - // request cannot be resent without potentially violating the "at-most-once" - // principle. - // - throw new LocalExceptionWrapper(exc, false); - } - catch(LocalExceptionWrapper ex) - { - if(_mode == Ice.OperationMode.Nonmutating || _mode == Ice.OperationMode.Idempotent) + if(interval.value > 0) { - _cnt = _proxy.__handleExceptionWrapperRelaxed(_delegate, ex, interval, _cnt, _observer); + _instance.retryQueue().add(this, interval.value); + return false; // Don't retry immediately, the retry queue will take care of the retry. } else { - _proxy.__handleExceptionWrapper(_delegate, ex, _observer); + return true; // Retry immediately. } } - catch(Ice.LocalException ex) + catch(Ice.Exception ex) { - _cnt = _proxy.__handleException(_delegate, ex, interval, _cnt, _observer); - } - return interval.value; - } - - private int - handleException(LocalExceptionWrapper ex) - { - Ice.IntHolder interval = new Ice.IntHolder(0); - if(_mode == Ice.OperationMode.Nonmutating || _mode == Ice.OperationMode.Idempotent) - { - _cnt = _proxy.__handleExceptionWrapperRelaxed(_delegate, ex, interval, _cnt, _observer); - } - else - { - _proxy.__handleExceptionWrapper(_delegate, ex, _observer); + if(_observer != null) + { + _observer.failed(ex.ice_name()); + } + throw ex; } - return interval.value; } protected Ice.ObjectPrxHelperBase _proxy; - private Ice._ObjectDel _delegate; + private RequestHandler _handler; private Ice.EncodingVersion _encoding; private int _cnt; private Ice.OperationMode _mode; diff --git a/java/src/IceInternal/OutgoingAsyncMessageCallback.java b/java/src/IceInternal/OutgoingAsyncMessageCallback.java index bd710644a9e..8d830987428 100644 --- a/java/src/IceInternal/OutgoingAsyncMessageCallback.java +++ b/java/src/IceInternal/OutgoingAsyncMessageCallback.java @@ -19,7 +19,9 @@ public interface OutgoingAsyncMessageCallback // Called by the request handler to send the request over the connection. // int __send(Ice.ConnectionI conection, boolean compress, boolean response) - throws LocalExceptionWrapper; + throws RetryException; + + int __invokeCollocated(CollocatedRequestHandler handler); // // Called by the connection when the message is confirmed sent. The connection is locked @@ -40,5 +42,5 @@ public interface OutgoingAsyncMessageCallback // not the message was possibly sent (this is useful for retry to figure out whether // or not the request can't be retried without breaking at-most-once semantics.) // - public abstract void __finished(Ice.LocalException ex, boolean sent); + public abstract void __finished(Ice.Exception ex, boolean sent); } diff --git a/java/src/IceInternal/OutgoingMessageCallback.java b/java/src/IceInternal/OutgoingMessageCallback.java index af53575d3a9..18b18a09575 100644 --- a/java/src/IceInternal/OutgoingMessageCallback.java +++ b/java/src/IceInternal/OutgoingMessageCallback.java @@ -12,8 +12,11 @@ package IceInternal; public interface OutgoingMessageCallback { boolean send(Ice.ConnectionI conection, boolean compress, boolean response) - throws LocalExceptionWrapper; + throws RetryException; + + void invokeCollocated(CollocatedRequestHandler handler); void sent(); - void finished(Ice.LocalException ex, boolean sent); + + void finished(Ice.Exception ex, boolean sent); } diff --git a/java/src/IceInternal/ProxyBatchOutgoingAsync.java b/java/src/IceInternal/ProxyBatchOutgoingAsync.java index 8bea231573d..77a82ae2772 100644 --- a/java/src/IceInternal/ProxyBatchOutgoingAsync.java +++ b/java/src/IceInternal/ProxyBatchOutgoingAsync.java @@ -11,11 +11,10 @@ package IceInternal; public class ProxyBatchOutgoingAsync extends BatchOutgoingAsync { - public ProxyBatchOutgoingAsync(Ice.ObjectPrx prx, String operation, CallbackBase callback) + public ProxyBatchOutgoingAsync(Ice.ObjectPrxHelperBase prx, String operation, CallbackBase callback) { - super(prx.ice_getCommunicator(), ((Ice.ObjectPrxHelperBase)prx).__reference().getInstance(), operation, - callback); - _proxy = (Ice.ObjectPrxHelperBase)prx; + super(prx.ice_getCommunicator(), prx.__reference().getInstance(), operation, callback); + _proxy = prx; _observer = ObserverHelper.get(prx, operation); } @@ -23,25 +22,11 @@ public class ProxyBatchOutgoingAsync extends BatchOutgoingAsync { Protocol.checkSupportedProtocol(_proxy.__reference().getProtocol()); - // - // We don't automatically retry if ice_flushBatchRequests fails. Otherwise, if some batch - // requests were queued with the connection, they would be lost without being noticed. - // - Ice._ObjectDel delegate = null; - int cnt = -1; // Don't retry. + RequestHandler handler = null; try { - delegate = _proxy.__getDelegate(false); - RequestHandler handler = delegate.__getRequestHandler(); - int status; - try - { - status = handler.sendAsyncRequest(this); - } - catch(IceInternal.LocalExceptionWrapper ex) - { - throw ex.get(); - } + handler = _proxy.__getRequestHandler(true); + int status = handler.sendAsyncRequest(this); if((status & AsyncStatus.Sent) > 0) { _sentSynchronously = true; @@ -66,9 +51,23 @@ public class ProxyBatchOutgoingAsync extends BatchOutgoingAsync } } } - catch(Ice.LocalException __ex) + catch(RetryException ex) { - cnt = _proxy.__handleException(delegate, __ex, null, cnt, _observer); + // + // Clear request handler but don't retry or throw. Retrying + // isn't useful, there were no batch requests associated with + // the proxy's request handler. + // + _proxy.__setRequestHandler(handler, null); + } + catch(Ice.Exception ex) + { + if(_observer != null) + { + _observer.failed(ex.ice_name()); + } + _proxy.__setRequestHandler(handler, null); // Clear request handler + throw ex; // Throw to notify the user lthat batch requests were potentially lost. } } diff --git a/java/src/IceInternal/ProxyFactory.java b/java/src/IceInternal/ProxyFactory.java index c3fba4c0a88..6283de1dc0e 100644 --- a/java/src/IceInternal/ProxyFactory.java +++ b/java/src/IceInternal/ProxyFactory.java @@ -70,7 +70,7 @@ public final class ProxyFactory if(ref != null) { Ice.ObjectPrxHelperBase proxy = new Ice.ObjectPrxHelperBase(); - proxy.setup(ref); + proxy.__setup(ref); return proxy; } else @@ -248,23 +248,7 @@ public final class ProxyFactory logger.trace(traceLevels.retryCat, s); } - if(sleepInterval != null) - { - sleepInterval.value = interval; - } - else if(interval > 0) - { - // - // Sleep before retrying. - // - try - { - Thread.sleep(interval); - } - catch(InterruptedException ex1) - { - } - } + sleepInterval.value = interval; return cnt; } diff --git a/java/src/IceInternal/RequestHandler.java b/java/src/IceInternal/RequestHandler.java index 070ff48106a..92a94b0057a 100644 --- a/java/src/IceInternal/RequestHandler.java +++ b/java/src/IceInternal/RequestHandler.java @@ -14,15 +14,15 @@ import Ice.Instrumentation.InvocationObserver; public interface RequestHandler { void prepareBatchRequest(BasicStream out) - throws LocalExceptionWrapper; + throws RetryException; void finishBatchRequest(BasicStream out); void abortBatchRequest(); boolean sendRequest(OutgoingMessageCallback out) - throws LocalExceptionWrapper; + throws RetryException; int sendAsyncRequest(OutgoingAsyncMessageCallback out) - throws LocalExceptionWrapper; + throws RetryException; void requestTimedOut(OutgoingMessageCallback out); void asyncRequestTimedOut(OutgoingAsyncMessageCallback outAsync); @@ -30,10 +30,4 @@ public interface RequestHandler Reference getReference(); Ice.ConnectionI getConnection(boolean wait); - - Outgoing getOutgoing(String operation, Ice.OperationMode mode, java.util.Map<String, String> context, - InvocationObserver observer) - throws LocalExceptionWrapper; - - void reclaimOutgoing(Outgoing out); } diff --git a/java/src/IceInternal/ResponseHandler.java b/java/src/IceInternal/ResponseHandler.java new file mode 100644 index 00000000000..9b26f6ee2fc --- /dev/null +++ b/java/src/IceInternal/ResponseHandler.java @@ -0,0 +1,17 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package IceInternal; + +public interface ResponseHandler +{ + void sendResponse(int requestId, BasicStream os, byte status); + void sendNoResponse(); + void invokeException(int requestId, Ice.LocalException ex, int invokeNum); +}; diff --git a/java/src/IceInternal/RetryException.java b/java/src/IceInternal/RetryException.java new file mode 100644 index 00000000000..350a0d3ac18 --- /dev/null +++ b/java/src/IceInternal/RetryException.java @@ -0,0 +1,27 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package IceInternal; + +public class RetryException extends Exception +{ + public + RetryException(Ice.LocalException ex) + { + _ex = ex; + } + + public Ice.LocalException + get() + { + return _ex; + } + + private Ice.LocalException _ex; +} diff --git a/java/src/IceInternal/RouterInfo.java b/java/src/IceInternal/RouterInfo.java index 1630cb92819..84856f1294f 100644 --- a/java/src/IceInternal/RouterInfo.java +++ b/java/src/IceInternal/RouterInfo.java @@ -110,21 +110,7 @@ public final class RouterInfo public void exception(Ice.LocalException ex) { - if(ex instanceof Ice.CollocationOptimizationException) - { - try - { - callback.setEndpoints(getClientEndpoints()); - } - catch(Ice.LocalException e) - { - callback.setException(e); - } - } - else - { - callback.setException(ex); - } + callback.setException(ex); } }); } @@ -189,22 +175,7 @@ public final class RouterInfo public void exception(Ice.LocalException ex) { - if(ex instanceof Ice.CollocationOptimizationException) - { - try - { - addProxy(proxy); - callback.addedProxy(); - } - catch(Ice.LocalException e) - { - callback.setException(ex); - } - } - else - { - callback.setException(ex); - } + callback.setException(ex); } }); @@ -249,14 +220,10 @@ public final class RouterInfo // router, we must use the same timeout as the already // existing connection. // - try + if(_router.ice_getConnection() != null) { clientProxy = clientProxy.ice_timeout(_router.ice_getConnection().timeout()); } - catch(Ice.CollocationOptimizationException ex) - { - // Ignore - collocated router. - } _clientEndpoints = ((Ice.ObjectPrxHelperBase)clientProxy).__reference().getEndpoints(); } diff --git a/java/src/IceInternal/TwowayCallback.java b/java/src/IceInternal/TwowayCallback.java index 1a6e9b7480a..368f3600a04 100644 --- a/java/src/IceInternal/TwowayCallback.java +++ b/java/src/IceInternal/TwowayCallback.java @@ -15,8 +15,13 @@ public abstract class TwowayCallback extends CallbackBase implements Ice.TwowayC { } + public void exception(Ice.SystemException __ex) + { + exception(new Ice.UnknownException(__ex)); + } + public final void __sent(Ice.AsyncResult __result) { sent(__result.sentSynchronously()); } -};
\ No newline at end of file +}; |