From 8ed89dbd8f13cb78c7b2ed0ed2f2fe257d0dbee8 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Tue, 21 Jul 2009 07:36:11 +0000 Subject: [PATCH] Fixed a race condition in HttpTunnelingServlet which caused data corruption and duplicate write --- .../netty/channel/socket/http/HttpTunnelingServlet.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelingServlet.java b/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelingServlet.java index dcbb4ada0c..57cb1cc2ab 100644 --- a/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelingServlet.java +++ b/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelingServlet.java @@ -240,8 +240,10 @@ public class HttpTunnelingServlet extends HttpServlet { @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { ChannelBuffer buffer = (ChannelBuffer) e.getMessage(); - buffer.readBytes(out, buffer.readableBytes()); - out.flush(); + synchronized (this) { + buffer.readBytes(out, buffer.readableBytes()); + out.flush(); + } } @Override