Program: 5801
Project: 5801
Buggy source:
@Override public void messageReceived(final ChannelHandlerContext ctx,MessageEvent event) throws Exception {
  if (channelClosed) {
    return;
  }
  final Channel inboundChannel=event.getChannel();
  Object msg=event.getMessage();
  if (msg instanceof HttpChunk) {
    if (chunkSender == null) {
      throw new HandlerException(HttpResponseStatus.INTERNAL_SERVER_ERROR,"String_Node_Str");
    }
    chunkSender.send(msg);
  }
 else   if (msg instanceof HttpRequest) {
    HttpRequest request=(HttpRequest)msg;
    request=applyProxyRules(request);
    inboundChannel.setReadable(false);
    WrappedDiscoverable discoverable=getDiscoverable(request,(InetSocketAddress)inboundChannel.getLocalAddress());
    MessageSender sender=discoveryLookup.get(discoverable);
    if (sender == null || !sender.isConnected()) {
      InetSocketAddress address=discoverable.getSocketAddress();
      ChannelFuture future=clientBootstrap.connect(address);
      final Channel outboundChannel=future.getChannel();
      outboundChannel.getPipeline().addAfter("String_Node_Str","String_Node_Str",new OutboundHandler(inboundChannel));
      sender=new MessageSender(inboundChannel,future);
      discoveryLookup.put(discoverable,sender);
      inboundChannel.setAttachment(outboundChannel);
      outboundChannel.getCloseFuture().addListener(new ChannelFutureListener(){
        @Override public void operationComplete(        ChannelFuture future) throws Exception {
          inboundChannel.getPipeline().execute(new Runnable(){
            @Override public void run(){
              if (outboundChannel.equals(inboundChannel.getAttachment())) {
                closeOnFlush(inboundChannel);
              }
            }
          }
);
        }
      }
);
    }
    sender.send(request);
    inboundChannel.setReadable(true);
    if (request.isChunked()) {
      chunkSender=sender;
    }
  }
 else {
    super.messageReceived(ctx,event);
  }
}

Fixed version (ground truth):
@Override public void messageReceived(final ChannelHandlerContext ctx,MessageEvent event) throws Exception {
  if (channelClosed) {
    return;
  }
  final Channel inboundChannel=event.getChannel();
  Object msg=event.getMessage();
  if (msg instanceof HttpChunk) {
    if (chunkSender == null) {
      throw new HandlerException(HttpResponseStatus.INTERNAL_SERVER_ERROR,"String_Node_Str");
    }
    chunkSender.send(msg);
  }
 else   if (msg instanceof HttpRequest) {
    HttpRequest request=(HttpRequest)msg;
    request=applyProxyRules(request);
    inboundChannel.setReadable(false);
    WrappedDiscoverable discoverable=getDiscoverable(request,(InetSocketAddress)inboundChannel.getLocalAddress());
    MessageSender sender=discoveryLookup.get(discoverable);
    if (sender == null || !sender.isConnected()) {
      InetSocketAddress address=discoverable.getSocketAddress();
      ChannelFuture future=clientBootstrap.connect(address);
      final Channel outboundChannel=future.getChannel();
      outboundChannel.getPipeline().addAfter("String_Node_Str","String_Node_Str",new OutboundHandler(inboundChannel));
      sender=new MessageSender(inboundChannel,future);
      discoveryLookup.put(discoverable,sender);
      inboundChannel.setAttachment(outboundChannel);
      outboundChannel.getCloseFuture().addListener(new ChannelFutureListener(){
        @Override public void operationComplete(        ChannelFuture future) throws Exception {
          inboundChannel.getPipeline().execute(new Runnable(){
            @Override public void run(){
              if (outboundChannel.equals(inboundChannel.getAttachment())) {
                closeOnFlush(inboundChannel);
              }
            }
          }
);
        }
      }
);
    }
 else {
      Channel outboundChannel=(Channel)inboundChannel.getAttachment();
      if (outboundChannel != null) {
        outboundChannel.setReadable(true);
      }
    }
    sender.send(request);
    inboundChannel.setReadable(true);
    if (request.isChunked()) {
      chunkSender=sender;
    }
  }
 else {
    super.messageReceived(ctx,event);
  }
}