Author: ron.sigal(a)jboss.com
Date: 2008-12-29 21:34:37 -0500 (Mon, 29 Dec 2008)
New Revision: 4772
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java
Log:
JBREM-1073: Added facility to rethrow an InvalidStateException as a
CannotConnectException.
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java
===================================================================
---
remoting2/branches/2.x/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java 2008-12-30
02:33:54 UTC (rev 4771)
+++
remoting2/branches/2.x/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java 2008-12-30
02:34:37 UTC (rev 4772)
@@ -46,6 +46,7 @@
private LeasePinger leasePinger = null;
private String invokerSessionID = new GUID().toString();
protected boolean parentFirstClassLoading = true;
+ private boolean changeInvalidStateToCannotConnect = false;
protected List connectHomes;
@@ -209,16 +210,26 @@
System.arraycopy(serverStackTrace, 0, completeStackTrace, 0,
serverStackTrace.length);
System.arraycopy(clientStackTrace, 0, completeStackTrace,
serverStackTrace.length, clientStackTrace.length);
+ Throwable responseException = null;
+ if (e instanceof ServerInvoker.InvalidStateException &&
changeInvalidStateToCannotConnect)
+ {
+ responseException = new CannotConnectException(e.getMessage(),
e.getCause());
+ }
+ else
+ {
+ responseException = e;
+ }
+
if (e.getCause() != null)
{
- e.getCause().setStackTrace(completeStackTrace);
+ responseException.getCause().setStackTrace(completeStackTrace);
}
else
{
- e.setStackTrace(completeStackTrace);
+ responseException.setStackTrace(completeStackTrace);
}
- throw e;
+ throw responseException;
}
if (trace) { log.trace(this + " received InvocationResponse so going to
return response's return value of " + returnValue);}
@@ -542,6 +553,13 @@
parentFirst = Boolean.valueOf(sflag).booleanValue();
}
parentFirstClassLoading = parentFirst;
+
+ flag = configuration.get(Remoting.CHANGE_INVALID_STATE_TO_CANNOT_CONNECT);
+ if (flag != null)
+ {
+ String sflag = flag.toString();
+ changeInvalidStateToCannotConnect = Boolean.valueOf(sflag).booleanValue();
+ }
}
/**
Show replies by date