Program: 39583
Project: 39583
Buggy source:
public ButterflyCliRun run() throws IOException {
  ButterflyCliRun run=new ButterflyCliRun();
  run.setButterflyVersion(ButterflyProperties.getString("String_Node_Str"));
  logger.info(ButterflyCliApp.getBanner());
  if (optionSet == null || optionSet.has(CLI_OPTION_HELP) || (!optionSet.hasOptions() && optionSet.nonOptionArguments() == null)) {
    logger.info("String_Node_Str");
    logger.info("String_Node_Str");
    logger.info("String_Node_Str");
    logger.info("String_Node_Str");
    optionParser.printHelpOn(System.out);
    run.setExitStatus(0);
    return run;
  }
  if (optionSet.has(CLI_OPTION_VERBOSE)) {
    logConfigurator.setVerboseMode(true);
    logger.info("String_Node_Str");
  }
  if (optionSet.has(CLI_OPTION_DEBUG)) {
    logConfigurator.setDebugMode(true);
    logger.info("String_Node_Str");
    logger.info("String_Node_Str",ButterflyCliApp.getButterflyHome());
    logger.info("String_Node_Str",System.getenv("String_Node_Str"));
    logger.info("String_Node_Str",System.getProperty("String_Node_Str"));
    logger.info("String_Node_Str",System.getProperty("String_Node_Str"));
    logger.info("String_Node_Str",System.getenv("String_Node_Str"));
  }
  if (optionSet.has(CLI_OPTION_LIST_EXTENSIONS)) {
    try {
      printExtensionsList(butterflyFacade);
      run.setExitStatus(0);
      return run;
    }
 catch (    Exception e) {
      registerError(run,"String_Node_Str",e);
      return run;
    }
  }
  logger.info("String_Node_Str");
  List<?> nonOptionArguments=optionSet.nonOptionArguments();
  if (nonOptionArguments == null || nonOptionArguments.size() == 0 || StringUtils.isEmpty(nonOptionArguments.get(0))) {
    registerError(run,"String_Node_Str");
    return run;
  }
  File applicationFolder=new File((String)nonOptionArguments.get(0));
  if (!applicationFolder.exists()) {
    String errorMessage=String.format("String_Node_Str",applicationFolder.getAbsolutePath());
    registerError(run,errorMessage);
    return run;
  }
  run.setApplication(applicationFolder);
  File transformedApplicationFolder=(File)optionSet.valueOf(CLI_OPTION_TRANSFORMED_APP_FOLDER);
  boolean createZip=optionSet.has(CLI_OPTION_CREATE_ZIP);
  String templateClassName=null;
  Class<? extends TransformationTemplate> templateClass=null;
  if (optionSet.has(CLI_OPTION_TEMPLATE)) {
    templateClassName=(String)optionSet.valueOf(CLI_OPTION_TEMPLATE);
  }
 else   if (optionSet.has(CLI_OPTION_TEMPLATE_SHORTCUT)) {
    int shortcut=(Integer)optionSet.valueOf(CLI_OPTION_TEMPLATE_SHORTCUT);
    templateClass=getTemplateClass(shortcut);
    if (templateClass == null) {
      registerError(run,"String_Node_Str");
      return run;
    }
    logger.info("String_Node_Str",shortcut,templateClass.getName());
  }
 else {
    try {
      templateClass=butterflyFacade.automaticResolution(applicationFolder);
      if (templateClass == null) {
        registerError(run,"String_Node_Str");
        return run;
      }
      logger.info("String_Node_Str");
    }
 catch (    TemplateResolutionException e) {
      registerError(run,e.getMessage());
      return run;
    }
  }
  if (createZip) {
    logger.info("String_Node_Str");
  }
  Configuration configuration=new Configuration(transformedApplicationFolder,createZip);
  if (optionSet.has(CLI_OPTION_DEBUG)) {
    Extension extension=butterflyFacade.getRegisteredExtension();
    if (extension != null) {
      logger.info("String_Node_Str",extension.getClass().getName());
      logConfigurator.setLoggerLevel(extension.getClass().getPackage().getName(),Level.DEBUG);
    }
  }
  try {
    if (templateClass == null) {
      templateClass=(Class<? extends TransformationTemplate>)Class.forName(templateClassName);
    }
    run.setTransformationTemplate(templateClass.getName());
    TransformationResult transformationResult=null;
    if (UpgradeStep.class.isAssignableFrom(templateClass)) {
      Class<? extends UpgradeStep> firstStepClass=(Class<? extends UpgradeStep>)templateClass;
      String upgradeVersion=(String)optionSet.valueOf(CLI_OPTION_UPGRADE_VERSION);
      UpgradePath upgradePath=new UpgradePath(firstStepClass,upgradeVersion);
      logger.info("String_Node_Str",upgradePath.getOriginalVersion(),upgradePath.getUpgradeVersion());
      transformationResult=butterflyFacade.transform(applicationFolder,upgradePath,configuration);
    }
 else {
      logger.info("String_Node_Str");
      transformationResult=butterflyFacade.transform(applicationFolder,templateClass,configuration);
    }
    logger.info("String_Node_Str");
    logger.info("String_Node_Str");
    logger.info("String_Node_Str");
    logger.info("String_Node_Str");
    logger.info("String_Node_Str",transformationResult.getTransformedApplicationLocation());
    logger.info("String_Node_Str",LogFileDefiner.getLogFile());
    run.setTransformedApplication(transformationResult.getTransformedApplicationLocation());
    run.setLogFile(LogFileDefiner.getLogFile());
    if (transformationResult.hasManualInstructions()) {
      logger.info("String_Node_Str");
      logger.info("String_Node_Str");
      logger.info("String_Node_Str");
      logger.info("String_Node_Str");
      logger.info("String_Node_Str",transformationResult.getManualInstructionsFile());
      logger.info("String_Node_Str");
      run.setManualInstructionsFile(transformationResult.getManualInstructionsFile());
    }
    logger.info("String_Node_Str");
  }
 catch (  ButterflyException|ButterflyRuntimeException e) {
    logger.info("String_Node_Str");
    logger.info("String_Node_Str");
    logger.error("String_Node_Str");
    logger.error("String_Node_Str",e.getMessage());
    logger.info("String_Node_Str");
    logger.info("String_Node_Str",LogFileDefiner.getLogFile().getAbsolutePath());
    run.setErrorMessage("String_Node_Str" + e.getMessage());
    run.setExceptionMessage(e.getMessage());
    run.setExitStatus(1);
    return run;
  }
catch (  ClassNotFoundException e) {
    registerError(run,"String_Node_Str",e);
    return run;
  }
  return run;
}

Fixed version (ground truth):
public ButterflyCliRun run() throws IOException {
  ButterflyCliRun run=new ButterflyCliRun();
  run.setButterflyVersion(ButterflyProperties.getString("String_Node_Str"));
  logger.info(ButterflyCliApp.getBanner());
  if (optionSet == null || optionSet.has(CLI_OPTION_HELP) || (!optionSet.hasOptions() && optionSet.nonOptionArguments() == null)) {
    logger.info("String_Node_Str");
    logger.info("String_Node_Str");
    logger.info("String_Node_Str");
    logger.info("String_Node_Str");
    optionParser.printHelpOn(System.out);
    run.setExitStatus(0);
    return run;
  }
  if (optionSet.has(CLI_OPTION_VERBOSE)) {
    logConfigurator.setVerboseMode(true);
    logger.info("String_Node_Str");
  }
  if (optionSet.has(CLI_OPTION_DEBUG)) {
    logConfigurator.setDebugMode(true);
    logger.info("String_Node_Str");
    logger.info("String_Node_Str",ButterflyCliApp.getButterflyHome());
    logger.info("String_Node_Str",System.getenv("String_Node_Str"));
    logger.info("String_Node_Str",System.getProperty("String_Node_Str"));
    logger.info("String_Node_Str",System.getProperty("String_Node_Str"));
    logger.info("String_Node_Str",System.getenv("String_Node_Str"));
  }
  if (optionSet.has(CLI_OPTION_LIST_EXTENSIONS)) {
    try {
      printExtensionsList(butterflyFacade);
      run.setExitStatus(0);
      return run;
    }
 catch (    Exception e) {
      registerError(run,"String_Node_Str",e);
      return run;
    }
  }
  logger.info("String_Node_Str");
  List<?> nonOptionArguments=optionSet.nonOptionArguments();
  if (nonOptionArguments == null || nonOptionArguments.size() == 0 || StringUtils.isEmpty(nonOptionArguments.get(0))) {
    registerError(run,"String_Node_Str");
    return run;
  }
  File applicationFolder=new File((String)nonOptionArguments.get(0));
  if (!applicationFolder.exists()) {
    String errorMessage=String.format("String_Node_Str",applicationFolder.getAbsolutePath());
    registerError(run,errorMessage);
    return run;
  }
  run.setApplication(applicationFolder);
  File transformedApplicationFolder=(File)optionSet.valueOf(CLI_OPTION_TRANSFORMED_APP_FOLDER);
  boolean createZip=optionSet.has(CLI_OPTION_CREATE_ZIP);
  String templateClassName=null;
  Class<? extends TransformationTemplate> templateClass=null;
  if (optionSet.has(CLI_OPTION_TEMPLATE)) {
    templateClassName=(String)optionSet.valueOf(CLI_OPTION_TEMPLATE);
  }
 else   if (optionSet.has(CLI_OPTION_TEMPLATE_SHORTCUT)) {
    int shortcut=(Integer)optionSet.valueOf(CLI_OPTION_TEMPLATE_SHORTCUT);
    templateClass=getTemplateClass(shortcut);
    if (templateClass == null) {
      registerError(run,"String_Node_Str");
      return run;
    }
    logger.info("String_Node_Str",shortcut,templateClass.getName());
  }
 else {
    try {
      templateClass=butterflyFacade.automaticResolution(applicationFolder);
      if (templateClass == null) {
        registerError(run,"String_Node_Str");
        return run;
      }
      logger.info("String_Node_Str");
    }
 catch (    TemplateResolutionException e) {
      registerError(run,e.getMessage());
      return run;
    }
  }
  if (createZip) {
    logger.info("String_Node_Str");
  }
  Configuration configuration=new Configuration(transformedApplicationFolder,createZip);
  if (optionSet.has(CLI_OPTION_DEBUG)) {
    Extension extension=butterflyFacade.getRegisteredExtension();
    if (extension != null) {
      logger.info("String_Node_Str",extension.getClass().getName());
      logConfigurator.setLoggerLevel(extension.getClass().getPackage().getName(),Level.DEBUG);
    }
  }
  try {
    if (templateClass == null) {
      templateClass=(Class<? extends TransformationTemplate>)Class.forName(templateClassName);
    }
    run.setTransformationTemplate(templateClass.getName());
    TransformationResult transformationResult=null;
    if (UpgradeStep.class.isAssignableFrom(templateClass)) {
      Class<? extends UpgradeStep> firstStepClass=(Class<? extends UpgradeStep>)templateClass;
      String upgradeVersion=(String)optionSet.valueOf(CLI_OPTION_UPGRADE_VERSION);
      UpgradePath upgradePath=new UpgradePath(firstStepClass,upgradeVersion);
      logger.info("String_Node_Str",upgradePath.getOriginalVersion(),upgradePath.getUpgradeVersion());
      transformationResult=butterflyFacade.transform(applicationFolder,upgradePath,configuration);
    }
 else {
      logger.info("String_Node_Str");
      transformationResult=butterflyFacade.transform(applicationFolder,templateClass,configuration);
    }
    logger.info("String_Node_Str");
    logger.info("String_Node_Str");
    logger.info("String_Node_Str");
    logger.info("String_Node_Str");
    logger.info("String_Node_Str",transformationResult.getTransformedApplicationLocation());
    logger.info("String_Node_Str",LogFileDefiner.getLogFile());
    run.setTransformedApplication(transformationResult.getTransformedApplicationLocation());
    run.setLogFile(LogFileDefiner.getLogFile());
    if (transformationResult.hasManualInstructions()) {
      logger.info("String_Node_Str");
      logger.info("String_Node_Str");
      logger.info("String_Node_Str");
      logger.info("String_Node_Str");
      logger.info("String_Node_Str",transformationResult.getManualInstructionsFile());
      logger.info("String_Node_Str");
      run.setManualInstructionsFile(transformationResult.getManualInstructionsFile());
    }
    logger.info("String_Node_Str");
  }
 catch (  ButterflyException|ButterflyRuntimeException e) {
    logger.info("String_Node_Str");
    logger.info("String_Node_Str");
    logger.error("String_Node_Str");
    logger.error("String_Node_Str",e.getMessage());
    logger.info("String_Node_Str");
    logger.info("String_Node_Str",LogFileDefiner.getLogFile().getAbsolutePath());
    run.setErrorMessage("String_Node_Str" + e.getMessage());
    run.setExceptionMessage(e.getMessage());
    run.setExitStatus(1);
    return run;
  }
catch (  ClassNotFoundException e) {
    registerError(run,"String_Node_Str",e);
    return run;
  }
catch (  IllegalArgumentException e) {
    registerError(run,"String_Node_Str",e);
    return run;
  }
catch (  Exception e) {
    registerError(run,"String_Node_Str",e);
    return run;
  }
  return run;
}