Author: alessio.soldano(a)jboss.com
Date: 2009-10-01 11:58:57 -0400 (Thu, 01 Oct 2009)
New Revision: 10821
Modified:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyClient.java
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyTransportHandler.java
Log:
[JBWS-2753] Survive closed connections not yet evicted from cache
Modified:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyClient.java
===================================================================
---
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyClient.java 2009-10-01
14:01:17 UTC (rev 10820)
+++
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyClient.java 2009-10-01
15:58:57 UTC (rev 10821)
@@ -28,6 +28,7 @@
import java.net.URL;
import java.nio.channels.ClosedChannelException;
import java.util.Map;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
@@ -113,6 +114,26 @@
*/
public Object invoke(Object reqMessage, String targetAddress, boolean oneway,
Map<String, Object> additionalHeaders, Map<String, Object> callProps) throws
IOException
{
+ try
+ {
+ return invokeInternal(reqMessage, targetAddress, oneway, additionalHeaders,
callProps);
+ }
+ catch (ClosedChannelException cce)
+ {
+ if (NettyTransportHandler.getHttpKeepAliveSet())
+ {
+ log.info("Retrying with a new connection..."); //because using keep-alive
connections it's possible to try re-using closed connections before they've been
evicted
+ return invokeInternal(reqMessage, targetAddress, oneway, additionalHeaders,
callProps);
+ }
+ else
+ {
+ throw cce;
+ }
+ }
+ }
+
+ private Object invokeInternal(Object reqMessage, String targetAddress, boolean oneway,
Map<String, Object> additionalHeaders, Map<String, Object> callProps) throws
IOException
+ {
URL target;
try
{
@@ -153,7 +174,17 @@
//Get the response
Future<Result> futureResult = responseHandler.getFutureResult();
- Result result = timeout == null ? futureResult.get() : futureResult.get(timeout,
TimeUnit.MILLISECONDS);
+ Result result = null;
+ try
+ {
+ result = timeout == null ? futureResult.get() : futureResult.get(timeout,
TimeUnit.MILLISECONDS);
+ }
+ catch (ExecutionException ee)
+ {
+ //unwrap ExecutionException
+ Throwable t = ee.getCause();
+ throw t != null ? t : ee;
+ }
resHeaders = result.getResponseHeaders();
Object resMessage = oneway ? null : unmarshaller.read(result.getResponse(),
resHeaders);
@@ -205,7 +236,7 @@
transport.finished(resHeaders);
}
}
-
+
private static SslHandler getSSLHandler(URL target, Map<String, Object>
callProps) throws IOException
{
SslHandler handler = null;
Modified:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyTransportHandler.java
===================================================================
---
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyTransportHandler.java 2009-10-01
14:01:17 UTC (rev 10820)
+++
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyTransportHandler.java 2009-10-01
15:58:57 UTC (rev 10821)
@@ -313,7 +313,7 @@
}
}
- public boolean getHttpKeepAliveSet()
+ public static boolean getHttpKeepAliveSet()
{
return keepAliveProp;
}
Show replies by date