Buggy code:
} private XSDHandler . LocationResolver fLocationResolver = new XSDHandler . LocationResolver ( ) ; 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 ; DOMParser fSchemaParser ; final DOMNodePool fDOMPool = new DOMNodePool ( ) ; 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 int [ ] fAllContext = new int [ XSDHandler . INIT_STACK_SIZE ] ; private XSComplexTypeDecl [ ] fEnclosingCT = new XSComplexTypeDecl [ 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 XSElementDecl [ ] fKeyrefElems = new XSElementDecl [ XSDHandler . INIT_KEYREF_STACK ] ; private String [ ] [ ] fKeyrefNamespaceContext = new String [ XSDHandler . INIT_KEYREF_STACK ] [ 1 ] ; public XSDHandler ( XSGrammarBucket gBucket ) { } public SchemaGrammar parseSchema ( XSDDescription desc ) { } public SchemaGrammar parseSchema ( XMLInputSource is , XSDDescription desc ) { fDOMPool . reset ( ) ; fSchemaParser . setPool ( fDOMPool ) ; SchemaGrammar grammar = findGrammar ( desc ) ; if ( grammar != null ) return grammar ; prepare ( ) ; String schemaNamespace = desc . getTargetNamespace ( ) ; if ( schemaNamespace != null ) { schemaNamespace = fSymbolTable . addSymbol ( schemaNamespace ) ; } short referType = desc . getContextType ( ) ; Document schemaRoot = getSchema ( schemaNamespace , is , ( referType == ( XSDDescription . CONTEXT_PREPARSE ) ) , referType , null ) ; if ( schemaRoot == null ) { return null ; } fRoot = constructTrees ( schemaRoot , is . getSystemId ( ) , desc ) ; if ( ( fRoot ) == null ) { return null ; } buildGlobalNameRegistries ( ) ; traverseSchemas ( ) ; traverseLocalElements ( ) ; resolveKeyRefs ( ) ; for ( int i = ( fAllTNSs . size ( ) ) - 1 ; i >= 0 ; i -- ) { String tns = ( ( String ) ( fAllTNSs . elementAt ( i ) ) ) ; Vector ins = ( ( Vector ) ( fImportMap . get ( tns ) ) ) ; SchemaGrammar sg = fGrammarBucket . getGrammar ( emptyString2Null ( tns ) ) ; if ( sg == null ) continue ; SchemaGrammar isg ; int count = 0 ; for ( int j = 0 ; j < ( ins . size ( ) ) ; j ++ ) { isg = fGrammarBucket . getGrammar ( ( ( String ) ( ins . elementAt ( j ) ) ) ) ; if ( isg != null ) ins . setElementAt ( isg , ( count ++ ) ) ; } ins . setSize ( count ) ; sg . setImportedGrammars ( ins ) ; } <START_BUG> return fGrammarBucket . getGrammar ( schemaNamespace ) ; <END_BUG> } protected SchemaGrammar findGrammar ( XSDDescription desc ) { } 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 ( Document schemaRoot , String locationHint , XSDDescription desc ) { } protected void buildGlobalNameRegistries ( ) { } protected void traverseSchemas ( ) { } private static final String [ ] COMP_TYPE = new String [ ] { null , "attribute<seq2seq4repair_space>declaration" , "attribute<seq2seq4repair_space>group" , "elment<seq2seq4repair_space>declaration" , "group" , "identity<seq2seq4repair_space>constraint" , "notation" , "type<seq2seq4repair_space>definition" } ; protected Object getGlobalDecl ( XSDocumentInfo currSchema , int declType , QName declToTraverse , Element elmNode ) { } Object getGrpOrAttrGrpRedefinedByRestriction ( int type , QName name , XSDocumentInfo currSchema , Element elmNode ) { } protected void resolveKeyRefs ( ) { } protected Hashtable getIDRegistry ( ) { } protected void storeKeyRef ( Element keyrefToStore , XSDocumentInfo schemaDoc , XSElementDecl currElemDecl ) { } private static final String [ ] DOC_ERROR_CODES = new String [ ] { "src-include.0" , "src-redefine.0" , "src-import.0" , "schema_reference.4" , "schema_reference.4" , "schema_reference.4" , "schema_reference.4" , "schema_reference.4" } ; private Document getSchema ( XSDDescription desc , boolean mustResolve , Element referElement ) { } private Document getSchema ( String schemaNamespace , XMLInputSource schemaSource , boolean mustResolve , short referType , Element referElement ) { } private void createTraversers ( ) { } void prepare ( ) { } public void setDeclPool ( XSDeclarationPool declPool ) { } public void reset ( XMLErrorReporter errorReporter , XMLEntityResolver entityResolver , SymbolTable symbolTable , String externalSchemaLocation , String externalNoNSSchemaLocation , XMLGrammarPool grammarPool ) { } void traverseLocalElements ( ) { } void fillInLocalElemInfo ( Element elmDecl , XSDocumentInfo schemaDoc , int allContextFlags , XSComplexTypeDecl enclosingCT , XSParticleDecl particle ) { } void checkForDuplicateNames ( String qName , Hashtable registry , Element currComp , XSDocumentInfo currSchema ) { }

Fix:
return fGrammarBucket . getGrammar ( fRoot . fTargetNamespace ) ;