Buggy code:
if ( entity == null ) { if ( ( fEntityHandler ) != null ) { String encoding = null ; fResourceIdentifier . clear ( ) ; fEntityAugs . removeAllItems ( ) ; fEntityAugs . putItem ( ENTITY_SKIPPED , Boolean . TRUE ) ; fEntityHandler . startEntity ( entityName , fResourceIdentifier , encoding , fEntityAugs ) ; fEntityAugs . removeAllItems ( ) ; fEntityAugs . putItem ( ENTITY_SKIPPED , Boolean . TRUE ) ; fEntityHandler . endEntity ( entityName , fEntityAugs ) ; } return ; } boolean external = entity . isExternal ( ) ; if ( external && ( ( ( fValidationManager ) == null ) || ( ! ( fValidationManager . isCachedDTD ( ) ) ) ) ) { boolean unparsed = entity . isUnparsed ( ) ; boolean parameter = entityName . startsWith ( "%" ) ; boolean general = ! parameter ; if ( ( unparsed || ( general && ( ! ( fExternalGeneralEntities ) ) ) ) || ( parameter && ( ! ( fExternalParameterEntities ) ) ) ) { if ( ( fEntityHandler ) != null ) { fResourceIdentifier . clear ( ) ; final String encoding = null ; XMLEntityManager . ExternalEntity externalEntity = ( ( XMLEntityManager . ExternalEntity ) ( entity ) ) ; String extLitSysId = ( ( externalEntity . entityLocation ) != null ) ? externalEntity . entityLocation . getLiteralSystemId ( ) : null ; String extBaseSysId = ( ( externalEntity . entityLocation ) != null ) ? externalEntity . entityLocation . getBaseSystemId ( ) : null ; String expandedSystemId = XMLEntityManager . expandSystemId ( extLitSysId , extBaseSysId , false ) ; fResourceIdentifier . setValues ( ( ( externalEntity . entityLocation ) != null ? externalEntity . entityLocation . getPublicId ( ) : null ) , extLitSysId , extBaseSysId , expandedSystemId ) ; fEntityAugs . removeAllItems ( ) ; fEntityAugs . putItem ( ENTITY_SKIPPED , Boolean . TRUE ) ; fEntityHandler . startEntity ( entityName , fResourceIdentifier , encoding , fEntityAugs ) ; fEntityAugs . removeAllItems ( ) ; fEntityAugs . putItem ( ENTITY_SKIPPED , Boolean . TRUE ) ; fEntityHandler . endEntity ( entityName , fEntityAugs ) ; } return ; } } int size = fEntityStack . size ( ) ; for ( int i = size ; i >= 0 ; i -- ) { XMLEntityManager . Entity activeEntity = ( i == size ) ? fCurrentEntity : ( ( XMLEntityManager . Entity ) ( fEntityStack . elementAt ( i ) ) ) ; if ( ( activeEntity . name ) == entityName ) { String path = entityName ; for ( int j = i + 1 ; j < size ; j ++ ) { activeEntity = ( ( XMLEntityManager . Entity ) ( fEntityStack . elementAt ( j ) ) ) ; path = ( path + "<seq2seq4repair_space>-><seq2seq4repair_space>" ) + ( activeEntity . name ) ; } path = ( path + "<seq2seq4repair_space>-><seq2seq4repair_space>" ) + ( fCurrentEntity . name ) ; path = ( path + "<seq2seq4repair_space>-><seq2seq4repair_space>" ) + entityName ; fErrorReporter . reportError ( XML_DOMAIN , "RecursiveReference" , new Object [ ] { entityName , path } , SEVERITY_FATAL_ERROR ) ; if ( ( fEntityHandler ) != null ) { fResourceIdentifier . clear ( ) ; final String encoding = null ; if ( external ) { XMLEntityManager . ExternalEntity externalEntity = ( ( XMLEntityManager . ExternalEntity ) ( entity ) ) ; String extLitSysId = ( ( externalEntity . entityLocation ) != null ) ? externalEntity . entityLocation . getLiteralSystemId ( ) : null ; String extBaseSysId = ( ( externalEntity . entityLocation ) != null ) ? externalEntity . entityLocation . getBaseSystemId ( ) : null ; String expandedSystemId = XMLEntityManager . expandSystemId ( extLitSysId , extBaseSysId , false ) ; fResourceIdentifier . setValues ( ( ( externalEntity . entityLocation ) != null ? externalEntity . entityLocation . getPublicId ( ) : null ) , extLitSysId , extBaseSysId , expandedSystemId ) ; } fEntityAugs . removeAllItems ( ) ; fEntityAugs . putItem ( ENTITY_SKIPPED , Boolean . TRUE ) ; fEntityHandler . startEntity ( entityName , fResourceIdentifier , encoding , fEntityAugs ) ; fEntityAugs . removeAllItems ( ) ; fEntityAugs . putItem ( ENTITY_SKIPPED , Boolean . TRUE ) ; <START_BUG> fEntityHandler . endEntity ( entityName , null ) ; <END_BUG> } return ; } } XMLInputSource xmlInputSource = null ; if ( external ) { XMLEntityManager . ExternalEntity externalEntity = ( ( XMLEntityManager . ExternalEntity ) ( entity ) ) ; xmlInputSource = resolveEntity ( externalEntity . entityLocation ) ; } else { XMLEntityManager . InternalEntity internalEntity = ( ( XMLEntityManager . InternalEntity ) ( entity ) ) ; Reader reader = new StringReader ( internalEntity . text ) ; xmlInputSource = new XMLInputSource ( null , null , null , reader , null ) ; } startEntity ( entityName , xmlInputSource , literal , external ) ; } public void startDocumentEntity ( XMLInputSource xmlInputSource ) throws IOException , XNIException { } public void startDTDEntity ( XMLInputSource xmlInputSource ) throws IOException , XNIException { } public void startExternalSubset ( ) { } public void endExternalSubset ( ) { } public void startEntity ( String name , XMLInputSource xmlInputSource , boolean literal , boolean isExternal ) throws IOException , XNIException { } public String setupCurrentEntity ( String name , XMLInputSource xmlInputSource , boolean literal , boolean isExternal ) throws IOException , XNIException { } public void setScannerVersion ( short version ) { } public XMLEntityScanner getEntityScanner ( ) { } protected Stack fReaderStack = new Stack ( ) ; public void closeReaders ( ) { } public void reset ( XMLComponentManager componentManager ) throws XMLConfigurationException { } public void reset ( ) { } public String [ ] getRecognizedFeatures ( ) { } public void setFeature ( String featureId , boolean state ) throws XMLConfigurationException { } public String [ ] getRecognizedProperties ( ) { } public void setProperty ( String propertyId , Object value ) throws XMLConfigurationException { }

Fix:
fEntityHandler . endEntity ( entityName , fEntityAugs ) ;