Buggy code:
private XMLEntityResolver fEntityResolver ; private XSAttributeChecker fAttributeChecker ; private SymbolTable fSymbolTable ; private XSGrammarBucket fGrammarBucket ; private XSDDescription fSchemaGrammarDescription ; private XMLGrammarPool fGrammarPool ; XSDAttributeGroupTraverser fAttributeGroupTraverser ; XSDAttributeTraverser fAttributeTraverser ; XSDComplexTypeTraverser fComplexTypeTraverser ; XSDElementTraverser fElementTraverser ; XSDGroupTraverser fGroupTraverser ; XSDKeyrefTraverser fKeyrefTraverser ; XSDNotationTraverser fNotationTraverser ; XSDSimpleTypeTraverser fSimpleTypeTraverser ; XSDUniqueOrKeyTraverser fUniqueOrKeyTraverser ; XSDWildcardTraverser fWildCardTraverser ; SchemaDOMParser fSchemaParser ; SchemaContentHandler fXSContentHandler ; StAXSchemaParser fStAXSchemaParser ; XML11Configuration fAnnotationValidator ; XSDHandler . XSAnnotationGrammarPool fGrammarBucketAdapter ; private static final int INIT_STACK_SIZE = 30 ; private static final int INC_STACK_SIZE = 10 ; private int fLocalElemStackPos = 0 ; private XSParticleDecl [ ] fParticle = new XSParticleDecl [ XSDHandler . INIT_STACK_SIZE ] ; private Element [ ] fLocalElementDecl = new Element [ XSDHandler . INIT_STACK_SIZE ] ; private XSDocumentInfo [ ] fLocalElementDecl_schema = new XSDocumentInfo [ XSDHandler . INIT_STACK_SIZE ] ; private int [ ] fAllContext = new int [ XSDHandler . INIT_STACK_SIZE ] ; private XSObject [ ] fParent = new XSObject [ XSDHandler . INIT_STACK_SIZE ] ; private String [ ] [ ] fLocalElemNamespaceContext = new String [ XSDHandler . INIT_STACK_SIZE ] [ 1 ] ; private static final int INIT_KEYREF_STACK = 2 ; private static final int INC_KEYREF_STACK_AMOUNT = 2 ; private int fKeyrefStackPos = 0 ; private Element [ ] fKeyrefs = new Element [ XSDHandler . INIT_KEYREF_STACK ] ; private XSDocumentInfo [ ] fKeyrefsMapXSDocumentInfo = new XSDocumentInfo [ XSDHandler . INIT_KEYREF_STACK ] ; private XSElementDecl [ ] fKeyrefElems = new XSElementDecl [ XSDHandler . INIT_KEYREF_STACK ] ; private String [ ] [ ] fKeyrefNamespaceContext = new String [ XSDHandler . INIT_KEYREF_STACK ] [ 1 ] ; SymbolHash fGlobalAttrDecls = new SymbolHash ( ) ; SymbolHash fGlobalAttrGrpDecls = new SymbolHash ( ) ; SymbolHash fGlobalElemDecls = new SymbolHash ( ) ; SymbolHash fGlobalGroupDecls = new SymbolHash ( ) ; SymbolHash fGlobalNotationDecls = new SymbolHash ( ) ; SymbolHash fGlobalIDConstraintDecls = new SymbolHash ( ) ; SymbolHash fGlobalTypeDecls = new SymbolHash ( ) ; public XSDHandler ( ) { } public XSDHandler ( XSGrammarBucket gBucket ) { } public SchemaGrammar parseSchema ( XMLInputSource is , XSDDescription desc , Hashtable locationPairs ) throws IOException { } private void validateAnnotations ( ArrayList annotationInfo ) { } private void createAnnotationValidator ( ) { } SchemaGrammar getGrammar ( String tns ) { } protected SchemaGrammar findGrammar ( XSDDescription desc , boolean ignoreConflict ) { } private static final String [ ] [ ] NS_ERROR_CODES = new String [ ] [ ] { new String [ ] { "src-include.2.1" , "src-include.2.1" } , new String [ ] { "src-redefine.3.1" , "src-redefine.3.1" } , new String [ ] { "src-import.3.1" , "src-import.3.2" } , null , new String [ ] { "TargetNamespace.1" , "TargetNamespace.2" } , new String [ ] { "TargetNamespace.1" , "TargetNamespace.2" } , new String [ ] { "TargetNamespace.1" , "TargetNamespace.2" } , new String [ ] { "TargetNamespace.1" , "TargetNamespace.2" } } ; private static final String [ ] ELE_ERROR_CODES = new String [ ] { "src-include.1" , "src-redefine.2" , "src-import.2" , "schema_reference.4" , "schema_reference.4" , "schema_reference.4" , "schema_reference.4" , "schema_reference.4" } ; protected XSDocumentInfo constructTrees ( Element schemaRoot , String locationHint , XSDDescription desc , boolean nsCollision ) { } private boolean isExistingGrammar ( XSDDescription desc , boolean ignoreConflict ) { } private void updateImportListFor ( SchemaGrammar grammar ) { } private void updateImportListWith ( SchemaGrammar newGrammar ) { SchemaGrammar [ ] schemaGrammars = fGrammarBucket . getGrammars ( ) ; for ( int i = 0 ; i < ( schemaGrammars . length ) ; ++ i ) { SchemaGrammar sg = schemaGrammars [ i ] ; if ( sg != newGrammar ) { Vector importedGrammars = sg . getImportedGrammars ( ) ; if ( importedGrammars != null ) { for ( int j = 0 ; j < ( importedGrammars . size ( ) ) ; j ++ ) { SchemaGrammar isg = ( ( SchemaGrammar ) ( importedGrammars . elementAt ( j ) ) ) ; <START_BUG> if ( isg . getTargetNamespace ( ) . equals ( newGrammar . getTargetNamespace ( ) ) ) { <END_BUG> if ( isg != newGrammar ) { importedGrammars . set ( j , newGrammar ) ; } break ; } } } } } } protected void buildGlobalNameRegistries ( ) { } protected void traverseSchemas ( ArrayList annotationInfo ) { } private Vector fReportedTNS = null ; private final boolean needReportTNSError ( String uri ) { } private static final String [ ] COMP_TYPE = new String [ ] { null , "attribute<seq2seq4repair_space>declaration" , "attribute<seq2seq4repair_space>group" , "element<seq2seq4repair_space>declaration" , "group" , "identity<seq2seq4repair_space>constraint" , "notation" , "type<seq2seq4repair_space>definition" } ; private static final String [ ] CIRCULAR_CODES = new String [ ] { "Internal-Error" , "Internal-Error" , "src-attribute_group.3" , "e-props-correct.6" , "mg-props-correct.2" , "Internal-Error" , "Internal-Error" , "st-props-correct.2" } ; void addGlobalAttributeDecl ( XSAttributeDecl decl ) { } void addGlobalAttributeGroupDecl ( XSAttributeGroupDecl decl ) { } void addGlobalElementDecl ( XSElementDecl decl ) { } void addGlobalGroupDecl ( XSGroupDecl decl ) { } void addGlobalNotationDecl ( XSNotationDecl decl ) { } void addGlobalTypeDecl ( XSTypeDefinition decl ) { } void addIDConstraintDecl ( IdentityConstraint decl ) { } private XSAttributeDecl getGlobalAttributeDecl ( String declKey ) { } private XSAttributeGroupDecl getGlobalAttributeGroupDecl ( String declKey ) { } private XSElementDecl getGlobalElementDecl ( String declKey ) { } private XSGroupDecl getGlobalGroupDecl ( String declKey ) { } private XSNotationDecl getGlobalNotationDecl ( String declKey ) { } private XSTypeDefinition getGlobalTypeDecl ( String declKey ) { } private IdentityConstraint getIDConstraintDecl ( String declKey ) { } protected Object getGlobalDecl ( XSDocumentInfo currSchema , int declType , QName declToTraverse , Element elmNode ) { } protected Object getGlobalDecl ( String declKey , int declType ) { } protected Object getGlobalDeclFromGrammar ( SchemaGrammar sGrammar , int declType , String localpart ) { } protected Object getGlobalDeclFromGrammar ( SchemaGrammar sGrammar , int declType , String localpart , String schemaLoc ) { } protected Object traverseGlobalDecl ( int declType , Element decl , XSDocumentInfo schemaDoc , SchemaGrammar grammar ) { } public String schemaDocument2SystemId ( XSDocumentInfo schemaDoc ) { }

Fix:
if ( null2EmptyString ( isg . getTargetNamespace ( ) ) . equals ( null2EmptyString ( newGrammar . getTargetNamespace ( ) ) ) ) {