Program: 30003
Project: 30003
Buggy source:
private static void retrieveArtifacts(final AdminCommandContext context,final Collection<Artifacts.FullAndPartURIs> artifactInfo,final String targetLocalDir,final boolean reportErrorsInTopReport){
  Logger logger=context.getLogger();
  try {
    Payload.Outbound outboundPayload=context.getOutboundPayload();
    boolean retrieveArtifacts=false;
    if (outboundPayload == null) {
      outboundPayload=PayloadImpl.Outbound.newInstance();
      retrieveArtifacts=true;
    }
    Properties props=new Properties();
    props.setProperty("String_Node_Str",targetLocalDir.replace('\\','/'));
    for (    Artifacts.FullAndPartURIs uriPair : artifactInfo) {
      if (logger.isLoggable(Level.FINE)) {
        logger.log(Level.FINE,"String_Node_Str",uriPair.getFull());
      }
      outboundPayload.attachFile("String_Node_Str",uriPair.getPart(),"String_Node_Str",props,new File(uriPair.getFull().getSchemeSpecificPart()));
    }
    if (retrieveArtifacts) {
      File targetLocalFile=new File(targetLocalDir);
      if (targetLocalFile.exists()) {
        final String msg=localStrings.getLocalString("String_Node_Str","String_Node_Str",targetLocalFile.getAbsolutePath());
        throw new Exception(msg);
      }
      if (!targetLocalFile.getParentFile().exists()) {
        final String msg=localStrings.getLocalString("String_Node_Str","String_Node_Str",targetLocalFile.getParent());
        throw new Exception(msg);
      }
      FileOutputStream targetStream=new FileOutputStream(targetLocalFile);
      outboundPayload.writeTo(targetStream);
      targetStream.flush();
      targetStream.close();
    }
  }
 catch (  Exception e) {
    final String errorMsg=localStrings.getLocalString("String_Node_Str","String_Node_Str");
    logger.log(Level.SEVERE,errorMsg,e);
    ActionReport report=context.getActionReport();
    if (!reportErrorsInTopReport) {
      report=report.addSubActionsReport();
      report.setActionExitCode(ExitCode.WARNING);
    }
 else {
      report.setActionExitCode(ExitCode.FAILURE);
    }
    report.setMessage(errorMsg);
    report.setFailureCause(e);
  }
}

Fixed version (ground truth):
private static void retrieveArtifacts(final AdminCommandContext context,final Collection<Artifacts.FullAndPartURIs> artifactInfo,final String targetLocalDir,final boolean reportErrorsInTopReport){
  Logger logger=context.getLogger();
  FileOutputStream targetStream=null;
  try {
    Payload.Outbound outboundPayload=context.getOutboundPayload();
    boolean retrieveArtifacts=false;
    if (outboundPayload == null) {
      outboundPayload=PayloadImpl.Outbound.newInstance();
      retrieveArtifacts=true;
    }
    Properties props=new Properties();
    props.setProperty("String_Node_Str",targetLocalDir.replace('\\','/'));
    for (    Artifacts.FullAndPartURIs uriPair : artifactInfo) {
      if (logger.isLoggable(Level.FINE)) {
        logger.log(Level.FINE,"String_Node_Str",uriPair.getFull());
      }
      outboundPayload.attachFile("String_Node_Str",uriPair.getPart(),"String_Node_Str",props,new File(uriPair.getFull().getSchemeSpecificPart()));
    }
    if (retrieveArtifacts) {
      File targetLocalFile=new File(targetLocalDir);
      if (targetLocalFile.exists()) {
        final String msg=localStrings.getLocalString("String_Node_Str","String_Node_Str",targetLocalFile.getAbsolutePath());
        throw new Exception(msg);
      }
      if (!targetLocalFile.getParentFile().exists()) {
        final String msg=localStrings.getLocalString("String_Node_Str","String_Node_Str",targetLocalFile.getParent());
        throw new Exception(msg);
      }
      targetStream=new FileOutputStream(targetLocalFile);
      outboundPayload.writeTo(targetStream);
      targetStream.flush();
    }
  }
 catch (  Exception e) {
    handleRetrieveException(e,context,reportErrorsInTopReport);
  }
 finally {
    if (targetStream != null) {
      try {
        targetStream.close();
      }
 catch (      IOException ex) {
        handleRetrieveException(ex,context,reportErrorsInTopReport);
      }
    }
  }
}