Program: 177174
Project: 177174
Buggy source:
/** 
 * Invokes the flex compiler on the apps specified in the configuration file.
 */
protected void doFlexCompile() throws EnunciateException, IOException {
  File swcFile=null;
  File asSources=null;
  Enunciate enunciate=getEnunciate();
  if (isSwcDownloadable() || !flexApps.isEmpty()) {
    if (this.flexHome == null) {
      throw new EnunciateException("String_Node_Str");
    }
    File flexHomeDir=new File(this.flexHome);
    if (!flexHomeDir.exists()) {
      throw new EnunciateException("String_Node_Str" + flexHomeDir.getAbsolutePath() + "String_Node_Str");
    }
    File javaBinDir=new File(System.getProperty("String_Node_Str"),"String_Node_Str");
    File javaExecutable=new File(javaBinDir,"String_Node_Str");
    if (!javaExecutable.exists()) {
      javaExecutable=new File(javaBinDir,"String_Node_Str");
    }
    String javaCommand=javaExecutable.getAbsolutePath();
    if (!javaExecutable.exists()) {
      warn("String_Node_Str",javaBinDir.getAbsolutePath());
      javaCommand="String_Node_Str";
    }
    int compileCommandIndex;
    int outputFileIndex;
    int sourcePathIndex;
    int mainMxmlPathIndex;
    List<String> commandLine=new ArrayList<String>();
    int argIndex=0;
    commandLine.add(argIndex++,javaCommand);
    for (    String jvmarg : this.compilerConfig.getJVMArgs()) {
      commandLine.add(argIndex++,jvmarg);
    }
    commandLine.add(argIndex++,"String_Node_Str");
    File flexHomeLib=new File(flexHomeDir,"String_Node_Str");
    if (!flexHomeLib.exists()) {
      throw new EnunciateException("String_Node_Str" + flexHomeLib);
    }
 else {
      StringBuilder builder=new StringBuilder();
      Iterator<File> flexLibIt=Arrays.asList(flexHomeLib.listFiles()).iterator();
      while (flexLibIt.hasNext()) {
        File flexJar=flexLibIt.next();
        if (flexJar.getAbsolutePath().endsWith("String_Node_Str")) {
          builder.append(flexJar.getAbsolutePath());
          if (flexLibIt.hasNext()) {
            builder.append(File.pathSeparatorChar);
          }
        }
 else {
          debug("String_Node_Str",flexJar);
        }
      }
      commandLine.add(argIndex++,builder.toString());
    }
    compileCommandIndex=argIndex;
    commandLine.add(argIndex++,null);
    commandLine.add(argIndex++,"String_Node_Str");
    outputFileIndex=argIndex;
    commandLine.add(argIndex++,null);
    if (compilerConfig.getFlexConfig() == null) {
      compilerConfig.setFlexConfig(new File(new File(flexHome,"String_Node_Str"),"String_Node_Str"));
    }
    if (compilerConfig.getFlexConfig().exists()) {
      commandLine.add(argIndex++,"String_Node_Str");
      commandLine.add(argIndex++,compilerConfig.getFlexConfig().getAbsolutePath());
    }
 else {
      warn("String_Node_Str",compilerConfig.getFlexConfig());
    }
    if (compilerConfig.getContextRoot() == null) {
      if (getEnunciate().getConfig().getLabel() != null) {
        compilerConfig.setContextRoot("String_Node_Str" + getEnunciate().getConfig().getLabel());
      }
 else {
        compilerConfig.setContextRoot("String_Node_Str");
      }
    }
    commandLine.add(argIndex++,"String_Node_Str");
    commandLine.add(argIndex++,compilerConfig.getContextRoot());
    if (compilerConfig.getLocale() != null) {
      commandLine.add(argIndex++,"String_Node_Str");
      commandLine.add(argIndex++,compilerConfig.getLocale());
    }
    if (compilerConfig.getLicenses().size() > 0) {
      commandLine.add(argIndex++,"String_Node_Str");
      for (      License license : compilerConfig.getLicenses()) {
        commandLine.add(argIndex++,license.getProduct());
        commandLine.add(argIndex++,license.getSerialNumber());
      }
    }
    if (compilerConfig.getOptimize() != null && compilerConfig.getOptimize()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    if (compilerConfig.getDebug() != null && compilerConfig.getDebug()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    if (compilerConfig.getStrict() != null && compilerConfig.getStrict()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    if (compilerConfig.getUseNetwork() != null && compilerConfig.getUseNetwork()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    if (compilerConfig.getIncremental() != null && compilerConfig.getIncremental()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    if (compilerConfig.getShowActionscriptWarnings() != null && compilerConfig.getShowActionscriptWarnings()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    if (compilerConfig.getShowBindingWarnings() != null && compilerConfig.getShowBindingWarnings()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    if (compilerConfig.getShowDeprecationWarnings() != null && compilerConfig.getShowDeprecationWarnings()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    for (    String arg : this.compilerConfig.getArgs()) {
      commandLine.add(argIndex++,arg);
    }
    commandLine.add(argIndex++,"String_Node_Str");
    File xmlGenerateDir=getXMLGenerateDir();
    commandLine.add(argIndex++,new File(xmlGenerateDir,"String_Node_Str").getAbsolutePath());
    commandLine.add(argIndex,"String_Node_Str");
    File clientSideGenerateDir=getClientSideGenerateDir();
    commandLine.add(argIndex + 1,clientSideGenerateDir.getAbsolutePath());
    String swcName=getSwcName();
    if (swcName == null) {
      String label="String_Node_Str";
      if ((enunciate.getConfig() != null) && (enunciate.getConfig().getLabel() != null)) {
        label=enunciate.getConfig().getLabel();
      }
      swcName=label + "String_Node_Str";
    }
    File swcCompileDir=getSwcCompileDir();
    swcFile=new File(swcCompileDir,swcName);
    boolean swcUpToDate=swcFile.exists() && enunciate.isUpToDate(xmlGenerateDir,swcCompileDir) && enunciate.isUpToDate(clientSideGenerateDir,swcCompileDir);
    if (!swcUpToDate) {
      commandLine.set(compileCommandIndex,compilerConfig.getSwcCompileCommand());
      commandLine.set(outputFileIndex,swcFile.getAbsolutePath());
      info("String_Node_Str",swcFile.getAbsolutePath());
      if (enunciate.isDebug()) {
        StringBuilder command=new StringBuilder();
        for (        String commandPiece : commandLine) {
          command.append(' ').append(commandPiece);
        }
        debug("String_Node_Str",command);
      }
      compileSwc(commandLine);
    }
 else {
      info("String_Node_Str",swcFile.getAbsolutePath());
    }
    while (commandLine.size() > argIndex) {
      commandLine.remove(argIndex);
    }
    if (compilerConfig.getProfile() != null && compilerConfig.getProfile()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    if (compilerConfig.getWarnings() != null && compilerConfig.getWarnings()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    commandLine.add(argIndex++,"String_Node_Str");
    commandLine.add(argIndex++,clientSideGenerateDir.getAbsolutePath());
    commandLine.add(argIndex++,"String_Node_Str");
    sourcePathIndex=argIndex;
    commandLine.add(argIndex++,null);
    commandLine.add(argIndex++,"String_Node_Str");
    mainMxmlPathIndex=argIndex;
    commandLine.add(argIndex++,null);
    commandLine.set(compileCommandIndex,compilerConfig.getFlexCompileCommand());
    File outputDirectory=getSwfCompileDir();
    debug("String_Node_Str" + outputDirectory);
    outputDirectory.mkdirs();
    for (    FlexApp flexApp : flexApps) {
      String mainMxmlPath=flexApp.getMainMxmlFile();
      if (mainMxmlPath == null) {
        throw new EnunciateException("String_Node_Str" + flexApp.getName() + "String_Node_Str");
      }
      File mainMxmlFile=enunciate.resolvePath(mainMxmlPath);
      if (!mainMxmlFile.exists()) {
        throw new EnunciateException("String_Node_Str" + flexApp.getName() + "String_Node_Str");
      }
      File swfFile=new File(outputDirectory,flexApp.getName() + "String_Node_Str");
      File appSrcDir=enunciate.resolvePath(flexApp.getSrcDir());
      String swfFilePath=swfFile.getAbsolutePath();
      boolean swfUpToDate=swfFile.exists() && mainMxmlFile.lastModified() < swfFile.lastModified() && enunciate.isUpToDate(appSrcDir,swfFile);
      if (!swfUpToDate) {
        commandLine.set(outputFileIndex,swfFilePath);
        commandLine.set(mainMxmlPathIndex,mainMxmlFile.getAbsolutePath());
        commandLine.set(sourcePathIndex,appSrcDir.getAbsolutePath());
        info("String_Node_Str",swfFilePath);
        if (enunciate.isDebug()) {
          StringBuilder command=new StringBuilder();
          for (          String commandPiece : commandLine) {
            command.append(' ').append(commandPiece);
          }
          debug("String_Node_Str",flexApp.getName(),command);
        }
        ProcessBuilder processBuilder=new ProcessBuilder(commandLine.toArray(new String[commandLine.size()]));
        processBuilder.directory(getSwfCompileDir());
        processBuilder.redirectErrorStream(true);
        Process process=processBuilder.start();
        BufferedReader procReader=new BufferedReader(new InputStreamReader(process.getInputStream()));
        String line=procReader.readLine();
        while (line != null) {
          info(line);
          line=procReader.readLine();
        }
        int procCode;
        try {
          procCode=process.waitFor();
        }
 catch (        InterruptedException e1) {
          throw new EnunciateException("String_Node_Str");
        }
        if (procCode != 0) {
          throw new EnunciateException("String_Node_Str" + flexApp.getName());
        }
      }
 else {
        info("String_Node_Str",swfFilePath);
      }
    }
  }
 else   if (isAsSourcesDownloadable()) {
    String label="String_Node_Str";
    if ((enunciate.getConfig() != null) && (enunciate.getConfig().getLabel() != null)) {
      label=enunciate.getConfig().getLabel();
    }
    asSources=new File(new File(getCompileDir(),"String_Node_Str"),label + "String_Node_Str");
    enunciate.zip(asSources,getClientSideGenerateDir());
  }
  if (swcFile != null || asSources != null) {
    List<ArtifactDependency> clientDeps=new ArrayList<ArtifactDependency>();
    BaseArtifactDependency as3Dependency=new BaseArtifactDependency();
    as3Dependency.setId("String_Node_Str");
    as3Dependency.setArtifactType("String_Node_Str");
    as3Dependency.setDescription("String_Node_Str");
    as3Dependency.setURL("String_Node_Str");
    as3Dependency.setVersion("String_Node_Str");
    clientDeps.add(as3Dependency);
    ClientLibraryArtifact as3ClientArtifact=new ClientLibraryArtifact(getName(),"String_Node_Str","String_Node_Str");
    as3ClientArtifact.setPlatform("String_Node_Str");
    as3ClientArtifact.setDescription(readResource("String_Node_Str"));
    as3ClientArtifact.setDependencies(clientDeps);
    if (swcFile != null) {
      NamedFileArtifact clientArtifact=new NamedFileArtifact(getName(),"String_Node_Str",swcFile);
      clientArtifact.setDescription("String_Node_Str");
      clientArtifact.setPublic(true);
      as3ClientArtifact.addArtifact(clientArtifact);
      enunciate.addArtifact(clientArtifact);
    }
    if (asSources != null) {
      NamedFileArtifact clientArtifact=new NamedFileArtifact(getName(),"String_Node_Str",asSources);
      clientArtifact.setDescription("String_Node_Str");
      clientArtifact.setPublic(true);
      as3ClientArtifact.addArtifact(clientArtifact);
      enunciate.addArtifact(clientArtifact);
    }
    enunciate.addArtifact(as3ClientArtifact);
  }
}

Fixed version (ground truth):
/** 
 * Invokes the flex compiler on the apps specified in the configuration file.
 */
protected void doFlexCompile() throws EnunciateException, IOException {
  File swcFile=null;
  File asSources=null;
  Enunciate enunciate=getEnunciate();
  if (isSwcDownloadable() || !flexApps.isEmpty()) {
    if (this.flexHome == null) {
      throw new EnunciateException("String_Node_Str");
    }
    File flexHomeDir=new File(this.flexHome);
    if (!flexHomeDir.exists()) {
      throw new EnunciateException("String_Node_Str" + flexHomeDir.getAbsolutePath() + "String_Node_Str");
    }
    File javaBinDir=new File(System.getProperty("String_Node_Str"),"String_Node_Str");
    File javaExecutable=new File(javaBinDir,"String_Node_Str");
    if (!javaExecutable.exists()) {
      javaExecutable=new File(javaBinDir,"String_Node_Str");
    }
    String javaCommand=javaExecutable.getAbsolutePath();
    if (!javaExecutable.exists()) {
      warn("String_Node_Str",javaBinDir.getAbsolutePath());
      javaCommand="String_Node_Str";
    }
    int compileCommandIndex;
    int outputFileIndex;
    int sourcePathIndex;
    int mainMxmlPathIndex;
    List<String> commandLine=new ArrayList<String>();
    int argIndex=0;
    commandLine.add(argIndex++,javaCommand);
    for (    String jvmarg : this.compilerConfig.getJVMArgs()) {
      commandLine.add(argIndex++,jvmarg);
    }
    commandLine.add(argIndex++,"String_Node_Str");
    File flexHomeLib=new File(flexHomeDir,"String_Node_Str");
    if (!flexHomeLib.exists()) {
      throw new EnunciateException("String_Node_Str" + flexHomeLib);
    }
 else {
      StringBuilder builder=new StringBuilder();
      Iterator<File> flexLibIt=Arrays.asList(flexHomeLib.listFiles()).iterator();
      while (flexLibIt.hasNext()) {
        File flexJar=flexLibIt.next();
        if (flexJar.getAbsolutePath().endsWith("String_Node_Str")) {
          builder.append(flexJar.getAbsolutePath());
          if (flexLibIt.hasNext()) {
            builder.append(File.pathSeparatorChar);
          }
        }
 else {
          debug("String_Node_Str",flexJar);
        }
      }
      commandLine.add(argIndex++,builder.toString());
    }
    compileCommandIndex=argIndex;
    commandLine.add(argIndex++,null);
    commandLine.add(argIndex++,"String_Node_Str");
    outputFileIndex=argIndex;
    commandLine.add(argIndex++,null);
    if (compilerConfig.getFlexConfig() == null) {
      compilerConfig.setFlexConfig(new File(new File(flexHome,"String_Node_Str"),"String_Node_Str"));
    }
    if (compilerConfig.getFlexConfig().exists()) {
      commandLine.add(argIndex++,"String_Node_Str");
      commandLine.add(argIndex++,compilerConfig.getFlexConfig().getAbsolutePath());
    }
 else {
      warn("String_Node_Str",compilerConfig.getFlexConfig());
    }
    if (compilerConfig.getContextRoot() == null) {
      if (getEnunciate().getConfig().getLabel() != null) {
        compilerConfig.setContextRoot("String_Node_Str" + getEnunciate().getConfig().getLabel());
      }
 else {
        compilerConfig.setContextRoot("String_Node_Str");
      }
    }
    commandLine.add(argIndex++,"String_Node_Str");
    commandLine.add(argIndex++,compilerConfig.getContextRoot());
    if (compilerConfig.getLocale() != null) {
      commandLine.add(argIndex++,"String_Node_Str");
      commandLine.add(argIndex++,compilerConfig.getLocale());
    }
    if (compilerConfig.getLicenses().size() > 0) {
      commandLine.add(argIndex++,"String_Node_Str");
      for (      License license : compilerConfig.getLicenses()) {
        commandLine.add(argIndex++,license.getProduct());
        commandLine.add(argIndex++,license.getSerialNumber());
      }
    }
    if (compilerConfig.getOptimize() != null && compilerConfig.getOptimize()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    if (compilerConfig.getDebug() != null && compilerConfig.getDebug()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    if (compilerConfig.getStrict() != null && compilerConfig.getStrict()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    if (compilerConfig.getUseNetwork() != null && compilerConfig.getUseNetwork()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    if (compilerConfig.getIncremental() != null && compilerConfig.getIncremental()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    if (compilerConfig.getShowActionscriptWarnings() != null && compilerConfig.getShowActionscriptWarnings()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    if (compilerConfig.getShowBindingWarnings() != null && compilerConfig.getShowBindingWarnings()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    if (compilerConfig.getShowDeprecationWarnings() != null && compilerConfig.getShowDeprecationWarnings()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    for (    String arg : this.compilerConfig.getArgs()) {
      commandLine.add(argIndex++,arg);
    }
    commandLine.add(argIndex++,"String_Node_Str");
    File xmlGenerateDir=getXMLGenerateDir();
    commandLine.add(argIndex++,new File(xmlGenerateDir,"String_Node_Str").getAbsolutePath());
    commandLine.add(argIndex,"String_Node_Str");
    File clientSideGenerateDir=getClientSideGenerateDir();
    commandLine.add(argIndex + 1,clientSideGenerateDir.getAbsolutePath());
    String swcName=getSwcName();
    if (swcName == null) {
      String label="String_Node_Str";
      if ((enunciate.getConfig() != null) && (enunciate.getConfig().getLabel() != null)) {
        label=enunciate.getConfig().getLabel();
      }
      swcName=label + "String_Node_Str";
    }
    File swcCompileDir=getSwcCompileDir();
    swcFile=new File(swcCompileDir,swcName);
    boolean swcUpToDate=swcFile.exists() && enunciate.isUpToDate(xmlGenerateDir,swcCompileDir) && enunciate.isUpToDate(clientSideGenerateDir,swcCompileDir);
    if (!swcUpToDate) {
      commandLine.set(compileCommandIndex,compilerConfig.getSwcCompileCommand());
      commandLine.set(outputFileIndex,swcFile.getAbsolutePath());
      info("String_Node_Str",swcFile.getAbsolutePath());
      if (enunciate.isDebug()) {
        StringBuilder command=new StringBuilder();
        for (        String commandPiece : commandLine) {
          command.append(' ').append(commandPiece);
        }
        debug("String_Node_Str",command);
      }
      compileSwc(commandLine);
    }
 else {
      info("String_Node_Str",swcFile.getAbsolutePath());
    }
    while (commandLine.size() > argIndex) {
      commandLine.remove(argIndex);
    }
    if (compilerConfig.getProfile() != null && compilerConfig.getProfile()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    if (compilerConfig.getWarnings() != null && compilerConfig.getWarnings()) {
      commandLine.add(argIndex++,"String_Node_Str");
    }
    commandLine.add(argIndex++,"String_Node_Str");
    commandLine.add(argIndex++,clientSideGenerateDir.getAbsolutePath());
    commandLine.add(argIndex++,"String_Node_Str");
    sourcePathIndex=argIndex;
    commandLine.add(argIndex++,null);
    commandLine.add(argIndex++,"String_Node_Str");
    mainMxmlPathIndex=argIndex;
    commandLine.add(argIndex++,null);
    commandLine.set(compileCommandIndex,compilerConfig.getFlexCompileCommand());
    File outputDirectory=getSwfCompileDir();
    debug("String_Node_Str" + outputDirectory);
    outputDirectory.mkdirs();
    for (    FlexApp flexApp : flexApps) {
      String mainMxmlPath=flexApp.getMainMxmlFile();
      if (mainMxmlPath == null) {
        throw new EnunciateException("String_Node_Str" + flexApp.getName() + "String_Node_Str");
      }
      File mainMxmlFile=enunciate.resolvePath(mainMxmlPath);
      if (!mainMxmlFile.exists()) {
        throw new EnunciateException("String_Node_Str" + flexApp.getName() + "String_Node_Str");
      }
      File swfFile=new File(outputDirectory,flexApp.getName() + "String_Node_Str");
      File appSrcDir=enunciate.resolvePath(flexApp.getSrcDir());
      String swfFilePath=swfFile.getAbsolutePath();
      boolean swfUpToDate=swfFile.exists() && mainMxmlFile.lastModified() < swfFile.lastModified() && enunciate.isUpToDate(appSrcDir,swfFile);
      if (!swfUpToDate) {
        commandLine.set(outputFileIndex,swfFilePath);
        commandLine.set(mainMxmlPathIndex,mainMxmlFile.getAbsolutePath());
        commandLine.set(sourcePathIndex,appSrcDir.getAbsolutePath());
        info("String_Node_Str",swfFilePath);
        if (enunciate.isDebug()) {
          StringBuilder command=new StringBuilder();
          for (          String commandPiece : commandLine) {
            command.append(' ').append(commandPiece);
          }
          debug("String_Node_Str",flexApp.getName(),command);
        }
        ProcessBuilder processBuilder=new ProcessBuilder(commandLine.toArray(new String[commandLine.size()]));
        processBuilder.directory(getSwfCompileDir());
        processBuilder.redirectErrorStream(true);
        Process process=processBuilder.start();
        BufferedReader procReader=new BufferedReader(new InputStreamReader(process.getInputStream()));
        String line=procReader.readLine();
        while (line != null) {
          info(line);
          line=procReader.readLine();
        }
        int procCode;
        try {
          procCode=process.waitFor();
        }
 catch (        InterruptedException e1) {
          throw new EnunciateException("String_Node_Str");
        }
        if (procCode != 0) {
          throw new EnunciateException("String_Node_Str" + flexApp.getName());
        }
      }
 else {
        info("String_Node_Str",swfFilePath);
      }
    }
  }
  if (isAsSourcesDownloadable()) {
    String label="String_Node_Str";
    if ((enunciate.getConfig() != null) && (enunciate.getConfig().getLabel() != null)) {
      label=enunciate.getConfig().getLabel();
    }
    asSources=new File(new File(getCompileDir(),"String_Node_Str"),label + "String_Node_Str");
    enunciate.zip(asSources,getClientSideGenerateDir());
  }
  if (swcFile != null || asSources != null) {
    List<ArtifactDependency> clientDeps=new ArrayList<ArtifactDependency>();
    BaseArtifactDependency as3Dependency=new BaseArtifactDependency();
    as3Dependency.setId("String_Node_Str");
    as3Dependency.setArtifactType("String_Node_Str");
    as3Dependency.setDescription("String_Node_Str");
    as3Dependency.setURL("String_Node_Str");
    as3Dependency.setVersion("String_Node_Str");
    clientDeps.add(as3Dependency);
    ClientLibraryArtifact as3ClientArtifact=new ClientLibraryArtifact(getName(),"String_Node_Str","String_Node_Str");
    as3ClientArtifact.setPlatform("String_Node_Str");
    as3ClientArtifact.setDescription(readResource("String_Node_Str"));
    as3ClientArtifact.setDependencies(clientDeps);
    if (swcFile != null) {
      NamedFileArtifact clientArtifact=new NamedFileArtifact(getName(),"String_Node_Str",swcFile);
      clientArtifact.setDescription("String_Node_Str");
      clientArtifact.setPublic(false);
      as3ClientArtifact.addArtifact(clientArtifact);
      enunciate.addArtifact(clientArtifact);
    }
    if (asSources != null) {
      NamedFileArtifact clientArtifact=new NamedFileArtifact(getName(),"String_Node_Str",asSources);
      clientArtifact.setDescription("String_Node_Str");
      clientArtifact.setPublic(false);
      as3ClientArtifact.addArtifact(clientArtifact);
      enunciate.addArtifact(clientArtifact);
    }
    enunciate.addArtifact(as3ClientArtifact);
  }
}