Program: 68713
Project: 68713
Buggy source:
private void addTypeToListIfNeeded(Type sourceType,Type targetType){
  if ((targetType.getURI() != null) && !targetType.getURI().equals(SDOConstants.SDO_URL) && !targetType.getURI().equals(SDOConstants.SDOJAVA_URL)&& !targetType.getURI().equals(SDOConstants.SDOXML_URL)) {
    boolean alreadyGenerated=allTypes.contains(targetType);
    String schemaLocation=null;
    if (namespaceToSchemaLocation != null) {
      schemaLocation=(String)namespaceToSchemaLocation.get(targetType.getURI());
      if (targetType.getURI().equals(generatedSchema.getTargetNamespace())) {
        if (!alreadyGenerated) {
          allTypes.add(targetType);
        }
      }
 else {
        Import theImport=(Import)generatedSchema.getImports().get(schemaLocation);
        if (theImport == null) {
          theImport=new Import();
          theImport.setSchemaLocation(schemaLocation);
          theImport.setNamespace(targetType.getURI());
          generatedSchema.getImports().put(schemaLocation,theImport);
        }
      }
    }
 else     if (schemaLocationResolver != null) {
      schemaLocation=schemaLocationResolver.resolveSchemaLocation(sourceType,targetType);
      if (schemaLocation != null) {
        if (targetType.getURI().equals(generatedSchema.getTargetNamespace())) {
          Include include=(Include)generatedSchema.getIncludes().get(schemaLocation);
          if (include == null) {
            include=new Include();
            include.setSchemaLocation(schemaLocation);
            generatedSchema.getIncludes().put(schemaLocation,include);
            allTypes.remove(targetType);
          }
        }
 else {
          Import theImport=(Import)generatedSchema.getImports().get(schemaLocation);
          if (theImport == null) {
            theImport=new Import();
            theImport.setSchemaLocation(schemaLocation);
            theImport.setNamespace(targetType.getURI());
            generatedSchema.getImports().put(schemaLocation,theImport);
          }
        }
      }
 else {
        if (!alreadyGenerated) {
          if (targetType.getURI().equals(generatedSchema.getTargetNamespace())) {
            allTypes.add(targetType);
          }
        }
      }
    }
 else {
      if (!alreadyGenerated) {
        if (targetType.getURI().equals(generatedSchema.getTargetNamespace())) {
          allTypes.add(targetType);
        }
      }
    }
  }
}

Fixed version (ground truth):
private void addTypeToListIfNeeded(Type sourceType,Type targetType){
  if ((targetType.getURI() != null) && !targetType.getURI().equals(SDOConstants.SDO_URL) && !targetType.getURI().equals(SDOConstants.SDOJAVA_URL)&& !targetType.getURI().equals(SDOConstants.SDOXML_URL)) {
    boolean alreadyGenerated=allTypes.contains(targetType);
    String schemaLocation=null;
    if (namespaceToSchemaLocation != null) {
      schemaLocation=(String)namespaceToSchemaLocation.get(targetType.getURI());
      if (targetType.getURI().equals(generatedSchema.getTargetNamespace())) {
        if (!alreadyGenerated) {
          allTypes.add(targetType);
        }
      }
 else {
        if (!importExists(generatedSchema.getImports(),schemaLocation)) {
          Import theImport=new Import();
          theImport.setSchemaLocation(schemaLocation);
          theImport.setNamespace(targetType.getURI());
          generatedSchema.getImports().add(theImport);
        }
      }
    }
 else     if (schemaLocationResolver != null) {
      schemaLocation=schemaLocationResolver.resolveSchemaLocation(sourceType,targetType);
      if (schemaLocation != null) {
        if (targetType.getURI().equals(generatedSchema.getTargetNamespace())) {
          if (!importExists(generatedSchema.getIncludes(),schemaLocation)) {
            Include include=new Include();
            include.setSchemaLocation(schemaLocation);
            generatedSchema.getIncludes().add(include);
            allTypes.remove(targetType);
          }
        }
 else {
          if (!importExists(generatedSchema.getImports(),schemaLocation)) {
            Import theImport=new Import();
            theImport.setSchemaLocation(schemaLocation);
            theImport.setNamespace(targetType.getURI());
            generatedSchema.getImports().add(theImport);
          }
        }
      }
 else {
        if (!alreadyGenerated) {
          if (targetType.getURI().equals(generatedSchema.getTargetNamespace())) {
            allTypes.add(targetType);
          }
        }
      }
    }
 else {
      if (!alreadyGenerated) {
        if (targetType.getURI().equals(generatedSchema.getTargetNamespace())) {
          allTypes.add(targetType);
        }
      }
    }
  }
}