Program: 82826
Project: 82826
Buggy source:
/** 
 * Returns the content of an   {@link HttpServletRequest} by decoding it usingthe UTF-8 charset.
 * @param request the servlet request whose content we want to read
 * @return the content of an {@link HttpServletRequest} by decoding it usingthe UTF-8 charset
 * @throws IOException if the requests input stream cannot be accessed, readfrom or closed
 * @throws ServletException if the content length of the request is notspecified of if the request's content type is not 'text/x-gwt-rpc' and 'charset=utf-8'
 */
public static String readContentAsUtf8(HttpServletRequest request) throws IOException, ServletException {
  int contentLength=request.getContentLength();
  if (contentLength == -1) {
    throw new ServletException("String_Node_Str");
  }
  String contentType=request.getContentType();
  boolean contentTypeIsOkay=false;
  if (contentType != null) {
    contentType=contentType.toLowerCase();
    if (contentType.startsWith(EXPECTED_CONTENT_TYPE)) {
      if (contentType.indexOf(EXPECTED_CHARSET) != -1) {
        contentTypeIsOkay=true;
      }
    }
  }
  if (!contentTypeIsOkay) {
    throw new ServletException("String_Node_Str" + EXPECTED_CONTENT_TYPE + "String_Node_Str"+ EXPECTED_CHARSET+ "String_Node_Str");
  }
  InputStream in=request.getInputStream();
  try {
    byte[] payload=new byte[contentLength];
    int offset=0;
    int len=contentLength;
    int byteCount;
    while (offset < contentLength) {
      byteCount=in.read(payload,offset,len);
      if (byteCount == -1) {
        throw new ServletException("String_Node_Str" + contentLength + "String_Node_Str");
      }
      offset+=byteCount;
      len-=byteCount;
    }
    return new String(payload,CHARSET_UTF8);
  }
  finally {
    if (in != null) {
      in.close();
    }
  }
}

Fixed version (ground truth):
/** 
 * Returns the content of an   {@link HttpServletRequest} by decoding it usingthe UTF-8 charset.
 * @param request the servlet request whose content we want to read
 * @return the content of an {@link HttpServletRequest} by decoding it usingthe UTF-8 charset
 * @throws IOException if the requests input stream cannot be accessed, readfrom or closed
 * @throws ServletException if the content length of the request is notspecified of if the request's content type is not 'text/x-gwt-rpc' and 'charset=utf-8'
 */
public static String readContentAsUtf8(HttpServletRequest request) throws IOException, ServletException {
  int contentLength=request.getContentLength();
  if (contentLength == -1) {
    throw new ServletException("String_Node_Str");
  }
  String contentType=request.getContentType();
  boolean contentTypeIsOkay=false;
  if (contentType != null) {
    contentType=contentType.toLowerCase();
    if (contentType.startsWith(EXPECTED_CONTENT_TYPE)) {
      String characterEncoding=request.getCharacterEncoding();
      if (characterEncoding != null) {
        if (characterEncoding.toLowerCase().indexOf(CHARSET_UTF8.toLowerCase()) != -1) {
          contentTypeIsOkay=true;
        }
      }
    }
  }
  if (!contentTypeIsOkay) {
    throw new ServletException("String_Node_Str" + EXPECTED_CONTENT_TYPE + "String_Node_Str"+ EXPECTED_CHARSET+ "String_Node_Str");
  }
  InputStream in=request.getInputStream();
  try {
    byte[] payload=new byte[contentLength];
    int offset=0;
    int len=contentLength;
    int byteCount;
    while (offset < contentLength) {
      byteCount=in.read(payload,offset,len);
      if (byteCount == -1) {
        throw new ServletException("String_Node_Str" + contentLength + "String_Node_Str");
      }
      offset+=byteCount;
      len-=byteCount;
    }
    return new String(payload,CHARSET_UTF8);
  }
  finally {
    if (in != null) {
      in.close();
    }
  }
}