Author: norman Date: Thu Aug 25 05:59:53 2011 New Revision: 1161399 URL: http://svn.apache.org/viewvc?rev=1161399&view=rev Log: Make sure all messages are flushed out to the client before closing the channel. See JAMES-1303
Modified: james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java Modified: james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java URL: http://svn.apache.org/viewvc/james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java?rev=1161399&r1=1161398&r2=1161399&view=diff ============================================================================== --- james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java (original) +++ james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java Thu Aug 25 05:59:53 2011 @@ -34,7 +34,9 @@ import org.apache.james.imap.encode.base import org.apache.james.imap.main.ResponseEncoder; import org.apache.james.protocols.impl.ChannelAttributeSupport; import org.apache.james.protocols.impl.SessionLog; +import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.ChannelFutureListener; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.ChannelStateEvent; @@ -150,8 +152,11 @@ public class ImapChannelUpstreamHandler if (imapSession != null) imapSession.logout(); - // just close the channel now! - ctx.getChannel().close(); + // Make sure we close the channel after all the buffers were flushed out + Channel channel = ctx.getChannel(); + if (channel.isConnected()) { + channel.write(ChannelBuffers.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE); + } } @@ -175,7 +180,11 @@ public class ImapChannelUpstreamHandler processor.process(message, responseEncoder, session); if (session.getState() == ImapSessionState.LOGOUT) { - ctx.getChannel().close(); + // Make sure we close the channel after all the buffers were flushed out + Channel channel = ctx.getChannel(); + if (channel.isConnected()) { + channel.write(ChannelBuffers.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE); + } } final IOException failure = responseEncoder.getFailure(); --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org