Program: 94172
Project: 94172
Buggy source:
public void start(final BundleContext ctxt) throws Exception {
  plugin=this;
  this.context=ctxt;
  if (disableBasicTopologyManager) {
    osgiTopologyManagerImpl=new OSGiTopologyManagerImpl(context);
    Properties props=new Properties();
    props.put(org.osgi.service.remoteserviceadmin.EndpointEventListener.ENDPOINT_LISTENER_SCOPE,osgiTopologyManagerImpl.getScope());
    endpointListenerReg=getContext().registerService(EndpointListener.class.getName(),osgiTopologyManagerImpl,(Dictionary)props);
    endpointEventListenerReg=getContext().registerService(EndpointEventListener.class.getName(),osgiTopologyManagerImpl,(Dictionary)props);
    osgiTopologyManagerImpl.activate();
  }
 else {
    basicTopologyManagerImpl=new BasicTopologyManagerImpl(context);
    Properties props=new Properties();
    props.put(org.osgi.service.remoteserviceadmin.EndpointEventListener.ENDPOINT_LISTENER_SCOPE,basicTopologyManagerImpl.getScope());
    endpointListenerReg=getContext().registerService(EndpointListener.class.getName(),basicTopologyManagerImpl,(Dictionary)props);
    endpointEventListenerReg=getContext().registerService(EndpointEventListener.class.getName(),new ServiceFactory(){
      public Object getService(      Bundle bundle,      ServiceRegistration registration){
        return new ProxyEndpointEventListener(bundle);
      }
      public void ungetService(      Bundle bundle,      ServiceRegistration registration,      Object service){
        ProxyEndpointEventListener peel=(service instanceof ProxyEndpointEventListener) ? (ProxyEndpointEventListener)service : null;
        if (peel == null)         return;
synchronized (bundleEndpointEventListenerMap) {
          List<EndpointEventHolder> endpointEventHolders=bundleEndpointEventListenerMap.get(bundle);
          if (endpointEventHolders != null)           for (          EndpointEventHolder eh : endpointEventHolders)           peel.deliverRemoveEventForBundle(eh);
        }
      }
    }
,(Dictionary)props);
    if (Boolean.valueOf(context.getProperty(PROP_USE_DS)).booleanValue())     return;
    String serviceName=EventListenerHook.class.getName();
    Filter serviceFilter=context.createFilter("String_Node_Str" + serviceName + "String_Node_Str");
    ServiceReference[] refs=context.getBundle().getRegisteredServices();
    if (refs != null) {
      for (int i=0; i < refs.length; i++)       if (serviceFilter.match(refs[i]))       return;
    }
    basicTopologyManagerComp=new BasicTopologyManagerComponent();
    basicTopologyManagerComp.bindEndpointEventListener(basicTopologyManagerImpl);
    eventAdminListenerRegistration=this.context.registerService(RemoteServiceAdminListener.class,basicTopologyManagerComp,null);
    eventListenerHookRegistration=this.context.registerService(EventListenerHook.class,basicTopologyManagerComp,null);
    basicTopologyManagerComp.activate();
  }
}

Fixed version (ground truth):
public void start(final BundleContext ctxt) throws Exception {
  plugin=this;
  this.context=ctxt;
  if (disableBasicTopologyManager) {
    osgiTopologyManagerImpl=new OSGiTopologyManagerImpl(context);
    Properties props=new Properties();
    props.put(org.osgi.service.remoteserviceadmin.EndpointEventListener.ENDPOINT_LISTENER_SCOPE,osgiTopologyManagerImpl.getScope());
    endpointListenerReg=getContext().registerService(EndpointListener.class.getName(),osgiTopologyManagerImpl,(Dictionary)props);
    endpointEventListenerReg=getContext().registerService(EndpointEventListener.class.getName(),osgiTopologyManagerImpl,(Dictionary)props);
    osgiTopologyManagerImpl.activate();
  }
 else {
    basicTopologyManagerImpl=new BasicTopologyManagerImpl(context);
    Properties props=new Properties();
    props.put(org.osgi.service.remoteserviceadmin.EndpointEventListener.ENDPOINT_LISTENER_SCOPE,basicTopologyManagerImpl.getScope());
    endpointEventListenerReg=getContext().registerService(EndpointEventListener.class.getName(),new ServiceFactory(){
      public Object getService(      Bundle bundle,      ServiceRegistration registration){
        return new ProxyEndpointEventListener(bundle);
      }
      public void ungetService(      Bundle bundle,      ServiceRegistration registration,      Object service){
        ProxyEndpointEventListener peel=(service instanceof ProxyEndpointEventListener) ? (ProxyEndpointEventListener)service : null;
        if (peel == null)         return;
synchronized (bundleEndpointEventListenerMap) {
          List<EndpointEventHolder> endpointEventHolders=bundleEndpointEventListenerMap.get(bundle);
          if (endpointEventHolders != null)           for (          EndpointEventHolder eh : endpointEventHolders)           peel.deliverRemoveEventForBundle(eh);
        }
      }
    }
,(Dictionary)props);
    if (Boolean.valueOf(context.getProperty(PROP_USE_DS)).booleanValue())     return;
    String serviceName=EventListenerHook.class.getName();
    Filter serviceFilter=context.createFilter("String_Node_Str" + serviceName + "String_Node_Str");
    ServiceReference[] refs=context.getBundle().getRegisteredServices();
    if (refs != null) {
      for (int i=0; i < refs.length; i++)       if (serviceFilter.match(refs[i]))       return;
    }
    basicTopologyManagerComp=new BasicTopologyManagerComponent();
    basicTopologyManagerComp.bindEndpointEventListener(basicTopologyManagerImpl);
    eventAdminListenerRegistration=this.context.registerService(RemoteServiceAdminListener.class,basicTopologyManagerComp,null);
    eventListenerHookRegistration=this.context.registerService(EventListenerHook.class,basicTopologyManagerComp,null);
    basicTopologyManagerComp.activate();
  }
}