Program: 51462
Project: 51462
Buggy source:
public void createReportContent(final OutputStream outputStream,final Serializable fileId,final String path,final boolean forceDefaultOutputTarget) throws Exception {
  final long start=System.currentTimeMillis();
  final Map<String,Object> inputs=contentGenerator.createInputs();
  String objID=getObjectIdFromContent(fileId);
  AuditHelper.audit(userSession.getId(),userSession.getName(),objID,contentGenerator.getObjectName(),getClass().getName(),MessageTypes.INSTANCE_START,contentGenerator.getInstanceId(),"String_Node_Str",0,contentGenerator);
  String result=MessageTypes.INSTANCE_END;
  StagingHandler reportStagingHandler=null;
  try {
    final Object rawSessionId=inputs.get(ParameterXmlContentHandler.SYS_PARAM_SESSION_ID);
    if ((rawSessionId instanceof String) == false || "String_Node_Str".equals(rawSessionId)) {
      inputs.put(ParameterXmlContentHandler.SYS_PARAM_SESSION_ID,UUIDUtil.getUUIDAsString());
    }
    final SimpleReportingComponent reportComponent=new SimpleReportingComponent();
    reportComponent.setReportFileId(fileId);
    reportComponent.setPaginateOutput(true);
    reportComponent.setForceDefaultOutputTarget(forceDefaultOutputTarget);
    reportComponent.setDefaultOutputTarget(HtmlTableModule.TABLE_HTML_PAGE_EXPORT_TYPE);
    if (path.endsWith("String_Node_Str")) {
      reportComponent.setForceUnlockPreferredOutput(true);
    }
    reportComponent.setInputs(inputs);
    final MasterReport report=reportComponent.getReport();
    final StagingMode stagingMode=getStagingMode(inputs,report);
    reportStagingHandler=new StagingHandler(outputStream,stagingMode,this.userSession);
    if (reportStagingHandler.isFullyBuffered()) {
      report.getReportConfiguration().setConfigProperty(FORCED_BUFFERED_WRITING,"String_Node_Str");
    }
    reportComponent.setOutputStream(reportStagingHandler.getStagingOutputStream());
    final IUnifiedRepository repository=PentahoSystem.get(IUnifiedRepository.class,userSession);
    final RepositoryFile file=repository.getFileById(fileId);
    final String mimeType=reportComponent.getMimeType();
    final String outputTarget=reportComponent.getComputedOutputTarget();
    if (HtmlTableModule.TABLE_HTML_PAGE_EXPORT_TYPE.equals(outputTarget) && reportComponent.getAcceptedPage() < 0) {
      reportComponent.setAcceptedPage(0);
    }
    if (logger.isDebugEnabled()) {
      logger.debug(Messages.getInstance().getString("String_Node_Str",mimeType,outputTarget,String.valueOf(reportComponent.getAcceptedPage())));
    }
    HttpServletResponse response=null;
    boolean streamToBrowser=false;
    final IParameterProvider pathProviders=contentGenerator.getParameterProviders().get("String_Node_Str");
    if (pathProviders != null) {
      final Object httpResponse=pathProviders.getParameter("String_Node_Str");
      if (httpResponse instanceof HttpServletResponse) {
        response=(HttpServletResponse)httpResponse;
        if (reportStagingHandler.getStagingMode() == StagingMode.THRU) {
          final OutputStream respOutputStream=response.getOutputStream();
          if (respOutputStream == outputStream) {
            streamToBrowser=true;
          }
        }
      }
    }
    final String extension=MimeHelper.getExtension(mimeType);
    String filename=file.getName();
    if (filename.lastIndexOf("String_Node_Str") != -1) {
      filename=filename.substring(0,filename.lastIndexOf("String_Node_Str"));
    }
    String disposition="String_Node_Str" + URLEncoder.encode(filename,"String_Node_Str") + extension;
    final boolean validates=reportComponent.validate();
    if (!validates) {
      sendErrorResponse(response,outputStream,reportStagingHandler);
    }
 else {
      if (response != null) {
        response.setHeader("String_Node_Str",disposition);
        response.setHeader("String_Node_Str",file.getName());
        response.setHeader("String_Node_Str","String_Node_Str");
      }
      if (reportComponent.execute()) {
        if (response != null) {
          if (reportStagingHandler.canSendHeaders()) {
            response.setHeader("String_Node_Str",disposition);
            response.setHeader("String_Node_Str",file.getName());
            response.setHeader("String_Node_Str","String_Node_Str");
            response.setContentLength(reportStagingHandler.getWrittenByteCount());
          }
        }
        if (logger.isDebugEnabled()) {
          logger.debug(Messages.getInstance().getString("String_Node_Str",String.valueOf(reportStagingHandler.getWrittenByteCount())));
        }
        reportStagingHandler.complete();
      }
 else {
        sendErrorResponse(response,outputStream,reportStagingHandler);
      }
    }
  }
 catch (  Exception ex) {
    result=MessageTypes.INSTANCE_FAILED;
    throw ex;
  }
 finally {
    if (reportStagingHandler != null) {
      reportStagingHandler.close();
    }
    final long end=System.currentTimeMillis();
    AuditHelper.audit(userSession.getId(),userSession.getName(),objID,contentGenerator.getObjectName(),getClass().getName(),result,contentGenerator.getInstanceId(),"String_Node_Str",((float)(end - start) / 1000),contentGenerator);
  }
}

Fixed version (ground truth):
public void createReportContent(final OutputStream outputStream,final Serializable fileId,final String path,final boolean forceDefaultOutputTarget) throws Exception {
  final long start=System.currentTimeMillis();
  final Map<String,Object> inputs=contentGenerator.createInputs();
  String objID=getObjectIdFromContent(fileId);
  AuditHelper.audit(userSession.getId(),userSession.getName(),objID,contentGenerator.getObjectName(),getClass().getName(),MessageTypes.INSTANCE_START,contentGenerator.getInstanceId(),"String_Node_Str",0,contentGenerator);
  String result=MessageTypes.INSTANCE_END;
  StagingHandler reportStagingHandler=null;
  try {
    final Object rawSessionId=inputs.get(ParameterXmlContentHandler.SYS_PARAM_SESSION_ID);
    if ((rawSessionId instanceof String) == false || "String_Node_Str".equals(rawSessionId)) {
      inputs.put(ParameterXmlContentHandler.SYS_PARAM_SESSION_ID,UUIDUtil.getUUIDAsString());
    }
    final SimpleReportingComponent reportComponent=new SimpleReportingComponent();
    reportComponent.setReportFileId(fileId);
    reportComponent.setPaginateOutput(true);
    reportComponent.setForceDefaultOutputTarget(forceDefaultOutputTarget);
    reportComponent.setDefaultOutputTarget(HtmlTableModule.TABLE_HTML_PAGE_EXPORT_TYPE);
    if (path.endsWith("String_Node_Str")) {
      reportComponent.setForceUnlockPreferredOutput(true);
    }
    reportComponent.setInputs(inputs);
    final MasterReport report=reportComponent.getReport();
    final StagingMode stagingMode=getStagingMode(inputs,report);
    reportStagingHandler=new StagingHandler(outputStream,stagingMode,this.userSession);
    if (reportStagingHandler.isFullyBuffered()) {
      report.getReportConfiguration().setConfigProperty(FORCED_BUFFERED_WRITING,"String_Node_Str");
    }
    reportComponent.setOutputStream(reportStagingHandler.getStagingOutputStream());
    final IUnifiedRepository repository=PentahoSystem.get(IUnifiedRepository.class,userSession);
    final RepositoryFile file=repository.getFileById(fileId);
    final String mimeType=reportComponent.getMimeType();
    final String outputTarget=reportComponent.getComputedOutputTarget();
    if (HtmlTableModule.TABLE_HTML_PAGE_EXPORT_TYPE.equals(outputTarget) && reportComponent.getAcceptedPage() < 0) {
      reportComponent.setAcceptedPage(0);
    }
    if (logger.isDebugEnabled()) {
      logger.debug(Messages.getInstance().getString("String_Node_Str",mimeType,outputTarget,String.valueOf(reportComponent.getAcceptedPage())));
    }
    HttpServletResponse response=null;
    boolean streamToBrowser=false;
    final IParameterProvider pathProviders=contentGenerator.getParameterProviders().get("String_Node_Str");
    if (pathProviders != null) {
      final Object httpResponse=pathProviders.getParameter("String_Node_Str");
      if (httpResponse instanceof HttpServletResponse) {
        response=(HttpServletResponse)httpResponse;
        if (reportStagingHandler.getStagingMode() == StagingMode.THRU) {
          final OutputStream respOutputStream=response.getOutputStream();
          if (respOutputStream == outputStream) {
            streamToBrowser=true;
          }
        }
      }
    }
    final String extension=MimeHelper.getExtension(mimeType);
    String filename=file.getName();
    if (filename.lastIndexOf("String_Node_Str") != -1) {
      filename=filename.substring(0,filename.lastIndexOf("String_Node_Str"));
    }
    String disposition="String_Node_Str" + RepositoryPathEncoder.encode(RepositoryPathEncoder.encodeRepositoryPath(filename + extension));
    final boolean validates=reportComponent.validate();
    if (!validates) {
      sendErrorResponse(response,outputStream,reportStagingHandler);
    }
 else {
      if (response != null) {
        response.setHeader("String_Node_Str",disposition);
        response.setHeader("String_Node_Str",file.getName());
        response.setHeader("String_Node_Str","String_Node_Str");
      }
      if (reportComponent.execute()) {
        if (response != null) {
          if (reportStagingHandler.canSendHeaders()) {
            response.setHeader("String_Node_Str",disposition);
            response.setHeader("String_Node_Str",file.getName());
            response.setHeader("String_Node_Str","String_Node_Str");
            response.setContentLength(reportStagingHandler.getWrittenByteCount());
          }
        }
        if (logger.isDebugEnabled()) {
          logger.debug(Messages.getInstance().getString("String_Node_Str",String.valueOf(reportStagingHandler.getWrittenByteCount())));
        }
        reportStagingHandler.complete();
      }
 else {
        sendErrorResponse(response,outputStream,reportStagingHandler);
      }
    }
  }
 catch (  Exception ex) {
    result=MessageTypes.INSTANCE_FAILED;
    throw ex;
  }
 finally {
    if (reportStagingHandler != null) {
      reportStagingHandler.close();
    }
    final long end=System.currentTimeMillis();
    AuditHelper.audit(userSession.getId(),userSession.getName(),objID,contentGenerator.getObjectName(),getClass().getName(),result,contentGenerator.getInstanceId(),"String_Node_Str",((float)(end - start) / 1000),contentGenerator);
  }
}