Program: 94438
Project: 94438
Buggy source:
public IRemoteServiceReference[] getRemoteServiceReferences(ID[] idFilter,String clazz,String filter) throws InvalidSyntaxException {
  Trace.entering(Activator.PLUGIN_ID,IRemoteServiceProviderDebugOptions.METHODS_ENTERING,this.getClass(),"String_Node_Str",new Object[]{idFilter,clazz,filter});
  if (clazz == null)   return null;
  final IRemoteFilter remoteFilter=(filter == null) ? null : new RemoteFilterImpl(filter);
  final List references=new ArrayList();
  addReferencesFromRemoteRegistrys(idFilter,clazz,remoteFilter,references);
synchronized (localRegistry) {
    addReferencesFromRegistry(clazz,remoteFilter,localRegistry,references);
  }
  if (references.size() == 0) {
    AddRegistrationRequest first=null;
    List ourAddRegistrationRequests=new ArrayList();
    if (idFilter == null) {
      first=new AddRegistrationRequest(null,clazz,filter,first);
      ourAddRegistrationRequests.add(first);
    }
 else {
      for (int i=0; i < idFilter.length; i++) {
        ID target=idFilter[i];
        if (target != null) {
          AddRegistrationRequest request=new AddRegistrationRequest(target,clazz,filter,first);
          if (i == 0)           first=request;
          ourAddRegistrationRequests.add(request);
          addRegistrationRequests.put(request.getId(),request);
          sendAddRegistrationRequest(target,request,getAddRegistrationRequestCredentials(request));
        }
      }
    }
    first.waitForResponse(ADD_REGISTRATION_REQUEST_TIMEOUT);
    addReferencesFromRemoteRegistrys(idFilter,clazz,remoteFilter,references);
    for (Iterator i=ourAddRegistrationRequests.iterator(); i.hasNext(); ) {
      AddRegistrationRequest request=(AddRegistrationRequest)i.next();
      addRegistrationRequests.remove(request.getId());
    }
  }
  final IRemoteServiceReference[] result=(IRemoteServiceReference[])references.toArray(new IRemoteServiceReference[references.size()]);
  Trace.exiting(Activator.PLUGIN_ID,IRemoteServiceProviderDebugOptions.METHODS_EXITING,this.getClass(),"String_Node_Str",result);
  return (result.length == 0) ? null : result;
}

Fixed version (ground truth):
public IRemoteServiceReference[] getRemoteServiceReferences(ID[] idFilter,String clazz,String filter) throws InvalidSyntaxException {
  Trace.entering(Activator.PLUGIN_ID,IRemoteServiceProviderDebugOptions.METHODS_ENTERING,this.getClass(),"String_Node_Str",new Object[]{idFilter,clazz,filter});
  if (clazz == null)   return null;
  final IRemoteFilter remoteFilter=(filter == null) ? null : new RemoteFilterImpl(filter);
  final List references=new ArrayList();
  addReferencesFromRemoteRegistrys(idFilter,clazz,remoteFilter,references);
  if (references.size() == 0) {
    AddRegistrationRequest first=null;
    List ourAddRegistrationRequests=new ArrayList();
    if (idFilter == null) {
      first=new AddRegistrationRequest(null,clazz,filter,first);
      ourAddRegistrationRequests.add(first);
    }
 else {
      for (int i=0; i < idFilter.length; i++) {
        ID target=idFilter[i];
        if (target != null) {
          AddRegistrationRequest request=new AddRegistrationRequest(target,clazz,filter,first);
          if (i == 0)           first=request;
          ourAddRegistrationRequests.add(request);
          addRegistrationRequests.put(request.getId(),request);
          sendAddRegistrationRequest(target,request,getAddRegistrationRequestCredentials(request));
        }
      }
    }
    first.waitForResponse(ADD_REGISTRATION_REQUEST_TIMEOUT);
    addReferencesFromRemoteRegistrys(idFilter,clazz,remoteFilter,references);
    for (Iterator i=ourAddRegistrationRequests.iterator(); i.hasNext(); ) {
      AddRegistrationRequest request=(AddRegistrationRequest)i.next();
      addRegistrationRequests.remove(request.getId());
    }
  }
  ID localContainerID=getLocalContainerID();
  if (idFilter == null || Arrays.asList(idFilter).contains(localContainerID)) {
synchronized (localRegistry) {
      addReferencesFromRegistry(clazz,remoteFilter,localRegistry,references);
    }
  }
  final IRemoteServiceReference[] result=(IRemoteServiceReference[])references.toArray(new IRemoteServiceReference[references.size()]);
  Trace.exiting(Activator.PLUGIN_ID,IRemoteServiceProviderDebugOptions.METHODS_EXITING,this.getClass(),"String_Node_Str",result);
  return (result.length == 0) ? null : result;
}