Buggy code:
public class XMLEntityManager implements XMLComponent , XMLEntityResolver { public static final int DEFAULT_BUFFER_SIZE = 2048 ; protected static final String VALIDATION = ( Constants . SAX_FEATURE_PREFIX ) + ( Constants . VALIDATION_FEATURE ) ; protected static final String EXTERNAL_GENERAL_ENTITIES = ( Constants . SAX_FEATURE_PREFIX ) + ( Constants . EXTERNAL_GENERAL_ENTITIES_FEATURE ) ; protected static final String EXTERNAL_PARAMETER_ENTITIES = ( Constants . SAX_FEATURE_PREFIX ) + ( Constants . EXTERNAL_PARAMETER_ENTITIES_FEATURE ) ; protected static final String ALLOW_JAVA_ENCODINGS = ( Constants . XERCES_FEATURE_PREFIX ) + ( Constants . ALLOW_JAVA_ENCODINGS_FEATURE ) ; protected static final String SYMBOL_TABLE = ( Constants . XERCES_PROPERTY_PREFIX ) + ( Constants . SYMBOL_TABLE_PROPERTY ) ; protected static final String ERROR_REPORTER = ( Constants . XERCES_PROPERTY_PREFIX ) + ( Constants . ERROR_REPORTER_PROPERTY ) ; protected static final String ENTITY_RESOLVER = ( Constants . XERCES_PROPERTY_PREFIX ) + ( Constants . ENTITY_RESOLVER_PROPERTY ) ; private static final String [ ] RECOGNIZED_FEATURES = new String [ ] { XMLEntityManager . VALIDATION , XMLEntityManager . EXTERNAL_GENERAL_ENTITIES , XMLEntityManager . EXTERNAL_PARAMETER_ENTITIES , XMLEntityManager . ALLOW_JAVA_ENCODINGS } ; private static final String [ ] RECOGNIZED_PROPERTIES = new String [ ] { XMLEntityManager . SYMBOL_TABLE , XMLEntityManager . ERROR_REPORTER , XMLEntityManager . ENTITY_RESOLVER } ; private static final boolean DEBUG_BUFFER = false ; private static final boolean DEBUG_ENTITIES = false ; private static final boolean DEBUG_ENCODINGS = false ; private static final boolean DEBUG_RESOLVER = false ; protected boolean fValidation ; protected boolean fExternalGeneralEntities ; protected boolean fExternalParameterEntities ; protected boolean fAllowJavaEncodings ; protected SymbolTable fSymbolTable ; protected XMLErrorReporter fErrorReporter ; protected XMLEntityResolver fEntityResolver ; protected int fBufferSize = XMLEntityManager . DEFAULT_BUFFER_SIZE ; protected boolean fStandalone ; protected XMLEntityHandler fEntityHandler ; protected XMLEntityScanner fEntityScanner ; protected Hashtable fEntities = new Hashtable ( ) ; protected Stack fEntityStack = new Stack ( ) ; protected XMLEntityManager . ScannedEntity fCurrentEntity ; protected Hashtable fDeclaredEntities ; public XMLEntityManager ( ) { } public XMLEntityManager ( XMLEntityManager entityManager ) { } public void setStandalone ( boolean standalone ) { } public boolean isStandalone ( ) { } public void setEntityHandler ( XMLEntityHandler entityHandler ) { } public void addInternalEntity ( String name , String text ) { } public void addExternalEntity ( String name , String publicId , String systemId , String baseSystemId ) { } public boolean isExternalEntity ( String entityName ) { } public void addUnparsedEntity ( String name , String publicId , String systemId , String notation ) { } public boolean isUnparsedEntity ( String entityName ) { } public boolean isDeclaredEntity ( String entityName ) { } public XMLInputSource resolveEntity ( String publicId , String systemId , String baseSystemId ) throws IOException , XNIException { <START_BUG> if ( baseSystemId == null ) { <END_BUG> baseSystemId = fCurrentEntity . systemId ; } XMLInputSource xmlInputSource = null ; if ( ( fEntityResolver ) != null ) { xmlInputSource = fEntityResolver . resolveEntity ( publicId , systemId , baseSystemId ) ; } if ( xmlInputSource == null ) { xmlInputSource = new XMLInputSource ( publicId , systemId , baseSystemId ) ; } if ( XMLEntityManager . DEBUG_RESOLVER ) { System . err . println ( ( ( "XMLEntityManager.resolveEntity(" + publicId ) + ")" ) ) ; System . err . println ( ( "<seq2seq4repair_space>=<seq2seq4repair_space>" + xmlInputSource ) ) ; } return xmlInputSource ; } public void startEntity ( String entityName , boolean literal ) throws IOException , XNIException { } public void startDocumentEntity ( XMLInputSource xmlInputSource ) throws IOException , XNIException { } public void startDTDEntity ( XMLInputSource xmlInputSource ) throws IOException , XNIException { } public void startEntity ( String name , XMLInputSource xmlInputSource , boolean literal ) throws IOException , XNIException { } public XMLEntityScanner getEntityScanner ( ) { } public void reset ( XMLComponentManager componentManager ) throws XMLConfigurationException { } public String [ ] getRecognizedFeatures ( ) { } public void setFeature ( String featureId , boolean state ) throws XMLConfigurationException { } public String [ ] getRecognizedProperties ( ) { } public void setProperty ( String propertyId , Object value ) throws XMLConfigurationException { } public static String expandSystemId ( String systemId ) { } public static String expandSystemId ( String systemId , String baseSystemId ) { } protected void endEntity ( ) throws XNIException { } protected String getEncodingName ( byte [ ] b4 , int count ) { } protected Reader createReader ( InputStream inputStream , String encoding ) throws IOException { } protected static String fixURI ( String str ) { } Hashtable getDeclaredEntities ( ) { } final void print ( ) { } protected abstract static class Entity { public String name ; public Entity ( ) { } public Entity ( String name ) { } public abstract boolean isExternal ( ) { } public abstract boolean isUnparsed ( ) { } public void clear ( ) { } public void setValues ( XMLEntityManager . Entity entity ) { } } protected static class InternalEntity extends XMLEntityManager . Entity { public String text ; public InternalEntity ( ) { } public InternalEntity ( String name , String text ) { } public final boolean isExternal ( ) { } public final boolean isUnparsed ( ) { } public void clear ( ) { } public void setValues ( XMLEntityManager . Entity entity ) { } public void setValues ( XMLEntityManager . InternalEntity entity ) { } } protected static class ExternalEntity extends XMLEntityManager . Entity { public String publicId ; public String systemId ; public String baseSystemId ; public String notation ; public ExternalEntity ( ) { } public ExternalEntity ( String name , String publicId , String systemId , String baseSystemId , String notation ) { } public final boolean isExternal ( ) { } public final boolean isUnparsed ( ) { } public void clear ( ) { } public void setValues ( XMLEntityManager . Entity entity ) { } public void setValues ( XMLEntityManager . ExternalEntity entity ) { } } protected class ScannedEntity extends XMLEntityManager . Entity { public InputStream stream ; public Reader reader ;

Fix:
if ( ( baseSystemId == null ) && ( ( fCurrentEntity ) != null ) ) {