Program: 185270
Project: 185270
Buggy source:
public ThriftStructMetadataBuilder(ThriftCatalog catalog,Class<T> structClass){
  this.catalog=checkNotNull(catalog,"String_Node_Str");
  this.structClass=checkNotNull(structClass,"String_Node_Str");
  this.problems=new Problems(catalog.getMonitor());
  if (Modifier.isAbstract(structClass.getModifiers())) {
    problems.addError("String_Node_Str",structClass.getName());
  }
  if (!Modifier.isPublic(structClass.getModifiers())) {
    problems.addError("String_Node_Str",structClass.getName());
  }
  ThriftStruct annotation=structClass.getAnnotation(ThriftStruct.class);
  if (annotation != null) {
    if (!annotation.name().isEmpty()) {
      structName=annotation.name();
    }
 else {
      structName=structClass.getSimpleName();
    }
  }
 else {
    problems.addError("String_Node_Str",structClass.getName());
    structName=structClass.getSimpleName();
  }
  if (!annotation.builder().equals(void.class)) {
    builderClass=annotation.builder();
  }
 else {
    builderClass=null;
  }
  if (builderClass != null) {
    addConstructors(builderClass);
    addBuilderMethods();
    for (    Constructor<?> constructor : structClass.getConstructors()) {
      if (constructor.isAnnotationPresent(ThriftConstructor.class)) {
        problems.addWarning("String_Node_Str",structClass.getName(),constructor);
      }
    }
  }
 else {
    addConstructors(structClass);
  }
  if (builderClass != null) {
    addFields(builderClass,false,true);
    addFields(structClass,true,false);
  }
 else {
    addFields(structClass,true,true);
  }
  if (builderClass != null) {
    addMethods(builderClass,false,true);
    addMethods(structClass,true,false);
  }
 else {
    addMethods(structClass,true,true);
  }
  Multimap<String,FieldMetadata> fieldsByName=Multimaps.index(fields,getOrExtractThriftFieldName());
  for (  Entry<String,Collection<FieldMetadata>> entry : fieldsByName.asMap().entrySet()) {
    Collection<FieldMetadata> fields=entry.getValue();
    if (fields.size() <= 1) {
      continue;
    }
    short id=Iterables.find(transform(fields,getThriftFieldId()),notNull(),Short.MIN_VALUE);
    if (id != Short.MIN_VALUE) {
      for (      FieldMetadata field : fields) {
        field.setId(id);
      }
    }
  }
  Multimap<Short,FieldMetadata> fieldsById=Multimaps.index(fields,getThriftFieldId());
  for (  Entry<Short,Collection<FieldMetadata>> entry : fieldsById.asMap().entrySet()) {
    Short id=entry.getKey();
    Collection<FieldMetadata> fields=entry.getValue();
    if (id == null) {
      for (      FieldMetadata field : fields) {
        problems.addError("String_Node_Str",structName,field.getName());
      }
      continue;
    }
    Set<String> names=ImmutableSet.copyOf(filter(transform(fields,getThriftFieldName()),notNull()));
    String name;
    if (!names.isEmpty()) {
      if (names.size() > 1) {
        problems.addWarning("String_Node_Str",id,names);
      }
      name=names.iterator().next();
    }
 else {
      name=Iterables.find(transform(fields,extractThriftFieldName()),notNull());
    }
    for (    FieldMetadata field : fields) {
      field.setName(name);
    }
    Set<ThriftProtocolFieldType> protocolTypes=ImmutableSet.copyOf(filter(transform(fields,getThriftFieldProtocolType()),notNull()));
    if (protocolTypes.size() > 1) {
      problems.addError("String_Node_Str",id,protocolTypes);
      continue;
    }
    ThriftProtocolFieldType type=protocolTypes.iterator().next();
    for (    FieldMetadata field : fields) {
      field.setProtocolType(type);
    }
    Set<ThriftType> types=ImmutableSet.copyOf(filter(transform(fields,getThriftFieldType(catalog)),notNull()));
    if (!types.isEmpty()) {
      if (protocolTypes.size() > 1) {
        problems.addError("String_Node_Str",id,protocolTypes);
      }
    }
  }
}

Fixed version (ground truth):
public ThriftStructMetadataBuilder(ThriftCatalog catalog,Class<T> structClass){
  this.catalog=checkNotNull(catalog,"String_Node_Str");
  this.structClass=checkNotNull(structClass,"String_Node_Str");
  this.problems=new Problems(catalog.getMonitor());
  if (Modifier.isAbstract(structClass.getModifiers())) {
    problems.addError("String_Node_Str",structClass.getName());
  }
  if (!Modifier.isPublic(structClass.getModifiers())) {
    problems.addError("String_Node_Str",structClass.getName());
  }
  ThriftStruct annotation=structClass.getAnnotation(ThriftStruct.class);
  if (annotation != null) {
    if (!annotation.name().isEmpty()) {
      structName=annotation.name();
    }
 else {
      structName=structClass.getSimpleName();
    }
  }
 else {
    problems.addError("String_Node_Str",structClass.getName());
    structName=structClass.getSimpleName();
  }
  if (!annotation.builder().equals(void.class)) {
    builderClass=annotation.builder();
  }
 else {
    builderClass=null;
  }
  if (builderClass != null) {
    addConstructors(builderClass);
    addBuilderMethods();
    for (    Constructor<?> constructor : structClass.getConstructors()) {
      if (constructor.isAnnotationPresent(ThriftConstructor.class)) {
        problems.addWarning("String_Node_Str",structClass.getName(),constructor);
      }
    }
  }
 else {
    addConstructors(structClass);
  }
  if (builderClass != null) {
    addFields(builderClass,false,true);
    addFields(structClass,true,false);
  }
 else {
    addFields(structClass,true,true);
  }
  if (builderClass != null) {
    addMethods(builderClass,false,true);
    addMethods(structClass,true,false);
  }
 else {
    addMethods(structClass,true,true);
  }
  Multimap<String,FieldMetadata> fieldsByName=Multimaps.index(fields,getOrExtractThriftFieldName());
  for (  Entry<String,Collection<FieldMetadata>> entry : fieldsByName.asMap().entrySet()) {
    Collection<FieldMetadata> fields=entry.getValue();
    if (fields.size() <= 1) {
      continue;
    }
    short id=Iterables.getFirst(Optional.presentInstances(transform(fields,getThriftFieldId())),Short.MIN_VALUE);
    if (id != Short.MIN_VALUE) {
      for (      FieldMetadata field : fields) {
        field.setId(id);
      }
    }
  }
  Multimap<Optional<Short>,FieldMetadata> fieldsById=Multimaps.index(fields,getThriftFieldId());
  for (  Entry<Optional<Short>,Collection<FieldMetadata>> entry : fieldsById.asMap().entrySet()) {
    Short id=entry.getKey().orNull();
    Collection<FieldMetadata> fields=entry.getValue();
    if (id == null) {
      for (      FieldMetadata field : fields) {
        problems.addError("String_Node_Str",structName,field.getName());
      }
      continue;
    }
    Set<String> names=ImmutableSet.copyOf(filter(transform(fields,getThriftFieldName()),notNull()));
    String name;
    if (!names.isEmpty()) {
      if (names.size() > 1) {
        problems.addWarning("String_Node_Str",id,names);
      }
      name=names.iterator().next();
    }
 else {
      name=Iterables.find(transform(fields,extractThriftFieldName()),notNull());
    }
    for (    FieldMetadata field : fields) {
      field.setName(name);
    }
    Set<ThriftProtocolFieldType> protocolTypes=ImmutableSet.copyOf(filter(transform(fields,getThriftFieldProtocolType()),notNull()));
    if (protocolTypes.size() > 1) {
      problems.addError("String_Node_Str",id,protocolTypes);
      continue;
    }
    ThriftProtocolFieldType type=protocolTypes.iterator().next();
    for (    FieldMetadata field : fields) {
      field.setProtocolType(type);
    }
    Set<ThriftType> types=ImmutableSet.copyOf(filter(transform(fields,getThriftFieldType(catalog)),notNull()));
    if (!types.isEmpty()) {
      if (protocolTypes.size() > 1) {
        problems.addError("String_Node_Str",id,protocolTypes);
      }
    }
  }
}