Buggy code:
public class NamespaceHandlerRegistryImpl implements NamespaceHandlerRegistry , ServiceTrackerCustomizer { public static final URI BLUEPRINT_NAMESPACE = URI . create ( "http:////www.osgi.org//xmlns//blueprint//v1.0.0" ) ; public static final String NAMESPACE = "osgi.service.blueprint.namespace" ; private static final Logger LOGGER = LoggerFactory . getLogger ( NamespaceHandlerRegistryImpl . class ) ; private final BundleContext bundleContext ; private final Map < URI , Set < NamespaceHandler > > handlers ; private final ServiceTracker tracker ; private final Map < Map < URI , NamespaceHandler > , Reference < Schema > > schemas = new NamespaceHandlerRegistryImpl . LRUMap < Map < URI , NamespaceHandler > , Reference < Schema > > ( 10 ) ; private SchemaFactory schemaFactory ; private List < NamespaceHandlerRegistryImpl . NamespaceHandlerSetImpl > sets ; public NamespaceHandlerRegistryImpl ( BundleContext bundleContext ) { } public Object addingService ( ServiceReference reference ) { } public void modifiedService ( ServiceReference reference , Object service ) { } public void removedService ( ServiceReference reference , Object service ) { } public synchronized void registerHandler ( NamespaceHandler handler , Map properties ) { } public synchronized void unregisterHandler ( NamespaceHandler handler , Map properties ) { } private static List < URI > getNamespaces ( Map properties ) { } private static URI toURI ( Object o ) { } public synchronized NamespaceHandlerSet getNamespaceHandlers ( Set < URI > uris , Bundle bundle ) { } public void destroy ( ) { } public synchronized Schema getSchema ( Map < URI , NamespaceHandler > handlers ) throws IOException , SAXException { Schema schema = null ; for ( Map < URI , NamespaceHandler > key : schemas . keySet ( ) ) { boolean found = true ; for ( URI uri : handlers . keySet ( ) ) { if ( ! ( handlers . get ( uri ) . equals ( key . get ( uri ) ) ) ) { found = false ; break ; } } if ( found ) { schema = schemas . get ( key ) . get ( ) ; break ; } } if ( schema == null ) { List < StreamSource > schemaSources = new ArrayList < StreamSource > ( ) ; try { schemaSources . add ( new StreamSource ( getClass ( ) . getResourceAsStream ( "//org//apache//aries//blueprint//blueprint.xsd" ) ) ) ; for ( URI ns : handlers . keySet ( ) ) { URL url = handlers . get ( ns ) . getSchemaLocation ( ns . toString ( ) ) ; if ( url == null ) { NamespaceHandlerRegistryImpl . LOGGER . warn ( ( ( "No<seq2seq4repair_space>URL<seq2seq4repair_space>is<seq2seq4repair_space>defined<seq2seq4repair_space>for<seq2seq4repair_space>schema<seq2seq4repair_space>" + ns ) + ".<seq2seq4repair_space>This<seq2seq4repair_space>schema<seq2seq4repair_space>will<seq2seq4repair_space>not<seq2seq4repair_space>be<seq2seq4repair_space>validated" ) ) ; } else { <START_BUG> schemaSources . add ( new StreamSource ( url . openStream ( ) ) ) ; <END_BUG> } } schema = getSchemaFactory ( ) . newSchema ( schemaSources . toArray ( new Source [ schemaSources . size ( ) ] ) ) ; for ( Iterator < Map < URI , NamespaceHandler > > iterator = schemas . keySet ( ) . iterator ( ) ; iterator . hasNext ( ) ; ) { Map < URI , NamespaceHandler > key = iterator . next ( ) ; boolean found = true ; for ( URI uri : key . keySet ( ) ) { if ( ! ( key . get ( uri ) . equals ( handlers . get ( uri ) ) ) ) { found = false ; break ; } } if ( found ) { iterator . remove ( ) ; break ; } } schemas . put ( handlers , new SoftReference < Schema > ( schema ) ) ; } finally { for ( StreamSource s : schemaSources ) { try { s . getInputStream ( ) . close ( ) ; } catch ( IOException e ) { } } } } return schema ; } protected synchronized void removeSchemasFor ( NamespaceHandler handler ) { } private SchemaFactory getSchemaFactory ( ) { } protected class NamespaceHandlerSetImpl implements NamespaceHandlerSet { private final Map < Listener , Boolean > listeners ; private final Bundle bundle ; private final Set < URI > namespaces ; private final Map < URI , NamespaceHandler > handlers ; private Schema schema ; public NamespaceHandlerSetImpl ( Set < URI > namespaces , Bundle bundle ) { } public boolean isComplete ( ) { } public Set < URI > getNamespaces ( ) { } public NamespaceHandler getNamespaceHandler ( URI namespace ) { } public Schema getSchema ( ) throws IOException , SAXException { } public synchronized void addListener ( Listener listener ) { } public synchronized void removeListener ( Listener listener ) { } public void destroy ( ) { } public void registerHandler ( URI uri , NamespaceHandler handler ) { } public void unregisterHandler ( URI uri , NamespaceHandler handler ) { } private NamespaceHandler findCompatibleNamespaceHandler ( URI ns ) { } } protected static Map < URI , NamespaceHandler > findHandlers ( Map < URI , Set < NamespaceHandler > > allHandlers , Set < URI > namespaces , Bundle bundle ) { } public static class LRUMap < K , V > extends AbstractMap < K , V > { private final int bound ; private final LinkedList < Map . Entry < K , V > > entries = new LinkedList < Map . Entry < K , V > > ( ) ; private static class LRUEntry < K , V > implements Map . Entry < K , V > { private final K key ; private final V value ; private LRUEntry ( K key , V value ) { } public K getKey ( ) { } public V getValue ( ) { } public V setValue ( V value ) { } } private LRUMap ( int bound ) { } public V get ( Object key ) { } public V put ( K key , V value ) { }

Fix:
schemaSources . add ( new StreamSource ( url . openStream ( ) , url . toExternalForm ( ) ) ) ;