Program: 52238
Project: 52238
Buggy source:
/** 
 * Process a post request.
 */
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  Deposit d=new Deposit();
  Date date=new Date();
  log.debug("String_Node_Str" + date.toString() + "String_Node_Str"+ request.getRemoteAddr());
  String usernamePassword=getUsernamePassword(request);
  if ((usernamePassword != null) && (!usernamePassword.equals("String_Node_Str"))) {
    int p=usernamePassword.indexOf("String_Node_Str");
    if (p != -1) {
      d.setUsername(usernamePassword.substring(0,p));
      d.setPassword(usernamePassword.substring(p + 1));
    }
  }
 else   if (authenticateWithBasic()) {
    String s="String_Node_Str";
    response.setHeader("String_Node_Str",s);
    response.setStatus(401);
    return;
  }
  String filename=null;
  File f=null;
  FileInputStream fis=null;
  try {
    filename=tempDirectory + "String_Node_Str" + request.getRemoteAddr()+ "String_Node_Str"+ counter.addAndGet(1);
    InputStream inputStream=request.getInputStream();
    OutputStream outputStream=new FileOutputStream(filename);
    int data;
    while ((data=inputStream.read()) != -1) {
      outputStream.write(data);
    }
    inputStream.close();
    outputStream.close();
    File file=new File(filename);
    long fLength=file.length() / 1024;
    if ((maxUploadSize != -1) && (fLength > maxUploadSize)) {
      this.makeErrorDocument(ErrorCodes.MAX_UPLOAD_SIZE_EXCEEDED,HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE,"String_Node_Str" + fLength + "String_Node_Str"+ maxUploadSize+ "String_Node_Str",request,response);
      return;
    }
    String receivedMD5=ChecksumUtils.generateMD5(filename);
    log.debug("String_Node_Str" + receivedMD5);
    d.setMd5(receivedMD5);
    String md5=request.getHeader("String_Node_Str");
    log.debug("String_Node_Str" + md5);
    if ((md5 != null) && (!md5.equals(receivedMD5))) {
      this.makeErrorDocument(ErrorCodes.ERROR_CHECKSUM_MISMATCH,HttpServletResponse.SC_PRECONDITION_FAILED,"String_Node_Str",request,response);
      log.debug("String_Node_Str");
      return;
    }
 else {
      f=new File(filename);
      fis=new FileInputStream(f);
      d.setFile(fis);
      String onBehalfOf=request.getHeader(HttpHeaders.X_ON_BEHALF_OF.toString());
      if ((onBehalfOf != null) && (onBehalfOf.equals("String_Node_Str"))) {
        throw new SWORDErrorException(ErrorCodes.TARGET_OWNER_UKNOWN,"String_Node_Str");
      }
 else {
        d.setOnBehalfOf(onBehalfOf);
      }
      d.setPackaging(request.getHeader(HttpHeaders.X_PACKAGING));
      String noop=request.getHeader(HttpHeaders.X_NO_OP);
      log.error("String_Node_Str" + noop);
      if ((noop != null) && (noop.equals("String_Node_Str"))) {
        d.setNoOp(true);
      }
 else       if ((noop != null) && (noop.equals("String_Node_Str"))) {
        d.setNoOp(false);
      }
 else       if (noop == null) {
        d.setNoOp(false);
      }
 else {
        throw new SWORDErrorException(ErrorCodes.ERROR_BAD_REQUEST,"String_Node_Str");
      }
      String verbose=request.getHeader(HttpHeaders.X_VERBOSE);
      if ((verbose != null) && (verbose.equals("String_Node_Str"))) {
        d.setVerbose(true);
      }
 else       if ((verbose != null) && (verbose.equals("String_Node_Str"))) {
        d.setVerbose(false);
      }
 else       if (verbose == null) {
        d.setVerbose(false);
      }
 else {
        throw new SWORDErrorException(ErrorCodes.ERROR_BAD_REQUEST,"String_Node_Str");
      }
      String slug=request.getHeader(HttpHeaders.SLUG);
      if (slug != null) {
        d.setSlug(slug);
      }
      d.setContentDisposition(request.getHeader(HttpHeaders.CONTENT_DISPOSITION));
      d.setIPAddress(request.getRemoteAddr());
      d.setLocation(getUrl(request));
      d.setContentType(request.getContentType());
      String cl=request.getHeader(HttpHeaders.CONTENT_LENGTH);
      if ((cl != null) && (!cl.equals("String_Node_Str"))) {
        d.setContentLength(Integer.parseInt(cl));
      }
      DepositResponse dr=myRepository.doDeposit(d);
      if (request.getHeader(HttpHeaders.USER_AGENT.toString()) != null) {
        dr.getEntry().setUserAgent(request.getHeader(HttpHeaders.USER_AGENT.toString()));
      }
      if (request.getHeader(HttpHeaders.X_PACKAGING.toString()) != null) {
        dr.getEntry().setPackaging(request.getHeader(HttpHeaders.X_PACKAGING.toString()));
      }
      response.setStatus(dr.getHttpResponse());
      if ((dr.getLocation() != null) && (!dr.getLocation().equals("String_Node_Str"))) {
        response.setHeader("String_Node_Str",dr.getLocation());
      }
      response.setContentType("String_Node_Str");
      PrintWriter out=response.getWriter();
      out.write(dr.marshall());
      out.flush();
    }
  }
 catch (  SWORDAuthenticationException sae) {
    if (authN.equals("String_Node_Str")) {
      String s="String_Node_Str";
      response.setHeader("String_Node_Str",s);
      response.setStatus(401);
    }
  }
catch (  SWORDErrorException see) {
    log.error(see.toString());
    this.makeErrorDocument(see.getErrorURI(),see.getStatus(),see.getDescription(),request,response);
    return;
  }
catch (  SWORDException se) {
    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    log.error(se.toString());
  }
catch (  NoSuchAlgorithmException nsae) {
    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    log.error(nsae.toString());
  }
 finally {
    if (fis != null) {
      fis.close();
    }
    if (filename != null) {
      f=new File(filename);
      f.delete();
    }
  }
}

Fixed version (ground truth):
/** 
 * Process a post request.
 */
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  Deposit d=new Deposit();
  Date date=new Date();
  log.debug("String_Node_Str" + date.toString() + "String_Node_Str"+ request.getRemoteAddr());
  String usernamePassword=getUsernamePassword(request);
  if ((usernamePassword != null) && (!usernamePassword.equals("String_Node_Str"))) {
    int p=usernamePassword.indexOf("String_Node_Str");
    if (p != -1) {
      d.setUsername(usernamePassword.substring(0,p));
      d.setPassword(usernamePassword.substring(p + 1));
    }
  }
 else   if (authenticateWithBasic()) {
    String s="String_Node_Str";
    response.setHeader("String_Node_Str",s);
    response.setStatus(401);
    return;
  }
  String filename=null;
  File f=null;
  FileInputStream fis=null;
  try {
    filename=tempDirectory + "String_Node_Str" + request.getRemoteAddr()+ "String_Node_Str"+ counter.addAndGet(1);
    InputStream inputStream=request.getInputStream();
    OutputStream outputStream=new FileOutputStream(filename);
    try {
      int data;
      while ((data=inputStream.read()) != -1) {
        outputStream.write(data);
      }
    }
  finally {
      inputStream.close();
      outputStream.close();
    }
    File file=new File(filename);
    long fLength=file.length() / 1024;
    if ((maxUploadSize != -1) && (fLength > maxUploadSize)) {
      this.makeErrorDocument(ErrorCodes.MAX_UPLOAD_SIZE_EXCEEDED,HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE,"String_Node_Str" + fLength + "String_Node_Str"+ maxUploadSize+ "String_Node_Str",request,response);
      return;
    }
    String receivedMD5=ChecksumUtils.generateMD5(filename);
    log.debug("String_Node_Str" + receivedMD5);
    d.setMd5(receivedMD5);
    String md5=request.getHeader("String_Node_Str");
    log.debug("String_Node_Str" + md5);
    if ((md5 != null) && (!md5.equals(receivedMD5))) {
      this.makeErrorDocument(ErrorCodes.ERROR_CHECKSUM_MISMATCH,HttpServletResponse.SC_PRECONDITION_FAILED,"String_Node_Str",request,response);
      log.debug("String_Node_Str");
      return;
    }
 else {
      f=new File(filename);
      fis=new FileInputStream(f);
      d.setFile(fis);
      String onBehalfOf=request.getHeader(HttpHeaders.X_ON_BEHALF_OF.toString());
      if ((onBehalfOf != null) && (onBehalfOf.equals("String_Node_Str"))) {
        throw new SWORDErrorException(ErrorCodes.TARGET_OWNER_UKNOWN,"String_Node_Str");
      }
 else {
        d.setOnBehalfOf(onBehalfOf);
      }
      d.setPackaging(request.getHeader(HttpHeaders.X_PACKAGING));
      String noop=request.getHeader(HttpHeaders.X_NO_OP);
      log.error("String_Node_Str" + noop);
      if ((noop != null) && (noop.equals("String_Node_Str"))) {
        d.setNoOp(true);
      }
 else       if ((noop != null) && (noop.equals("String_Node_Str"))) {
        d.setNoOp(false);
      }
 else       if (noop == null) {
        d.setNoOp(false);
      }
 else {
        throw new SWORDErrorException(ErrorCodes.ERROR_BAD_REQUEST,"String_Node_Str");
      }
      String verbose=request.getHeader(HttpHeaders.X_VERBOSE);
      if ((verbose != null) && (verbose.equals("String_Node_Str"))) {
        d.setVerbose(true);
      }
 else       if ((verbose != null) && (verbose.equals("String_Node_Str"))) {
        d.setVerbose(false);
      }
 else       if (verbose == null) {
        d.setVerbose(false);
      }
 else {
        throw new SWORDErrorException(ErrorCodes.ERROR_BAD_REQUEST,"String_Node_Str");
      }
      String slug=request.getHeader(HttpHeaders.SLUG);
      if (slug != null) {
        d.setSlug(slug);
      }
      d.setContentDisposition(request.getHeader(HttpHeaders.CONTENT_DISPOSITION));
      d.setIPAddress(request.getRemoteAddr());
      d.setLocation(getUrl(request));
      d.setContentType(request.getContentType());
      String cl=request.getHeader(HttpHeaders.CONTENT_LENGTH);
      if ((cl != null) && (!cl.equals("String_Node_Str"))) {
        d.setContentLength(Integer.parseInt(cl));
      }
      DepositResponse dr=myRepository.doDeposit(d);
      if (request.getHeader(HttpHeaders.USER_AGENT.toString()) != null) {
        dr.getEntry().setUserAgent(request.getHeader(HttpHeaders.USER_AGENT.toString()));
      }
      if (request.getHeader(HttpHeaders.X_PACKAGING.toString()) != null) {
        dr.getEntry().setPackaging(request.getHeader(HttpHeaders.X_PACKAGING.toString()));
      }
      response.setStatus(dr.getHttpResponse());
      if ((dr.getLocation() != null) && (!dr.getLocation().equals("String_Node_Str"))) {
        response.setHeader("String_Node_Str",dr.getLocation());
      }
      response.setContentType("String_Node_Str");
      PrintWriter out=response.getWriter();
      out.write(dr.marshall());
      out.flush();
    }
  }
 catch (  SWORDAuthenticationException sae) {
    if (authN.equals("String_Node_Str")) {
      String s="String_Node_Str";
      response.setHeader("String_Node_Str",s);
      response.setStatus(401);
    }
  }
catch (  SWORDErrorException see) {
    log.error(see.toString());
    this.makeErrorDocument(see.getErrorURI(),see.getStatus(),see.getDescription(),request,response);
    return;
  }
catch (  SWORDException se) {
    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    log.error(se.toString());
  }
catch (  NoSuchAlgorithmException nsae) {
    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    log.error(nsae.toString());
  }
 finally {
    if (fis != null) {
      fis.close();
    }
    if (filename != null) {
      f=new File(filename);
      f.delete();
    }
  }
}