Author: ron.sigal(a)jboss.com
Date: 2008-06-10 23:14:38 -0400 (Tue, 10 Jun 2008)
New Revision: 4287
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java
Log:
JBREM-954: Made wrapping InterruptedException in a RuntimeException configurable.
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java
===================================================================
---
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java 2008-06-11
01:17:12 UTC (rev 4286)
+++
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java 2008-06-11
03:14:38 UTC (rev 4287)
@@ -70,6 +70,12 @@
* used, which may also be a requirement.
*/
public static final String CLIENT_SOCKET_CLASS_FLAG = "clientSocketClass";
+
+ /**
+ * Configuration key for determining if an InterruptedException should be rethrown
+ * or wrapped in a RuntimeException.
+ */
+ public static final String WRAP_INTERRUPTED_EXCEPTION =
"wrapInterruptedException";
/**
* Default value for enable TCP nodelay. Value is false.
@@ -215,6 +221,8 @@
//public long usedPooled;
public Object usedPoolLock;
+
+ protected boolean wrapInterruptedException = false;
// Constructors
---------------------------------------------------------------------------------
@@ -349,6 +357,16 @@
return numberOfRetries;
}
+ public boolean isWrapInterruptedException()
+ {
+ return wrapInterruptedException;
+ }
+
+ public void setWrapInterruptedException(boolean wrapInterruptedException)
+ {
+ this.wrapInterruptedException = wrapInterruptedException;
+ }
+
/**
* The name of of the server.
*/
@@ -550,18 +568,14 @@
{
socketWrapper = getConnection(marshaller, unmarshaller, timeLeft);
}
- catch (InterruptedException e)
- {
- semaphore.release();
- if (trace) log.trace(this + " released semaphore: " +
semaphore.permits(), e);
- throw new RuntimeException(e);
- }
catch (Exception e)
{
// if (bailOut)
// return null;
semaphore.release();
if (trace) log.trace(this + " released semaphore: " +
semaphore.permits());
+ if (e instanceof InterruptedException &&
isWrapInterruptedException())
+ throw new RuntimeException(e);
throw new CannotConnectException(
"Can not get connection to server. Problem establishing " +
"socket connection for " + locator, e);
@@ -724,7 +738,7 @@
throw (ClassNotFoundException)ex;
}
- if (ex instanceof InterruptedException)
+ if (ex instanceof InterruptedException && isWrapInterruptedException())
{
log.debug(this, ex);
throw new RuntimeException(ex);
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java
===================================================================
---
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java 2008-06-11
01:17:12 UTC (rev 4286)
+++
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java 2008-06-11
03:14:38 UTC (rev 4287)
@@ -118,7 +118,7 @@
throw new MarshalException("Socket timed out. Waited " +
socketWrapper.getTimeout() + " milliseconds for response while calling on " +
getLocator(), ex);
}
- else if (ex instanceof InterruptedException)
+ else if (ex instanceof InterruptedException &&
isWrapInterruptedException())
{
log.debug(this, ex);
throw new RuntimeException(ex);