diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/_ObjectDelM.java | 2 | ||||
-rw-r--r-- | java/src/IceInternal/Connection.java | 2 | ||||
-rw-r--r-- | java/src/IceInternal/Incoming.java | 27 | ||||
-rw-r--r-- | java/src/IceInternal/IncomingAsync.java | 25 | ||||
-rw-r--r-- | java/src/IceInternal/IncomingBase.java | 46 | ||||
-rw-r--r-- | java/src/IceInternal/OutgoingAsync.java | 94 |
6 files changed, 109 insertions, 87 deletions
diff --git a/java/src/Ice/_ObjectDelM.java b/java/src/Ice/_ObjectDelM.java index fbc3dff9656..c2159fcf7ff 100644 --- a/java/src/Ice/_ObjectDelM.java +++ b/java/src/Ice/_ObjectDelM.java @@ -269,7 +269,7 @@ public class _ObjectDelM implements _ObjectDel assert(__connection != null); __connection.incProxyCount(); } - catch (LocalException ex) + catch(LocalException ex) { if(__reference.routerInfo == null && __reference.endpoints.length == 0) { diff --git a/java/src/IceInternal/Connection.java b/java/src/IceInternal/Connection.java index ec6fba846bd..dae4db099cb 100644 --- a/java/src/IceInternal/Connection.java +++ b/java/src/IceInternal/Connection.java @@ -1135,7 +1135,7 @@ public final class Connection extends EventHandler while(in != null) { - in.destroy(); + in.__destroy(); in = in.next; } } diff --git a/java/src/IceInternal/Incoming.java b/java/src/IceInternal/Incoming.java index 42a109cf248..5041f182bf6 100644 --- a/java/src/IceInternal/Incoming.java +++ b/java/src/IceInternal/Incoming.java @@ -19,14 +19,7 @@ final public class Incoming extends IncomingBase public Incoming(Instance instance, Ice.ObjectAdapter adapter, Connection connection, boolean response) { - _current = new Ice.Current(); - _current.id = new Ice.Identity(); - _current.adapter = adapter; - _cookie = new Ice.LocalObjectHolder(); - _connection = connection; - _response = response; - _is = new BasicStream(instance); - _os = new BasicStream(instance); + super(instance, adapter, connection, response); } // @@ -64,24 +57,6 @@ final public class Incoming extends IncomingBase } } - // - // Reclaim resources. - // - public void - destroy() - { - if(_is != null) - { - _is.destroy(); - _is = null; - } - if(_os != null) - { - _os.destroy(); - _os = null; - } - } - public void invoke() { diff --git a/java/src/IceInternal/IncomingAsync.java b/java/src/IceInternal/IncomingAsync.java index f99cbc733bb..ba71f1fdd22 100644 --- a/java/src/IceInternal/IncomingAsync.java +++ b/java/src/IceInternal/IncomingAsync.java @@ -17,18 +17,9 @@ package IceInternal; public class IncomingAsync extends IncomingBase { public - IncomingAsync(Incoming in) // Adopts the Incoming argument. It must not be used afterwards. + IncomingAsync(Incoming in) // Adopts the argument. It must not be used afterwards. { - _current = in._current; - _servant = in._servant; - _locator = in._locator; - _cookie = in._cookie; - _connection = in._connection; - _response = in._response; - _is = in._is; - in._is = null; - _os = in._os; - in._os = null; + super(in); } final protected void @@ -54,6 +45,7 @@ public class IncomingAsync extends IncomingBase } __finishInvoke(); + __destroy(); } final protected void @@ -106,8 +98,6 @@ public class IncomingAsync extends IncomingBase _os.writeStringSeq(ex.facet); _os.writeString(ex.operation); } - - __finishInvoke(); } catch(Ice.LocalException ex) { @@ -120,8 +110,6 @@ public class IncomingAsync extends IncomingBase _os.writeByte((byte)DispatchStatus._DispatchUnknownLocalException); _os.writeString(ex.toString()); } - - __finishInvoke(); } catch(Ice.UserException ex) { @@ -134,8 +122,6 @@ public class IncomingAsync extends IncomingBase _os.writeByte((byte)DispatchStatus._DispatchUnknownUserException); _os.writeString(ex.toString()); } - - __finishInvoke(); } catch(Exception ex) { @@ -148,9 +134,10 @@ public class IncomingAsync extends IncomingBase _os.writeByte((byte)DispatchStatus._DispatchUnknownException); _os.writeString(ex.toString()); } - - __finishInvoke(); } + + __finishInvoke(); + __destroy(); } final protected BasicStream diff --git a/java/src/IceInternal/IncomingBase.java b/java/src/IceInternal/IncomingBase.java index 3c552358c94..ca6ea9798e1 100644 --- a/java/src/IceInternal/IncomingBase.java +++ b/java/src/IceInternal/IncomingBase.java @@ -16,6 +16,52 @@ package IceInternal; public class IncomingBase { + protected + IncomingBase(Instance instance, Ice.ObjectAdapter adapter, Connection connection, boolean response) + { + _current = new Ice.Current(); + _current.id = new Ice.Identity(); + _current.adapter = adapter; + _cookie = new Ice.LocalObjectHolder(); + _connection = connection; + _response = response; + _is = new BasicStream(instance); + _os = new BasicStream(instance); + } + + protected + IncomingBase(IncomingBase in) // Adopts the IncomingBase argument. It must not be used afterwards. + { + _current = in._current; + _servant = in._servant; + _locator = in._locator; + _cookie = in._cookie; + _connection = in._connection; + _response = in._response; + _is = in._is; + in._is = null; + _os = in._os; + in._os = null; + } + + // + // Reclaim resources. + // + final public void + __destroy() + { + if(_is != null) + { + _is.destroy(); + _is = null; + } + if(_os != null) + { + _os.destroy(); + _os = null; + } + } + final protected void __finishInvoke() { diff --git a/java/src/IceInternal/OutgoingAsync.java b/java/src/IceInternal/OutgoingAsync.java index a2a0c1d9f4d..68d518b95c2 100644 --- a/java/src/IceInternal/OutgoingAsync.java +++ b/java/src/IceInternal/OutgoingAsync.java @@ -28,50 +28,64 @@ public abstract class OutgoingAsync public void __setup(Connection connection, Reference ref, String operation, Ice.OperationMode mode, java.util.Map context) { - _connection = connection; - if(_is != null) + try { - _is.destroy(); + _connection = connection; + if(_is == null) + { + _is = new BasicStream(ref.instance); + } + else + { + _is.reset(); + } + if(_os == null) + { + _os = new BasicStream(ref.instance); + } + else + { + _os.reset(); + } + + _connection.prepareRequest(_os); + + ref.identity.__write(_os); + _os.writeStringSeq(ref.facet); + _os.writeString(operation); + _os.writeByte((byte)mode.value()); + if(context == null) + { + _os.writeSize(0); + } + else + { + final int sz = context.size(); + _os.writeSize(sz); + if(sz > 0) + { + java.util.Iterator i = context.entrySet().iterator(); + while(i.hasNext()) + { + java.util.Map.Entry entry = (java.util.Map.Entry)i.next(); + _os.writeString((String)entry.getKey()); + _os.writeString((String)entry.getValue()); + } + } + } + + // + // Input and output parameters are always sent in an + // encapsulation, which makes it possible to forward + // requests as blobs. + // + _os.startWriteEncaps(); } - if(_os != null) + catch(RuntimeException ex) { - _os.destroy(); + destroy(); + throw ex; } - _is = new BasicStream(ref.instance); - _os = new BasicStream(ref.instance); - - _connection.prepareRequest(_os); - - ref.identity.__write(_os); - _os.writeStringSeq(ref.facet); - _os.writeString(operation); - _os.writeByte((byte)mode.value()); - if(context == null) - { - _os.writeSize(0); - } - else - { - final int sz = context.size(); - _os.writeSize(sz); - if(sz > 0) - { - java.util.Iterator i = context.entrySet().iterator(); - while(i.hasNext()) - { - java.util.Map.Entry entry = (java.util.Map.Entry)i.next(); - _os.writeString((String)entry.getKey()); - _os.writeString((String)entry.getValue()); - } - } - } - - // - // Input and output parameters are always sent in an - // encapsulation, which makes it possible to forward requests as - // blobs. - // - _os.startWriteEncaps(); } public void |