Program: 111380
Project: 111380
Buggy source:
@Override protected void channelRead0(ChannelHandlerContext ctx,HttpObject msg) throws Exception {
  if (msg instanceof HttpResponse) {
    response=(HttpResponse)msg;
  }
 else   if (msg instanceof HttpContent) {
    HttpContent content=(HttpContent)msg;
    ByteBuf byteBuf=content.content();
switch (response.status().code()) {
case 200:
case 201:
case 204:
      ctx.fireChannelRead(byteBuf);
    break;
default :
  errorBody.writeBytes(byteBuf);
}
if (content instanceof LastHttpContent) {
try {
switch (response.status().code()) {
case 101:
case 200:
case 201:
case 204:
    break;
case 301:
case 302:
  if (response.headers().contains(HttpHeaderNames.LOCATION)) {
    String location=response.headers().get(HttpHeaderNames.LOCATION);
    HttpRequest redirected=requestProvider.getHttpRequest(location);
    ctx.channel().writeAndFlush(redirected);
  }
break;
case 304:
throw new NotModifiedException(getBodyAsMessage(errorBody));
case 400:
throw new BadRequestException(getBodyAsMessage(errorBody));
case 401:
throw new UnauthorizedException(getBodyAsMessage(errorBody));
case 404:
throw new NotFoundException(getBodyAsMessage(errorBody));
case 406:
throw new NotAcceptableException(getBodyAsMessage(errorBody));
case 409:
throw new ConflictException(getBodyAsMessage(errorBody));
case 500:
throw new InternalServerErrorException(getBodyAsMessage(errorBody));
default :
throw new DockerException(getBodyAsMessage(errorBody),response.status().code());
}
}
 catch (Throwable e) {
resultCallback.onError(e);
}
 finally {
resultCallback.onComplete();
}
}
}
}

Fixed version (ground truth):
@Override protected void channelRead0(final ChannelHandlerContext ctx,HttpObject msg) throws Exception {
  if (msg instanceof HttpResponse) {
    response=(HttpResponse)msg;
    resultCallback.onStart(new Closeable(){
      @Override public void close(){
        ctx.channel().close();
      }
    }
);
  }
 else   if (msg instanceof HttpContent) {
    HttpContent content=(HttpContent)msg;
    ByteBuf byteBuf=content.content();
switch (response.status().code()) {
case 200:
case 201:
case 204:
      ctx.fireChannelRead(byteBuf);
    break;
default :
  errorBody.writeBytes(byteBuf);
}
if (content instanceof LastHttpContent) {
try {
switch (response.status().code()) {
case 101:
case 200:
case 201:
case 204:
    break;
case 301:
case 302:
  if (response.headers().contains(HttpHeaderNames.LOCATION)) {
    String location=response.headers().get(HttpHeaderNames.LOCATION);
    HttpRequest redirected=requestProvider.getHttpRequest(location);
    ctx.channel().writeAndFlush(redirected);
  }
break;
case 304:
throw new NotModifiedException(getBodyAsMessage(errorBody));
case 400:
throw new BadRequestException(getBodyAsMessage(errorBody));
case 401:
throw new UnauthorizedException(getBodyAsMessage(errorBody));
case 404:
throw new NotFoundException(getBodyAsMessage(errorBody));
case 406:
throw new NotAcceptableException(getBodyAsMessage(errorBody));
case 409:
throw new ConflictException(getBodyAsMessage(errorBody));
case 500:
throw new InternalServerErrorException(getBodyAsMessage(errorBody));
default :
throw new DockerException(getBodyAsMessage(errorBody),response.status().code());
}
}
 catch (Throwable e) {
resultCallback.onError(e);
}
 finally {
resultCallback.onComplete();
}
}
}
}