james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1161391 - /james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractSession.java
Date Thu, 25 Aug 2011 05:36:22 GMT
Author: norman
Date: Thu Aug 25 05:36:22 2011
New Revision: 1161391

URL: http://svn.apache.org/viewvc?rev=1161391&view=rev
Log:
AbstractSession.write(...) may fail to close the channel in some cases. See PROTOCOLS-27

Modified:
    james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractSession.java

Modified: james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractSession.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractSession.java?rev=1161391&r1=1161390&r2=1161391&view=diff
==============================================================================
--- james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractSession.java
(original)
+++ james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractSession.java
Thu Aug 25 05:36:22 2011
@@ -151,22 +151,13 @@ public abstract class AbstractSession im
      * @see org.apache.james.api.protocol.ProtocolSession#writeResponse(org.apache.james.api.protocol.Response)
      */
     public void writeResponse(final Response response) {
-        Channel channel = getChannelHandlerContext().getChannel();
+    	Channel channel = getChannelHandlerContext().getChannel();
         if (response != null && channel.isConnected()) {
-            channel.write(response).addListener(new ChannelFutureListener() {
-                
-                /*
-                 * (non-Javadoc)
-                 * @see org.jboss.netty.channel.ChannelFutureListener#operationComplete(org.jboss.netty.channel.ChannelFuture)
-                 */
-                public void operationComplete(ChannelFuture c) throws Exception {
-                    // once the response was written we can close the channel if needed
-                    if (response.isEndSession() && c.getChannel().isConnected())
{
-                        c.getChannel().close();         
-                    }
-                }
-            });
-          
+           ChannelFuture cf = channel.write(response);
+           if (response.isEndSession()) {
+                // close the channel if needed after the message was written out
+                cf.addListener(ChannelFutureListener.CLOSE);
+           }
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message