Program: 86079
Project: 86079
Buggy source:
@Override protected void doGet(HttpServletRequest pRequest,HttpServletResponse pResponse) throws ServletException, IOException {
  try {
    String login=pRequest.getRemoteUser();
    String[] pathInfos=UploadDownloadServlet.removeEmptyEntries(pRequest.getRequestURI().split("String_Node_Str"));
    int offset;
    if (pRequest.getContextPath().equals("String_Node_Str")) {
      offset=1;
    }
 else {
      offset=2;
    }
    String workspaceId=URLDecoder.decode(pathInfos[offset],"String_Node_Str");
    String elementType=pathInfos[offset + 1];
    String fullName=null;
    if (elementType.equals("String_Node_Str")) {
      String docMId=URLDecoder.decode(pathInfos[offset + 2],"String_Node_Str");
      String docMVersion=pathInfos[offset + 3];
      int iteration=Integer.parseInt(pathInfos[offset + 4]);
      String fileName=URLDecoder.decode(pathInfos[offset + 5],"String_Node_Str");
      fullName=workspaceId + "String_Node_Str" + elementType+ "String_Node_Str"+ docMId+ "String_Node_Str"+ docMVersion+ "String_Node_Str"+ iteration+ "String_Node_Str"+ fileName;
    }
 else     if (elementType.equals("String_Node_Str")) {
      String templateID=URLDecoder.decode(pathInfos[offset + 2],"String_Node_Str");
      String fileName=URLDecoder.decode(pathInfos[offset + 3],"String_Node_Str");
      fullName=workspaceId + "String_Node_Str" + elementType+ "String_Node_Str"+ templateID+ "String_Node_Str"+ fileName;
    }
 else     if (elementType.equals("String_Node_Str")) {
      String partNumber=URLDecoder.decode(pathInfos[offset + 2],"String_Node_Str");
      String version=pathInfos[offset + 3];
      int iteration=Integer.parseInt(pathInfos[offset + 4]);
      String fileName=URLDecoder.decode(pathInfos[offset + 5],"String_Node_Str");
      fullName=workspaceId + "String_Node_Str" + elementType+ "String_Node_Str"+ partNumber+ "String_Node_Str"+ version+ "String_Node_Str"+ iteration+ "String_Node_Str"+ fileName;
    }
    File dataFile=documentService.getDataFile(fullName);
    File fileToOutput;
    if ("String_Node_Str".equals(pRequest.getParameter("String_Node_Str"))) {
      pResponse.setContentType("String_Node_Str");
      String ooHome=getServletContext().getInitParameter("String_Node_Str");
      int ooPort=Integer.parseInt(getServletContext().getInitParameter("String_Node_Str"));
      fileToOutput=new FileConverter(ooHome,ooPort).convertToPDF(dataFile);
    }
 else     if ("String_Node_Str".equals(pRequest.getParameter("String_Node_Str"))) {
      pResponse.setContentType("String_Node_Str");
      String pdf2SWFHome=getServletContext().getInitParameter("String_Node_Str");
      String ooHome=getServletContext().getInitParameter("String_Node_Str");
      int ooPort=Integer.parseInt(getServletContext().getInitParameter("String_Node_Str"));
      FileConverter fileConverter=new FileConverter(pdf2SWFHome,ooHome,ooPort);
      fileToOutput=fileConverter.convertToSWF(dataFile);
    }
 else {
      String contentType=FileTypeMap.getDefaultFileTypeMap().getContentType(dataFile);
      pResponse.setContentType(contentType);
      fileToOutput=dataFile;
    }
    int cacheSeconds=86400;
    pResponse.setHeader("String_Node_Str","String_Node_Str" + cacheSeconds);
    DateFormat httpDateFormat=new SimpleDateFormat("String_Node_Str",Locale.US);
    httpDateFormat.setTimeZone(TimeZone.getTimeZone("String_Node_Str"));
    Calendar cal=new GregorianCalendar();
    cal.add(Calendar.SECOND,cacheSeconds);
    pResponse.setHeader("String_Node_Str",httpDateFormat.format(cal.getTime()));
    pResponse.setHeader("String_Node_Str","String_Node_Str");
    pResponse.setContentLength((int)fileToOutput.length());
    ServletOutputStream httpOut=pResponse.getOutputStream();
    InputStream input=new BufferedInputStream(new FileInputStream(fileToOutput),BUFFER_CAPACITY);
    byte[] data=new byte[CHUNK_SIZE];
    int length;
    while ((length=input.read(data)) != -1) {
      httpOut.write(data,0,length);
    }
    input.close();
    httpOut.flush();
    httpOut.close();
  }
 catch (  Exception pEx) {
    throw new ServletException("String_Node_Str",pEx);
  }
}

Fixed version (ground truth):
@Override protected void doGet(HttpServletRequest pRequest,HttpServletResponse pResponse) throws ServletException, IOException {
  try {
    String login=pRequest.getRemoteUser();
    String[] pathInfos=UploadDownloadServlet.removeEmptyEntries(pRequest.getRequestURI().split("String_Node_Str"));
    int offset;
    if (pRequest.getContextPath().equals("String_Node_Str")) {
      offset=1;
    }
 else {
      offset=2;
    }
    String workspaceId=URLDecoder.decode(pathInfos[offset],"String_Node_Str");
    String elementType=pathInfos[offset + 1];
    String fullName=null;
    if (elementType.equals("String_Node_Str")) {
      setCacheHeaders(86400,pResponse);
      String docMId=URLDecoder.decode(pathInfos[offset + 2],"String_Node_Str");
      String docMVersion=pathInfos[offset + 3];
      int iteration=Integer.parseInt(pathInfos[offset + 4]);
      String fileName=URLDecoder.decode(pathInfos[offset + 5],"String_Node_Str");
      fullName=workspaceId + "String_Node_Str" + elementType+ "String_Node_Str"+ docMId+ "String_Node_Str"+ docMVersion+ "String_Node_Str"+ iteration+ "String_Node_Str"+ fileName;
    }
 else     if (elementType.equals("String_Node_Str")) {
      String templateID=URLDecoder.decode(pathInfos[offset + 2],"String_Node_Str");
      String fileName=URLDecoder.decode(pathInfos[offset + 3],"String_Node_Str");
      fullName=workspaceId + "String_Node_Str" + elementType+ "String_Node_Str"+ templateID+ "String_Node_Str"+ fileName;
    }
 else     if (elementType.equals("String_Node_Str")) {
      setCacheHeaders(86400,pResponse);
      String partNumber=URLDecoder.decode(pathInfos[offset + 2],"String_Node_Str");
      String version=pathInfos[offset + 3];
      int iteration=Integer.parseInt(pathInfos[offset + 4]);
      String fileName=URLDecoder.decode(pathInfos[offset + 5],"String_Node_Str");
      fullName=workspaceId + "String_Node_Str" + elementType+ "String_Node_Str"+ partNumber+ "String_Node_Str"+ version+ "String_Node_Str"+ iteration+ "String_Node_Str"+ fileName;
    }
    File dataFile=documentService.getDataFile(fullName);
    File fileToOutput;
    if ("String_Node_Str".equals(pRequest.getParameter("String_Node_Str"))) {
      pResponse.setContentType("String_Node_Str");
      String ooHome=getServletContext().getInitParameter("String_Node_Str");
      int ooPort=Integer.parseInt(getServletContext().getInitParameter("String_Node_Str"));
      fileToOutput=new FileConverter(ooHome,ooPort).convertToPDF(dataFile);
    }
 else     if ("String_Node_Str".equals(pRequest.getParameter("String_Node_Str"))) {
      pResponse.setContentType("String_Node_Str");
      String pdf2SWFHome=getServletContext().getInitParameter("String_Node_Str");
      String ooHome=getServletContext().getInitParameter("String_Node_Str");
      int ooPort=Integer.parseInt(getServletContext().getInitParameter("String_Node_Str"));
      FileConverter fileConverter=new FileConverter(pdf2SWFHome,ooHome,ooPort);
      fileToOutput=fileConverter.convertToSWF(dataFile);
    }
 else {
      String contentType=FileTypeMap.getDefaultFileTypeMap().getContentType(dataFile);
      pResponse.setContentType(contentType);
      fileToOutput=dataFile;
    }
    long lastModified=fileToOutput.lastModified();
    long ifModified=pRequest.getDateHeader("String_Node_Str");
    setLastModifiedHeaders(lastModified,pResponse);
    if (lastModified > ifModified) {
      pResponse.setContentLength((int)fileToOutput.length());
      ServletOutputStream httpOut=pResponse.getOutputStream();
      InputStream input=new BufferedInputStream(new FileInputStream(fileToOutput),BUFFER_CAPACITY);
      byte[] data=new byte[CHUNK_SIZE];
      int length;
      while ((length=input.read(data)) != -1) {
        httpOut.write(data,0,length);
      }
      input.close();
      httpOut.flush();
      httpOut.close();
    }
 else {
      pResponse.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
    }
  }
 catch (  Exception pEx) {
    throw new ServletException("String_Node_Str",pEx);
  }
}