#vulnerable code 
                              protected AlgorithmExecutor buildExecutor(String executionIdentifier)
      throws FileNotFoundException, UnsupportedEncodingException {
    ResultPrinter resultPrinter = new ResultPrinter(executionIdentifier, "results");
    ResultsCache resultsCache = new ResultsCache();
    ResultsHub resultsHub = new ResultsHub();
    resultsHub.addSubscriber(resultPrinter);
    resultsHub.addSubscriber(resultsCache);

    FileGenerator fileGenerator = new TempFileGenerator();
    ProgressCache progressCache = new ProgressCache();

    AlgorithmExecutor executor = new AlgorithmExecutor(resultsHub, progressCache, fileGenerator);
    AlgorithmExecutionCache.add(executionIdentifier, resultsCache, progressCache);

    return executor;
  } 
                            #location 6 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                              protected AlgorithmExecutor buildExecutor(String executionIdentifier)
      throws FileNotFoundException, UnsupportedEncodingException {
    ResultPrinter resultPrinter = new ResultPrinter(executionIdentifier);
    ResultsCache resultsCache = new ResultsCache();
    ResultsHub resultsHub = new ResultsHub();
    resultsHub.addSubscriber(resultPrinter);
    resultsHub.addSubscriber(resultsCache);

    FileGenerator fileGenerator = new TempFileGenerator();
    ProgressCache progressCache = new ProgressCache();

    AlgorithmExecutor executor = new AlgorithmExecutor(resultsHub, progressCache, fileGenerator);
    executor.setResultPathPrefix(resultPrinter.getOutputFilePathPrefix());
    AlgorithmExecutionCache.add(executionIdentifier, resultsCache, progressCache);

    return executor;
  }