Program: 41525
Project: 41525
Buggy source:
private Response storeCSAR(String fileName,InputStream uploadedInputStream){
  File tmpDir=new File(System.getProperty("String_Node_Str") + System.getProperty("String_Node_Str") + Long.toString(System.currentTimeMillis()));
  tmpDir.mkdir();
  File uploadFile=new File(tmpDir.getAbsoluteFile() + System.getProperty("String_Node_Str") + fileName);
  OutputStream out;
  try {
    out=new FileOutputStream(uploadFile);
    int read=0;
    byte[] bytes=new byte[1024];
    while ((read=uploadedInputStream.read(bytes)) != -1) {
      out.write(bytes,0,read);
    }
    uploadedInputStream.close();
    CSARsResource.LOG.debug("String_Node_Str" + uploadFile.getAbsolutePath() + "String_Node_Str"+ uploadFile.getTotalSpace());
    out.flush();
    out.close();
    CSARID csarID=null;
    csarID=fileHandler.storeCSAR(uploadFile.toPath());
    csarID=startPlanBuilder(csarID);
    if (csarID != null) {
      CSARsResource.LOG.info("String_Node_Str",csarID.toString());
      CSARsResource.LOG.trace("String_Node_Str" + (null != control));
      control.setDeploymentProcessStateStored(csarID);
      if (control.invokeTOSCAProcessing(csarID)) {
        List<QName> serviceTemplates=ToscaServiceHandler.getToscaEngineService().getToscaReferenceMapper().getServiceTemplateIDsContainedInCSAR(csarID);
        for (        QName serviceTemplate : serviceTemplates) {
          CSARsResource.LOG.debug("String_Node_Str" + serviceTemplate + "String_Node_Str"+ csarID+ "String_Node_Str");
          if (!control.invokeIADeployment(csarID,serviceTemplate)) {
            break;
          }
          CSARsResource.LOG.debug("String_Node_Str" + serviceTemplate + "String_Node_Str"+ csarID+ "String_Node_Str");
          CSARsResource.LOG.debug("String_Node_Str");
          if (!control.invokePlanDeployment(csarID,serviceTemplate)) {
            break;
          }
        }
        return Response.created(URI.create(Utilities.buildURI(uriInfo.getAbsolutePath().toString(),csarID.toString()))).build();
      }
    }
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
catch (  UserException e) {
    e.printStackTrace();
  }
catch (  SystemException e) {
    e.printStackTrace();
  }
  CSARsResource.LOG.error("String_Node_Str",uploadFile.getAbsolutePath());
  return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}

Fixed version (ground truth):
private Response storeCSAR(String fileName,InputStream uploadedInputStream){
  File tmpDir=FileAccessServiceHandler.getFileAccessService().getTemp();
  tmpDir.mkdir();
  File uploadFile=new File(tmpDir.getAbsoluteFile() + System.getProperty("String_Node_Str") + fileName);
  OutputStream out;
  try {
    out=new FileOutputStream(uploadFile);
    int read=0;
    byte[] bytes=new byte[1024];
    while ((read=uploadedInputStream.read(bytes)) != -1) {
      out.write(bytes,0,read);
    }
    uploadedInputStream.close();
    CSARsResource.LOG.debug("String_Node_Str" + uploadFile.getAbsolutePath() + "String_Node_Str"+ uploadFile.getTotalSpace());
    out.flush();
    out.close();
    CSARID csarID=null;
    csarID=fileHandler.storeCSAR(uploadFile.toPath());
    csarID=startPlanBuilder(csarID);
    if (csarID != null) {
      CSARsResource.LOG.info("String_Node_Str",csarID.toString());
      CSARsResource.LOG.trace("String_Node_Str" + (null != control));
      control.setDeploymentProcessStateStored(csarID);
      if (control.invokeTOSCAProcessing(csarID)) {
        List<QName> serviceTemplates=ToscaServiceHandler.getToscaEngineService().getToscaReferenceMapper().getServiceTemplateIDsContainedInCSAR(csarID);
        for (        QName serviceTemplate : serviceTemplates) {
          CSARsResource.LOG.debug("String_Node_Str" + serviceTemplate + "String_Node_Str"+ csarID+ "String_Node_Str");
          if (!control.invokeIADeployment(csarID,serviceTemplate)) {
            break;
          }
          CSARsResource.LOG.debug("String_Node_Str" + serviceTemplate + "String_Node_Str"+ csarID+ "String_Node_Str");
          CSARsResource.LOG.debug("String_Node_Str");
          if (!control.invokePlanDeployment(csarID,serviceTemplate)) {
            break;
          }
        }
        return Response.created(URI.create(Utilities.buildURI(uriInfo.getAbsolutePath().toString(),csarID.toString()))).build();
      }
    }
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
catch (  UserException e) {
    e.printStackTrace();
  }
catch (  SystemException e) {
    e.printStackTrace();
  }
  CSARsResource.LOG.error("String_Node_Str",uploadFile.getAbsolutePath());
  return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}