Author: alessio.soldano(a)jboss.com
Date: 2009-09-11 10:12:37 -0400 (Fri, 11 Sep 2009)
New Revision: 10683
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyClient.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyTransportHandler.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMBackPortsInvocationHandler.java
Log:
[JBWS-2753] Further fixes
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyClient.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyClient.java 2009-09-11
14:11:21 UTC (rev 10682)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyClient.java 2009-09-11
14:12:37 UTC (rev 10683)
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.net.ConnectException;
import java.net.InetSocketAddress;
import java.net.MalformedURLException;
import java.net.URL;
@@ -151,22 +152,16 @@
setAuthorization(request, callProps);
ChannelFuture writeFuture = null;
- try
+
+ writeFuture = writeRequest(channel, request, reqMessage);
+
+ if (writeFuture != null)
{
- writeFuture = writeRequest(channel, request, reqMessage);
+ writeFuture.awaitUninterruptibly();
}
- catch (ClosedChannelException cce)
- {
- log.debug("Channel closed by remote peer while sending message");
- }
-
if (!waitForResponse)
{
//No need to wait for the result, just wait for the write to be completed.
- if (writeFuture != null)
- {
- writeFuture.awaitUninterruptibly();
- }
return null;
}
@@ -187,6 +182,17 @@
return resMessage;
}
+ catch (ClosedChannelException cce)
+ {
+ log.error("Channel closed by remote peer while sending message");
+ transport.end();
+ throw cce;
+ }
+ catch (ConnectException ce)
+ {
+ transport.end();
+ throw ce;
+ }
catch (IOException ioe)
{
throw ioe;
@@ -203,6 +209,7 @@
{
IOException io = new IOException("Could not transmit message");
io.initCause(t);
+ transport.end();
throw io;
}
finally
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyTransportHandler.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyTransportHandler.java 2009-09-11
14:11:21 UTC (rev 10682)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyTransportHandler.java 2009-09-11
14:12:37 UTC (rev 10683)
@@ -22,6 +22,7 @@
package org.jboss.ws.core.client.transport;
import java.io.IOException;
+import java.net.ConnectException;
import java.net.InetSocketAddress;
import java.net.URL;
import java.security.AccessController;
@@ -142,7 +143,7 @@
* @return A Netty channel
* @throws IOException
*/
- public Channel getChannel() throws IOException
+ public Channel getChannel() throws ConnectException
{
return getChannel(null);
}
@@ -154,16 +155,16 @@
* @return A Netty channel
* @throws IOException
*/
- public Channel getChannel(Long timeout) throws IOException
+ public Channel getChannel(Long timeout) throws ConnectException
{
if (channel == null && connectFuture != null) //first call after connection
attempt
{
NettyHelper.awaitUninterruptibly(connectFuture, timeout);
if (!connectFuture.isSuccess())
{
- IOException io = new IOException("Could not connect to " +
url.getHost());
- io.initCause(connectFuture.getCause());
- throw io;
+ ConnectException ce = new ConnectException("Could not connect to "
+ url.getHost());
+ ce.initCause(connectFuture.getCause());
+ throw ce;
}
channel = connectFuture.getChannel();
}
@@ -297,7 +298,15 @@
public void end()
{
keepingAlive = false;
- channel.close();
+ if (channel == null)
+ {
+ channel = connectFuture.getChannel();
+ connectFuture.cancel();
+ }
+ if (channel != null)
+ {
+ channel.close();
+ }
factory.releaseExternalResources();
}
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMBackPortsInvocationHandler.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMBackPortsInvocationHandler.java 2009-09-11
14:11:21 UTC (rev 10682)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMBackPortsInvocationHandler.java 2009-09-11
14:12:37 UTC (rev 10683)
@@ -33,6 +33,7 @@
import org.jboss.logging.Logger;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBufferInputStream;
+import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelPipelineCoverage;
import org.jboss.netty.channel.ChannelStateEvent;
@@ -161,8 +162,8 @@
}
// Write the response.
- e.getChannel().write(response);
- e.getChannel().close();
+ ChannelFuture cf = e.getChannel().write(response);
+ cf.awaitUninterruptibly();
}
@Override
Show replies by date