Program: 146044
Project: 146044
Buggy source:
@Override public void validate(ValidationHandler handler){
  int errorCount=handler.getErrorCount();
  fieldType.validate(handler);
  if (handler.getErrorCount() > errorCount) {
    return;
  }
  TypeMetadata currentType=fieldType;
  if (!XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(currentType.getNamespace())) {
    while (!currentType.getSuperTypes().isEmpty()) {
      TypeMetadata superType=currentType.getSuperTypes().iterator().next();
      if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(superType.getNamespace()) && ("String_Node_Str".equals(superType.getName()) || "String_Node_Str".equals(superType.getName()))) {
        break;
      }
      currentType=superType;
      errorCount=handler.getErrorCount();
      currentType.validate(handler);
      if (handler.getErrorCount() > errorCount) {
        return;
      }
    }
  }
  if (!"String_Node_Str".equals(currentType.getName())) {
    handler.error(this,"String_Node_Str" + getName() + "String_Node_Str",this.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),this.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),this.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.FOREIGN_KEY_NOT_STRING_TYPED);
  }
  referencedField.validate(handler);
  if (foreignKeyInfo != null) {
    errorCount=handler.getErrorCount();
    foreignKeyInfo.validate(handler);
    if (handler.getErrorCount() > errorCount) {
      return;
    }
    if (!isPrimitiveTypeField(foreignKeyInfo)) {
      handler.warning(foreignKeyInfo,"String_Node_Str",foreignKeyInfo.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),foreignKeyInfo.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),foreignKeyInfo.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.FOREIGN_KEY_INFO_NOT_STRING_TYPED);
    }
    if (foreignKeyInfo.isMany()) {
      handler.warning(foreignKeyInfo,"String_Node_Str",foreignKeyInfo.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),foreignKeyInfo.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),foreignKeyInfo.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.FOREIGN_KEY_INFO_REPEATABLE);
    }
  }
}

Fixed version (ground truth):
@Override public void validate(final ValidationHandler handler){
  int errorCount=handler.getErrorCount();
  fieldType.validate(handler);
  if (handler.getErrorCount() > errorCount) {
    return;
  }
  TypeMetadata currentType=fieldType;
  if (!XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(currentType.getNamespace())) {
    while (!currentType.getSuperTypes().isEmpty()) {
      TypeMetadata superType=currentType.getSuperTypes().iterator().next();
      if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(superType.getNamespace()) && ("String_Node_Str".equals(superType.getName()) || "String_Node_Str".equals(superType.getName()))) {
        break;
      }
      currentType=superType;
      errorCount=handler.getErrorCount();
      currentType.validate(handler);
      if (handler.getErrorCount() > errorCount) {
        return;
      }
    }
  }
  if (!"String_Node_Str".equals(currentType.getName())) {
    handler.error(this,"String_Node_Str" + getName() + "String_Node_Str",this.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),this.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),this.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.FOREIGN_KEY_NOT_STRING_TYPED);
  }
  referencedField.validate(new ValidationHandler(){
    @Override public void error(    TypeMetadata type,    String message,    Element element,    int lineNumber,    int columnNumber,    ValidationError error){
      handler.error(type,message,element,lineNumber,columnNumber,error);
    }
    public void warning(    TypeMetadata type,    String message,    Element element,    int lineNumber,    int columnNumber,    ValidationError error){
      handler.warning(type,message,element,lineNumber,columnNumber,error);
    }
    public void end(){
      handler.end();
    }
    public int getErrorCount(){
      return handler.getErrorCount();
    }
    public void fatal(    FieldMetadata field,    String message,    Element element,    int lineNumber,    int columnNumber,    ValidationError error){
      handler.fatal(field,message,element,lineNumber,columnNumber,error);
    }
    @Override public void error(    FieldMetadata field,    String message,    Element element,    int lineNumber,    int columnNumber,    ValidationError error){
      if (error == ValidationError.TYPE_DOES_NOT_EXIST) {
        handler.error(ReferenceFieldMetadata.this,message,element,lineNumber,columnNumber,error);
      }
 else {
        handler.error(field,message,element,lineNumber,columnNumber,error);
      }
    }
    public void warning(    FieldMetadata field,    String message,    Element element,    int lineNumber,    int columnNumber,    ValidationError error){
      handler.warning(field,message,element,lineNumber,columnNumber,error);
    }
    public void fatal(    TypeMetadata type,    String message,    Element element,    int lineNumber,    int columnNumber,    ValidationError error){
      handler.fatal(type,message,element,lineNumber,columnNumber,error);
    }
  }
);
  if (foreignKeyInfo != null) {
    errorCount=handler.getErrorCount();
    foreignKeyInfo.validate(handler);
    if (handler.getErrorCount() > errorCount) {
      return;
    }
    if (!isPrimitiveTypeField(foreignKeyInfo)) {
      handler.warning(foreignKeyInfo,"String_Node_Str",foreignKeyInfo.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),foreignKeyInfo.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),foreignKeyInfo.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.FOREIGN_KEY_INFO_NOT_STRING_TYPED);
    }
    if (foreignKeyInfo.isMany()) {
      handler.warning(foreignKeyInfo,"String_Node_Str",foreignKeyInfo.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),foreignKeyInfo.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),foreignKeyInfo.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.FOREIGN_KEY_INFO_REPEATABLE);
    }
  }
}