Skip to content

Commit

Permalink
[#1899] fix(PlayHandler): check if the channel because writing on it
Browse files Browse the repository at this point in the history
  • Loading branch information
xael-fry committed Jan 6, 2015
1 parent c1dd6fd commit 92d518c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions framework/src/play/server/PlayHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.jboss.netty.handler.codec.frame.TooLongFrameException;
import org.jboss.netty.handler.codec.http.*;
import org.jboss.netty.handler.codec.http.websocketx.*;
import org.jboss.netty.handler.stream.ChunkedFile;
import org.jboss.netty.handler.stream.ChunkedInput;
import org.jboss.netty.handler.stream.ChunkedStream;
import org.jboss.netty.handler.stream.ChunkedWriteHandler;
Expand Down Expand Up @@ -384,10 +383,15 @@ protected static void writeResponse(ChannelHandlerContext ctx, Response response
setContentLength(nettyResponse, response.out.size());
}

ChannelFuture f = ctx.getChannel().write(nettyResponse);
ChannelFuture f = null;
if (ctx.getChannel().isOpen()) {
f = ctx.getChannel().write(nettyResponse);
} else {
Logger.error("Try to write on a closed channel[keepAlive:%s]", keepAlive);
}

// Decide whether to close the connection or not.
if (!keepAlive) {
if (f != null && !keepAlive) {
// Close the connection when the whole content is written out.
f.addListener(ChannelFutureListener.CLOSE);
}
Expand Down

0 comments on commit 92d518c

Please sign in to comment.