Program: 32774
Project: 32774
Buggy source:
/** 
 * Handle a chunk by parsing the contents of the input buffer. If the input buffer does not contain a complete chunk, this will return. If it does contain a chunk: <li>the chunk will be processed <li>if the chunk is empty, the connection will be closed <p>It is possible that the source stream is not chunked, as a consequence of an interfering proxy server. In this case, we arbitrarily form our own chunks which are as large as possible.
 * @return whether the expected data was read fully. This returns false if therewas an insufficient amount of data to satisfy the request.
 */
private boolean handleChunk(){
  try {
    if (sourceChunked) {
      int chunkEndIndex=parser.indexOf("String_Node_Str");
      if (chunkEndIndex == -1)       return false;
      String chunkSizeInHex=parser.readUntil("String_Node_Str",false);
      int chunkSize=Integer.parseInt(chunkSizeInHex,16);
      int bytesRequired=chunkEndIndex + 2 + chunkSize+ 2;
      if (bytesRequired > parser.bytesAvailable()) {
        return false;
      }
      parser.consume("String_Node_Str");
      ByteBuffer chunkBuffer=parser.readBytes(chunkSize);
      parser.consume("String_Node_Str");
      if (chunkSize != 0) {
        handler.receiveChunk(this,chunkBuffer);
        return true;
      }
 else {
        return close();
      }
    }
 else {
      int bytesAvailable=parser.bytesAvailable();
      ByteBuffer chunkBuffer=parser.readBytes(bytesAvailable);
      if (bytesAvailable != 0) {
        handler.receiveChunk(this,chunkBuffer);
        return true;
      }
 else {
        return false;
      }
    }
  }
 catch (  NumberFormatException e) {
    return close(e);
  }
catch (  ParseException e) {
    return close(e);
  }
catch (  IOException e) {
    return close(e);
  }
}

Fixed version (ground truth):
/** 
 * Handle a chunk by parsing the contents of the input buffer. If the input buffer does not contain a complete chunk, this will return. If it does contain a chunk: <li>the chunk will be processed <li>if the chunk is empty, the connection will be closed <p>It is possible that the source stream is not chunked, as a consequence of an interfering proxy server. In this case, we arbitrarily form our own chunks which are as large as possible.
 * @return whether the expected data was read fully. This returns false if therewas an insufficient amount of data to satisfy the request.
 */
private boolean handleChunk(){
  try {
    if (sourceChunked) {
      int chunkEndIndex=parser.indexOf("String_Node_Str");
      if (chunkEndIndex == -1)       return false;
      String chunkSizeInHex=parser.readUntil("String_Node_Str",false);
      int chunkSize=Integer.parseInt(chunkSizeInHex,16);
      int bytesRequired=chunkEndIndex + 2 + chunkSize+ 2;
      if (bytesRequired > parser.bytesAvailable()) {
        return false;
      }
      parser.consume("String_Node_Str");
      ByteBuffer chunkBuffer=parser.readBytes(chunkSize);
      parser.consume("String_Node_Str");
      if (chunkSize != 0) {
        handler.receiveChunk(this,chunkBuffer);
        return true;
      }
 else {
        return close();
      }
    }
 else {
      int bytesAvailable=parser.bytesAvailable();
      ByteBuffer chunkBuffer=parser.readBytes(bytesAvailable);
      if (bytesAvailable != 0) {
        handler.receiveChunk(this,chunkBuffer);
        return true;
      }
 else {
        return false;
      }
    }
  }
 catch (  NumberFormatException e) {
    return close(e);
  }
catch (  ParseException e) {
    return close(e);
  }
catch (  IOException e) {
    e.printStackTrace();
    return close(e);
  }
}