Program: 85116
Project: 85116
Buggy source:
protected void encodeResponse(Channel channel,ChannelBuffer buffer,Response res) throws IOException {
  try {
    Serialization serialization=getSerialization(channel);
    byte[] header=new byte[HEADER_LENGTH];
    Bytes.short2bytes(MAGIC,header);
    header[2]=serialization.getContentTypeId();
    if (res.isHeartbeat())     header[2]|=FLAG_EVENT;
    byte status=res.getStatus();
    header[3]=status;
    Bytes.long2bytes(res.getId(),header,4);
    int savedWriteIndex=buffer.writerIndex();
    buffer.writerIndex(savedWriteIndex + HEADER_LENGTH);
    ChannelBufferOutputStream bos=new ChannelBufferOutputStream(buffer);
    ObjectOutput out=serialization.serialize(channel.getUrl(),bos);
    if (status == Response.OK) {
      if (res.isHeartbeat()) {
        encodeHeartbeatData(channel,out,res.getResult());
      }
 else {
        encodeResponseData(channel,out,res.getResult());
      }
    }
 else     out.writeUTF(res.getErrorMessage());
    out.flushBuffer();
    bos.flush();
    bos.close();
    int len=bos.writtenBytes();
    checkPayload(channel,len);
    Bytes.int2bytes(len,header,12);
    buffer.writerIndex(savedWriteIndex);
    buffer.writeBytes(header);
    buffer.writerIndex(savedWriteIndex + HEADER_LENGTH + len);
  }
 catch (  Throwable t) {
    if (!res.isEvent() && res.getStatus() != Response.BAD_RESPONSE) {
      try {
        logger.warn("String_Node_Str" + res + "String_Node_Str"+ t.getMessage(),t);
        Response r=new Response(res.getId(),res.getVersion());
        r.setStatus(Response.BAD_RESPONSE);
        r.setErrorMessage("String_Node_Str" + res + "String_Node_Str"+ StringUtils.toString(t));
        channel.send(r);
        return;
      }
 catch (      RemotingException e) {
        logger.warn("String_Node_Str" + res + "String_Node_Str"+ e.getMessage(),e);
      }
    }
    if (t instanceof IOException) {
      throw (IOException)t;
    }
 else     if (t instanceof RuntimeException) {
      throw (RuntimeException)t;
    }
 else     if (t instanceof Error) {
      throw (Error)t;
    }
 else {
      throw new RuntimeException(t.getMessage(),t);
    }
  }
}

Fixed version (ground truth):
protected void encodeResponse(Channel channel,ChannelBuffer buffer,Response res) throws IOException {
  int savedWriteIndex=buffer.writerIndex();
  try {
    Serialization serialization=getSerialization(channel);
    byte[] header=new byte[HEADER_LENGTH];
    Bytes.short2bytes(MAGIC,header);
    header[2]=serialization.getContentTypeId();
    if (res.isHeartbeat())     header[2]|=FLAG_EVENT;
    byte status=res.getStatus();
    header[3]=status;
    Bytes.long2bytes(res.getId(),header,4);
    buffer.writerIndex(savedWriteIndex + HEADER_LENGTH);
    ChannelBufferOutputStream bos=new ChannelBufferOutputStream(buffer);
    ObjectOutput out=serialization.serialize(channel.getUrl(),bos);
    if (status == Response.OK) {
      if (res.isHeartbeat()) {
        encodeHeartbeatData(channel,out,res.getResult());
      }
 else {
        encodeResponseData(channel,out,res.getResult());
      }
    }
 else     out.writeUTF(res.getErrorMessage());
    out.flushBuffer();
    bos.flush();
    bos.close();
    int len=bos.writtenBytes();
    checkPayload(channel,len);
    Bytes.int2bytes(len,header,12);
    buffer.writerIndex(savedWriteIndex);
    buffer.writeBytes(header);
    buffer.writerIndex(savedWriteIndex + HEADER_LENGTH + len);
  }
 catch (  Throwable t) {
    buffer.writerIndex(savedWriteIndex);
    if (!res.isEvent() && res.getStatus() != Response.BAD_RESPONSE) {
      Response r=new Response(res.getId(),res.getVersion());
      r.setStatus(Response.BAD_RESPONSE);
      if (t instanceof ExceedPayloadLimitException) {
        logger.warn(t.getMessage(),t);
        try {
          r.setErrorMessage(t.getMessage());
          channel.send(r);
          return;
        }
 catch (        RemotingException e) {
          logger.warn("String_Node_Str" + t.getMessage() + "String_Node_Str"+ e.getMessage(),e);
        }
      }
 else {
        logger.warn("String_Node_Str" + res + "String_Node_Str"+ t.getMessage(),t);
        try {
          r.setErrorMessage("String_Node_Str" + res + "String_Node_Str"+ StringUtils.toString(t));
          channel.send(r);
          return;
        }
 catch (        RemotingException e) {
          logger.warn("String_Node_Str" + res + "String_Node_Str"+ e.getMessage(),e);
        }
      }
    }
    if (t instanceof IOException) {
      throw (IOException)t;
    }
 else     if (t instanceof RuntimeException) {
      throw (RuntimeException)t;
    }
 else     if (t instanceof Error) {
      throw (Error)t;
    }
 else {
      throw new RuntimeException(t.getMessage(),t);
    }
  }
}