summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/IceInternal/Connection.java39
-rw-r--r--java/src/IceInternal/Incoming.java29
-rw-r--r--java/src/IceInternal/IncomingAsync.java8
3 files changed, 66 insertions, 10 deletions
diff --git a/java/src/IceInternal/Connection.java b/java/src/IceInternal/Connection.java
index b43451aba7e..c0f728479ca 100644
--- a/java/src/IceInternal/Connection.java
+++ b/java/src/IceInternal/Connection.java
@@ -1093,7 +1093,7 @@ public final class Connection extends EventHandler
Incoming in = null;
try
{
- while(invoke-- > 0)
+ while(invoke > 0)
{
//
@@ -1110,7 +1110,7 @@ public final class Connection extends EventHandler
//
if(response)
{
- assert(invoke == 0); // No further invocations if a response is expected.
+ assert(invoke == 1); // No further invocations if a response is expected.
os.writeBlob(_replyHdr);
//
@@ -1124,7 +1124,7 @@ public final class Connection extends EventHandler
//
// If there are more invocations, we need the stream back.
//
- if(invoke > 0)
+ if(--invoke > 0)
{
stream.swap(is);
}
@@ -1135,6 +1135,8 @@ public final class Connection extends EventHandler
}
catch(Ice.LocalException ex)
{
+ assert(invoke > 0);
+
synchronized(this)
{
setState(StateClosed, ex);
@@ -1142,15 +1144,23 @@ public final class Connection extends EventHandler
}
catch(AssertionError ex)
{
+ assert(invoke > 0);
+
//
// Java only: Upon an assertion, we don't kill the whole
// process, but just print the stack trace and close the
// connection.
//
- ex.printStackTrace();
synchronized(this)
{
- setState(StateClosed, new Ice.UnknownException());
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ ex.printStackTrace(pw);
+ pw.flush();
+ Ice.UnknownException exc = new Ice.UnknownException();
+ exc.unknown = sw.toString();
+ _logger.error(exc.unknown);
+ setState(StateClosed, exc);
}
}
finally
@@ -1159,6 +1169,25 @@ public final class Connection extends EventHandler
{
reclaimIncoming(in);
}
+
+ //
+ // If invoke() above raised an exception, and therefore
+ // neither sendResponse() nor sendNoResponse() has been
+ // called, then we must decrement _dispatchCount here.
+ //
+ if(invoke > 0)
+ {
+ synchronized(this)
+ {
+ assert(_dispatchCount > 0);
+ _dispatchCount -= invoke;
+ assert(_dispatchCount >= 0);
+ if(_dispatchCount == 0)
+ {
+ notifyAll();
+ }
+ }
+ }
}
}
diff --git a/java/src/IceInternal/Incoming.java b/java/src/IceInternal/Incoming.java
index cf0d5def6f7..a53d45c2c08 100644
--- a/java/src/IceInternal/Incoming.java
+++ b/java/src/IceInternal/Incoming.java
@@ -151,6 +151,8 @@ final public class Incoming extends IncomingBase
}
catch(Ice.RequestFailedException ex)
{
+ _is.endReadEncaps();
+
if(ex.id == null)
{
ex.id = _current.id;
@@ -209,12 +211,17 @@ final public class Incoming extends IncomingBase
_os.writeString(ex.operation);
}
+ //
+ // Must be called last, so that if an exception is raised,
+ // this function is definitely *not* called.
+ //
__finishInvoke();
- _is.endReadEncaps();
return;
}
catch(Ice.LocalException ex)
{
+ _is.endReadEncaps();
+
if(_os.instance().properties().getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
__warning(ex);
@@ -232,8 +239,11 @@ final public class Incoming extends IncomingBase
_os.writeString(sw.toString());
}
+ //
+ // Must be called last, so that if an exception is raised,
+ // this function is definitely *not* called.
+ //
__finishInvoke();
- _is.endReadEncaps();
return;
}
/* Not possible in Java - UserExceptions are checked exceptions
@@ -244,6 +254,8 @@ final public class Incoming extends IncomingBase
*/
catch(Exception ex)
{
+ _is.endReadEncaps();
+
if(_os.instance().properties().getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
__warning(ex);
@@ -261,8 +273,11 @@ final public class Incoming extends IncomingBase
_os.writeString(sw.toString());
}
+ //
+ // Must be called last, so that if an exception is raised,
+ // this function is definitely *not* called.
+ //
__finishInvoke();
- _is.endReadEncaps();
return;
}
@@ -272,6 +287,8 @@ final public class Incoming extends IncomingBase
// the caller of this operation.
//
+ _is.endReadEncaps();
+
//
// DispatchAsync is "pseudo dispatch status", used internally
// only to indicate async dispatch.
@@ -283,7 +300,6 @@ final public class Incoming extends IncomingBase
// here. We do *not* call __finishInvoke(), because
// the call is not finished yet.
//
- _is.endReadEncaps();
return;
}
@@ -326,8 +342,11 @@ final public class Incoming extends IncomingBase
}
}
+ //
+ // Must be called last, so that if an exception is raised,
+ // this function is definitely *not* called.
+ //
__finishInvoke();
- _is.endReadEncaps();
}
public BasicStream
diff --git a/java/src/IceInternal/IncomingAsync.java b/java/src/IceInternal/IncomingAsync.java
index 98f6e5f871d..b2822df23c4 100644
--- a/java/src/IceInternal/IncomingAsync.java
+++ b/java/src/IceInternal/IncomingAsync.java
@@ -62,6 +62,10 @@ public class IncomingAsync extends IncomingBase
_os.pos(save);
}
+ //
+ // Must be called last, so that if an exception is raised,
+ // this function is definitely *not* called.
+ //
__finishInvoke();
}
@@ -196,6 +200,10 @@ public class IncomingAsync extends IncomingBase
}
}
+ //
+ // Must be called last, so that if an exception is raised,
+ // this function is definitely *not* called.
+ //
__finishInvoke();
}