Fixed a race condition in HttpTunnelingServlet which caused data corruption and duplicate write

This commit is contained in:
Trustin Lee 2009-07-21 07:36:11 +00:00
parent a28d08936d
commit 8ed89dbd8f

View File

@ -240,9 +240,11 @@ public class HttpTunnelingServlet extends HttpServlet {
@Override @Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
ChannelBuffer buffer = (ChannelBuffer) e.getMessage(); ChannelBuffer buffer = (ChannelBuffer) e.getMessage();
synchronized (this) {
buffer.readBytes(out, buffer.readableBytes()); buffer.readBytes(out, buffer.readableBytes());
out.flush(); out.flush();
} }
}
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {