Program: 47892
Project: 47892
Buggy source:
@Override public int run(CommandLine cmd) throws Exception {
  int result=super.run(cmd);
  if (result != 0) {
    return result;
  }
  lilyClient=new LilyClient(zkConnectionString,60000);
  Repository repository=PureRepository.wrap(lilyClient.getRepository());
  typeManager=repository.getTypeManager();
  Configuration hbaseConf=HBaseConfiguration.create();
  hbaseConf.set("String_Node_Str",zkConnectionString);
  IndexManager indexManager=new IndexManager(hbaseConf,new HBaseTableFactoryImpl(hbaseConf));
  LinkIndex linkIndex=new LinkIndex(indexManager,repository);
  boolean incoming=true;
  if (cmd.hasOption(indexOption.getOpt())) {
    String index=cmd.getOptionValue(indexOption.getOpt());
    if (index.equals("String_Node_Str") || index.equals("String_Node_Str")) {
      incoming=true;
    }
 else     if (index.equals("String_Node_Str") || index.equals("String_Node_Str")) {
      incoming=false;
    }
 else {
      System.err.println("String_Node_Str" + index);
      return -1;
    }
  }
  String recordIdParam=cmd.getOptionValue(recordIdOption.getOpt());
  if (recordIdParam == null) {
    System.out.println("String_Node_Str" + recordIdOption.getOpt());
    return 1;
  }
  RecordId recordId=repository.getIdGenerator().fromString(recordIdParam);
  SchemaId vtagId=null;
  if (cmd.hasOption(vtagOption.getOpt())) {
    String vtagParam=cmd.getOptionValue(vtagOption.getOpt());
    vtagId=typeManager.getFieldTypeByName(new QName("String_Node_Str",vtagParam)).getId();
  }
  SchemaId fieldId=null;
  if (cmd.hasOption(fieldOption.getOpt())) {
    if (vtagId == null) {
      System.err.println("String_Node_Str");
      return -1;
    }
    String fieldParam=cmd.getOptionValue(fieldOption.getOpt());
    FieldType field=typeManager.getFieldTypeByName(QName.fromString(fieldParam));
    fieldId=field.getId();
    if (!field.getValueType().getDeepestValueType().getBaseName().equals("String_Node_Str")) {
      System.err.println("String_Node_Str" + field.getName() + "String_Node_Str");
      return -1;
    }
  }
  if (incoming) {
    System.out.println("String_Node_Str");
    System.out.println("String_Node_Str" + recordId);
    System.out.println("String_Node_Str" + vtagId + getFieldTypeNameSuffix(vtagId));
    System.out.println("String_Node_Str" + fieldId + getFieldTypeNameSuffix(fieldId));
    System.out.println();
    if (fieldId != null) {
      Set<RecordId> records=linkIndex.getReferrers(recordId,vtagId,fieldId);
      printRecords(records);
    }
 else {
      Set<FieldedLink> fieldedLinks=linkIndex.getFieldedReferrers(recordId,vtagId);
      printFieldedLinks(fieldedLinks);
    }
  }
 else {
    System.out.println("String_Node_Str");
    System.out.println("String_Node_Str" + recordId);
    System.out.println("String_Node_Str" + vtagId + getFieldTypeNameSuffix(vtagId));
    System.out.println("String_Node_Str" + fieldId + getFieldTypeNameSuffix(fieldId));
    System.out.println();
    if (fieldId != null) {
      Set<RecordId> records=linkIndex.getForwardLinks(recordId,vtagId,fieldId);
      printRecords(records);
    }
 else {
      Set<FieldedLink> fieldedLinks=linkIndex.getFieldedForwardLinks(recordId,vtagId);
      printFieldedLinks(fieldedLinks);
    }
  }
  return 0;
}

Fixed version (ground truth):
@Override public int run(CommandLine cmd) throws Exception {
  int result=super.run(cmd);
  if (result != 0) {
    return result;
  }
  lilyClient=new LilyClient(zkConnectionString,60000);
  Repository repository=PureRepository.wrap(lilyClient.getRepository());
  typeManager=repository.getTypeManager();
  Configuration hbaseConf=HBaseConfiguration.create();
  hbaseConf.set("String_Node_Str",zkConnectionString);
  IndexManager indexManager=new IndexManager(hbaseConf,new HBaseTableFactoryImpl(hbaseConf));
  LinkIndex linkIndex=new LinkIndex(indexManager,lilyClient);
  boolean incoming=true;
  if (cmd.hasOption(indexOption.getOpt())) {
    String index=cmd.getOptionValue(indexOption.getOpt());
    if (index.equals("String_Node_Str") || index.equals("String_Node_Str")) {
      incoming=true;
    }
 else     if (index.equals("String_Node_Str") || index.equals("String_Node_Str")) {
      incoming=false;
    }
 else {
      System.err.println("String_Node_Str" + index);
      return -1;
    }
  }
  String recordIdParam=cmd.getOptionValue(recordIdOption.getOpt());
  if (recordIdParam == null) {
    System.out.println("String_Node_Str" + recordIdOption.getOpt());
    return 1;
  }
  RecordId recordId=repository.getIdGenerator().fromString(recordIdParam);
  SchemaId vtagId=null;
  if (cmd.hasOption(vtagOption.getOpt())) {
    String vtagParam=cmd.getOptionValue(vtagOption.getOpt());
    vtagId=typeManager.getFieldTypeByName(new QName("String_Node_Str",vtagParam)).getId();
  }
  SchemaId fieldId=null;
  if (cmd.hasOption(fieldOption.getOpt())) {
    if (vtagId == null) {
      System.err.println("String_Node_Str");
      return -1;
    }
    String fieldParam=cmd.getOptionValue(fieldOption.getOpt());
    FieldType field=typeManager.getFieldTypeByName(QName.fromString(fieldParam));
    fieldId=field.getId();
    if (!field.getValueType().getDeepestValueType().getBaseName().equals("String_Node_Str")) {
      System.err.println("String_Node_Str" + field.getName() + "String_Node_Str");
      return -1;
    }
  }
  if (incoming) {
    System.out.println("String_Node_Str");
    System.out.println("String_Node_Str" + recordId);
    System.out.println("String_Node_Str" + vtagId + getFieldTypeNameSuffix(vtagId));
    System.out.println("String_Node_Str" + fieldId + getFieldTypeNameSuffix(fieldId));
    System.out.println();
    if (fieldId != null) {
      Set<RecordId> records=linkIndex.getReferrers(recordId,vtagId,fieldId);
      printRecords(records);
    }
 else {
      Set<FieldedLink> fieldedLinks=linkIndex.getFieldedReferrers(recordId,vtagId);
      printFieldedLinks(fieldedLinks);
    }
  }
 else {
    System.out.println("String_Node_Str");
    System.out.println("String_Node_Str" + recordId);
    System.out.println("String_Node_Str" + vtagId + getFieldTypeNameSuffix(vtagId));
    System.out.println("String_Node_Str" + fieldId + getFieldTypeNameSuffix(fieldId));
    System.out.println();
    if (fieldId != null) {
      Set<RecordId> records=linkIndex.getForwardLinks(recordId,vtagId,fieldId);
      printRecords(records);
    }
 else {
      Set<FieldedLink> fieldedLinks=linkIndex.getFieldedForwardLinks(recordId,vtagId);
      printFieldedLinks(fieldedLinks);
    }
  }
  return 0;
}