Program: 111016
Project: 111016
Buggy source:
/** 
 * Exit codes: 0   on successful evaluation. 1   if query evaluation did not complete. 2   if query parsing failed. 3   if errors were reported but evaluation produced a partial result (only when --keep_going is in effect.)
 */
@Override public ExitCode exec(BlazeRuntime runtime,OptionsProvider options){
  QueryOptions queryOptions=options.getOptions(QueryOptions.class);
  try {
    runtime.setupPackageCache(options.getOptions(PackageCacheOptions.class),runtime.getDefaultsPackageContent());
  }
 catch (  InterruptedException e) {
    runtime.getReporter().handle(Event.error("String_Node_Str"));
    return ExitCode.INTERRUPTED;
  }
catch (  AbruptExitException e) {
    runtime.getReporter().handle(Event.error(null,"String_Node_Str" + e.getMessage()));
    return e.getExitCode();
  }
  if (options.getResidue().isEmpty()) {
    runtime.getReporter().handle(Event.error(String.format("String_Node_Str",Constants.PRODUCT_NAME)));
    return ExitCode.COMMAND_LINE_ERROR;
  }
  Iterable<OutputFormatter> formatters=runtime.getQueryOutputFormatters();
  OutputFormatter formatter=OutputFormatter.getFormatter(formatters,queryOptions.outputFormat);
  if (formatter == null) {
    runtime.getReporter().handle(Event.error(String.format("String_Node_Str",queryOptions.outputFormat,OutputFormatter.formatterNames(formatters))));
    return ExitCode.COMMAND_LINE_ERROR;
  }
  String query=Joiner.on(' ').join(options.getResidue());
  Set<Setting> settings=queryOptions.toSettings();
  AbstractBlazeQueryEnvironment<Target> env=newQueryEnvironment(runtime,queryOptions.keepGoing,QueryOutputUtils.orderResults(queryOptions,formatter),queryOptions.universeScope,queryOptions.loadingPhaseThreads,settings);
  QueryExpression expr;
  try {
    expr=QueryExpression.parse(query,env);
  }
 catch (  QueryException e) {
    runtime.getReporter().handle(Event.error(null,"String_Node_Str" + query + "String_Node_Str"+ e.getMessage()));
    return ExitCode.COMMAND_LINE_ERROR;
  }
  QueryEvalResult<Target> result;
  try {
    result=env.evaluateQuery(expr);
  }
 catch (  QueryException|InterruptedException e) {
    runtime.getReporter().handle(Event.error(e.getMessage() == null ? e.toString() : e.getMessage()));
    return ExitCode.ANALYSIS_FAILURE;
  }
  PrintStream output=new PrintStream(runtime.getReporter().getOutErr().getOutputStream());
  try {
    QueryOutputUtils.output(queryOptions,result,formatter,output,queryOptions.aspectDeps.createResolver(runtime.getPackageManager(),runtime.getReporter()));
  }
 catch (  ClosedByInterruptException|InterruptedException e) {
    runtime.getReporter().handle(Event.error("String_Node_Str"));
    return ExitCode.INTERRUPTED;
  }
catch (  IOException e) {
    runtime.getReporter().handle(Event.error("String_Node_Str" + e.getMessage()));
    return ExitCode.LOCAL_ENVIRONMENTAL_ERROR;
  }
 finally {
    output.flush();
  }
  if (result.getResultSet().isEmpty()) {
    runtime.getReporter().handle(Event.info("String_Node_Str"));
  }
  return result.getSuccess() ? ExitCode.SUCCESS : ExitCode.PARTIAL_ANALYSIS_FAILURE;
}

Fixed version (ground truth):
/** 
 * Exit codes: 0   on successful evaluation. 1   if query evaluation did not complete. 2   if query parsing failed. 3   if errors were reported but evaluation produced a partial result (only when --keep_going is in effect.)
 */
@Override public ExitCode exec(BlazeRuntime runtime,OptionsProvider options){
  QueryOptions queryOptions=options.getOptions(QueryOptions.class);
  try {
    runtime.setupPackageCache(options.getOptions(PackageCacheOptions.class),runtime.getDefaultsPackageContent());
  }
 catch (  InterruptedException e) {
    runtime.getReporter().handle(Event.error("String_Node_Str"));
    return ExitCode.INTERRUPTED;
  }
catch (  AbruptExitException e) {
    runtime.getReporter().handle(Event.error(null,"String_Node_Str" + e.getMessage()));
    return e.getExitCode();
  }
  if (options.getResidue().isEmpty()) {
    runtime.getReporter().handle(Event.error(String.format("String_Node_Str",Constants.PRODUCT_NAME)));
    return ExitCode.COMMAND_LINE_ERROR;
  }
  Iterable<OutputFormatter> formatters=runtime.getQueryOutputFormatters();
  OutputFormatter formatter=OutputFormatter.getFormatter(formatters,queryOptions.outputFormat);
  if (formatter == null) {
    runtime.getReporter().handle(Event.error(String.format("String_Node_Str",queryOptions.outputFormat,OutputFormatter.formatterNames(formatters))));
    return ExitCode.COMMAND_LINE_ERROR;
  }
  String query=Joiner.on(' ').join(options.getResidue());
  Set<Setting> settings=queryOptions.toSettings();
  AbstractBlazeQueryEnvironment<Target> env=newQueryEnvironment(runtime,queryOptions.keepGoing,QueryOutputUtils.orderResults(queryOptions,formatter),queryOptions.universeScope,queryOptions.loadingPhaseThreads,settings);
  QueryExpression expr;
  try {
    expr=QueryExpression.parse(query,env);
  }
 catch (  QueryException e) {
    runtime.getReporter().handle(Event.error(null,"String_Node_Str" + query + "String_Node_Str"+ e.getMessage()));
    return ExitCode.COMMAND_LINE_ERROR;
  }
  QueryEvalResult<Target> result;
  try {
    result=env.evaluateQuery(expr);
  }
 catch (  QueryException|InterruptedException e) {
    runtime.getReporter().handle(Event.error(e.getMessage() == null ? e.toString() : e.getMessage()));
    return ExitCode.ANALYSIS_FAILURE;
  }
  runtime.getReporter().switchToAnsiAllowingHandler();
  PrintStream output=new PrintStream(runtime.getReporter().getOutErr().getOutputStream());
  try {
    QueryOutputUtils.output(queryOptions,result,formatter,output,queryOptions.aspectDeps.createResolver(runtime.getPackageManager(),runtime.getReporter()));
  }
 catch (  ClosedByInterruptException|InterruptedException e) {
    runtime.getReporter().handle(Event.error("String_Node_Str"));
    return ExitCode.INTERRUPTED;
  }
catch (  IOException e) {
    runtime.getReporter().handle(Event.error("String_Node_Str" + e.getMessage()));
    return ExitCode.LOCAL_ENVIRONMENTAL_ERROR;
  }
 finally {
    output.flush();
  }
  if (result.getResultSet().isEmpty()) {
    runtime.getReporter().handle(Event.info("String_Node_Str"));
  }
  return result.getSuccess() ? ExitCode.SUCCESS : ExitCode.PARTIAL_ANALYSIS_FAILURE;
}