Program: 53255
Project: 53255
Buggy source:
/** 
 * @param context an optional NGContext that is present if running inside a Nailgun server.
 * @param args command line arguments
 * @return an exit code or {@code null} if this is a process that should not exit
 */
@SuppressWarnings("String_Node_Str") public int executeCommand(File projectRoot,Command.ParseResult commandParseResult,Optional<NGContext> context,String... args) throws IOException {
  ProjectFilesystem projectFilesystem=new ProjectFilesystem(Paths.get(projectRoot.getPath()),createBuckConfig(new ProjectFilesystem(projectRoot),platform).getIgnorePaths());
  BuckConfig config=createBuckConfig(projectFilesystem,platform);
  Verbosity verbosity=VerbosityParser.parse(args);
  Optional<String> color;
  final boolean isDaemon=context.isPresent();
  if (isDaemon && (context.get().getEnv() != null)) {
    String colorString=context.get().getEnv().getProperty(BUCKD_COLOR_DEFAULT_ENV_VAR);
    color=Optional.fromNullable(colorString);
  }
 else {
    color=Optional.absent();
  }
  final Console console=new Console(verbosity,stdOut,stdErr,config.createAnsi(color));
  if (commandParseResult.getErrorText().isPresent()) {
    console.getStdErr().println(commandParseResult.getErrorText().get());
  }
  if (!commandSemaphore.tryAcquire()) {
    return BUSY_EXIT_CODE;
  }
  ProcessExecutor processExecutor=new ProcessExecutor(console);
  int exitCode;
  ImmutableList<BuckEventListener> eventListeners;
  BuildId buildId=new BuildId();
  Clock clock=new DefaultClock();
  ExecutionEnvironment executionEnvironment=new DefaultExecutionEnvironment(processExecutor);
  PropertyFinder propertyFinder=new DefaultPropertyFinder(projectFilesystem);
  AndroidDirectoryResolver androidDirectoryResolver=new DefaultAndroidDirectoryResolver(projectFilesystem,config.getNdkVersion(),propertyFinder);
  JavaBuckConfig javaConfig=new JavaBuckConfig(config);
  JavaCompilerEnvironment javacEnv=javaConfig.getJavaCompilerEnvironment(processExecutor);
  KnownBuildRuleTypes buildRuleTypes=KnownBuildRuleTypes.createInstance(config,androidDirectoryResolver,javacEnv);
  try (AbstractConsoleEventBusListener consoleListener=createConsoleEventListener(clock,console,verbosity,executionEnvironment);BuckEventBus buildEventBus=new BuckEventBus(clock,buildId)){
    Optional<WebServer> webServer=getWebServerIfDaemon(context,projectFilesystem,config,buildRuleTypes,androidDirectoryResolver,console);
    eventListeners=addEventListeners(buildEventBus,projectFilesystem,config,webServer,consoleListener);
    ImmutableList<String> remainingArgs=ImmutableList.copyOf(Arrays.copyOfRange(args,1,args.length));
    Command executingCommand=commandParseResult.getCommand().get();
    String commandName=executingCommand.name().toLowerCase();
    CommandEvent commandEvent=CommandEvent.started(commandName,remainingArgs,isDaemon);
    buildEventBus.post(commandEvent);
    ArtifactCacheFactory artifactCacheFactory=new LoggingArtifactCacheFactory(executionEnvironment,buildEventBus);
    Parser parser;
    if (isDaemon) {
      parser=getParserFromDaemon(context,projectFilesystem,config,buildRuleTypes,androidDirectoryResolver,console,commandEvent,buildEventBus);
    }
 else {
      JavaUtilsLoggingBuildListener.ensureLogFileIsWritten(projectFilesystem);
      parser=new Parser(projectFilesystem,buildRuleTypes,console,config.getPythonInterpreter(),config.getTempFilePatterns(),createRuleKeyBuilderFactory(new DefaultFileHashCache(projectFilesystem,console)));
    }
    CachingBuildEngine buildEngine=new CachingBuildEngine();
    exitCode=executingCommand.execute(remainingArgs,config,new CommandRunnerParams(console,projectFilesystem,androidDirectoryResolver,buildRuleTypes,buildEngine,artifactCacheFactory,buildEventBus,parser,platform));
    artifactCacheFactory.closeCreatedArtifactCaches(ARTIFACT_CACHE_TIMEOUT_IN_SECONDS);
    if (webServer.isPresent()) {
      int port=webServer.get().getPort();
      buildEventBus.post(LogEvent.info("String_Node_Str",port,buildId));
    }
    buildEventBus.post(CommandEvent.finished(commandName,remainingArgs,isDaemon,exitCode));
  }
  finally {
    commandSemaphore.release();
  }
  if (isDaemon && !config.getFlushEventsBeforeExit()) {
    context.get().in.close();
    context.get().exit(exitCode);
  }
  for (  BuckEventListener eventListener : eventListeners) {
    try {
      eventListener.outputTrace(buildId);
    }
 catch (    RuntimeException e) {
      System.err.println("String_Node_Str");
      e.printStackTrace();
    }
  }
  return exitCode;
}

Fixed version (ground truth):
/** 
 * @param context an optional NGContext that is present if running inside a Nailgun server.
 * @param args command line arguments
 * @return an exit code or {@code null} if this is a process that should not exit
 */
@SuppressWarnings("String_Node_Str") public int executeCommand(File projectRoot,Command.ParseResult commandParseResult,Optional<NGContext> context,String... args) throws IOException {
  ProjectFilesystem projectFilesystem=new ProjectFilesystem(Paths.get(projectRoot.getPath()),createBuckConfig(new ProjectFilesystem(projectRoot),platform).getIgnorePaths());
  BuckConfig config=createBuckConfig(projectFilesystem,platform);
  Verbosity verbosity=VerbosityParser.parse(args);
  Optional<String> color;
  final boolean isDaemon=context.isPresent();
  if (isDaemon && (context.get().getEnv() != null)) {
    String colorString=context.get().getEnv().getProperty(BUCKD_COLOR_DEFAULT_ENV_VAR);
    color=Optional.fromNullable(colorString);
  }
 else {
    color=Optional.absent();
  }
  final Console console=new Console(verbosity,stdOut,stdErr,config.createAnsi(color));
  if (commandParseResult.getErrorText().isPresent()) {
    console.getStdErr().println(commandParseResult.getErrorText().get());
  }
  if (!commandSemaphore.tryAcquire()) {
    return BUSY_EXIT_CODE;
  }
  ProcessExecutor processExecutor=new ProcessExecutor(console);
  int exitCode;
  ImmutableList<BuckEventListener> eventListeners;
  BuildId buildId=new BuildId();
  Clock clock=new DefaultClock();
  ExecutionEnvironment executionEnvironment=new DefaultExecutionEnvironment(processExecutor);
  PropertyFinder propertyFinder=new DefaultPropertyFinder(projectFilesystem);
  AndroidDirectoryResolver androidDirectoryResolver=new DefaultAndroidDirectoryResolver(projectFilesystem,config.getNdkVersion(),propertyFinder);
  JavaBuckConfig javaConfig=new JavaBuckConfig(config);
  JavaCompilerEnvironment javacEnv=javaConfig.getJavaCompilerEnvironment(processExecutor);
  KnownBuildRuleTypes buildRuleTypes=KnownBuildRuleTypes.createInstance(config,androidDirectoryResolver,javacEnv);
  try (AbstractConsoleEventBusListener consoleListener=createConsoleEventListener(clock,console,verbosity,executionEnvironment);BuckEventBus buildEventBus=new BuckEventBus(clock,buildId)){
    Optional<WebServer> webServer=getWebServerIfDaemon(context,projectFilesystem,config,buildRuleTypes,androidDirectoryResolver,console);
    eventListeners=addEventListeners(buildEventBus,projectFilesystem,config,webServer,consoleListener);
    ImmutableList<String> remainingArgs=ImmutableList.copyOf(Arrays.copyOfRange(args,1,args.length));
    Command executingCommand=commandParseResult.getCommand().get();
    String commandName=executingCommand.name().toLowerCase();
    CommandEvent commandEvent=CommandEvent.started(commandName,remainingArgs,isDaemon);
    buildEventBus.post(commandEvent);
    ArtifactCacheFactory artifactCacheFactory=new LoggingArtifactCacheFactory(executionEnvironment,buildEventBus);
    Parser parser;
    if (isDaemon) {
      parser=getParserFromDaemon(context,projectFilesystem,config,buildRuleTypes,androidDirectoryResolver,console,commandEvent,buildEventBus);
    }
 else {
      parser=new Parser(projectFilesystem,buildRuleTypes,console,config.getPythonInterpreter(),config.getTempFilePatterns(),createRuleKeyBuilderFactory(new DefaultFileHashCache(projectFilesystem,console)));
    }
    JavaUtilsLoggingBuildListener.ensureLogFileIsWritten(projectFilesystem);
    CachingBuildEngine buildEngine=new CachingBuildEngine();
    exitCode=executingCommand.execute(remainingArgs,config,new CommandRunnerParams(console,projectFilesystem,androidDirectoryResolver,buildRuleTypes,buildEngine,artifactCacheFactory,buildEventBus,parser,platform));
    artifactCacheFactory.closeCreatedArtifactCaches(ARTIFACT_CACHE_TIMEOUT_IN_SECONDS);
    if (webServer.isPresent()) {
      int port=webServer.get().getPort();
      buildEventBus.post(LogEvent.info("String_Node_Str",port,buildId));
    }
    buildEventBus.post(CommandEvent.finished(commandName,remainingArgs,isDaemon,exitCode));
  }
  finally {
    commandSemaphore.release();
  }
  if (isDaemon && !config.getFlushEventsBeforeExit()) {
    context.get().in.close();
    context.get().exit(exitCode);
  }
  for (  BuckEventListener eventListener : eventListeners) {
    try {
      eventListener.outputTrace(buildId);
    }
 catch (    RuntimeException e) {
      System.err.println("String_Node_Str");
      e.printStackTrace();
    }
  }
  return exitCode;
}