Program: 127315
Project: 127315
Buggy source:
private static List<ModuleNeeded> getModulesNeededForComponents(){
  initCache();
  if (isCreated) {
    List<ModuleNeeded> importNeedsList=new ArrayList<ModuleNeeded>();
    ComponentsCache cache=ComponentManager.getComponentCache();
    EMap<String,EList<ComponentInfo>> map=cache.getComponentEntryMap();
    Set<String> set=map.keySet();
    Iterator it=set.iterator();
    while (it.hasNext()) {
      String key=(String)it.next();
      EList<ComponentInfo> value=map.get(key);
      for (      ComponentInfo info : value) {
        EList emfImportList=info.getImportType();
        for (int i=0; i < emfImportList.size(); i++) {
          IMPORTType importType=(IMPORTType)emfImportList.get(i);
          String msg=importType.getMESSAGE();
          if (msg == null) {
            msg=Messages.getString("String_Node_Str");
          }
          List<String> list=getInstallURL(importType);
          ModuleNeeded componentImportNeeds=new ModuleNeeded(key,importType.getMODULE(),msg,importType.isREQUIRED(),list,importType.getREQUIREDIF());
          initBundleID(importType,componentImportNeeds);
          componentImportNeeds.setMrRequired(importType.isMRREQUIRED());
          componentImportNeeds.setShow(importType.isSHOW());
          componentImportNeeds.setModuleLocaion(importType.getUrlPath());
          importNeedsList.add(componentImportNeeds);
        }
      }
    }
    return importNeedsList;
  }
 else {
    List<ModuleNeeded> importNeedsList=new ArrayList<ModuleNeeded>();
    if (GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsService.class)) {
      IComponentsService service=(IComponentsService)GlobalServiceRegister.getDefault().getService(IComponentsService.class);
      IComponentsFactory compFac=service.getComponentsFactory();
      Set<IComponent> componentList=compFac.getComponents();
      for (      IComponent comp : componentList.toArray(new IComponent[0])) {
        importNeedsList.addAll(comp.getModulesNeeded());
      }
    }
    return importNeedsList;
  }
}

Fixed version (ground truth):
private static List<ModuleNeeded> getModulesNeededForComponents(){
  initCache();
  if (isCreated) {
    List<ModuleNeeded> importNeedsList=new ArrayList<ModuleNeeded>();
    ComponentsCache cache=ComponentManager.getComponentCache();
    EMap<String,EList<ComponentInfo>> map=cache.getComponentEntryMap();
    Set<String> set=map.keySet();
    Iterator it=set.iterator();
    Map<String,Boolean> bundlesAvailable=new HashMap<String,Boolean>();
    while (it.hasNext()) {
      String key=(String)it.next();
      EList<ComponentInfo> value=map.get(key);
      for (      ComponentInfo info : value) {
        Boolean available=bundlesAvailable.get(info.getSourceBundleName());
        if (available == null) {
          available=Platform.getBundle(info.getSourceBundleName()) != null;
          bundlesAvailable.put(info.getSourceBundleName(),available);
        }
        if (!available) {
          continue;
        }
        EList emfImportList=info.getImportType();
        for (int i=0; i < emfImportList.size(); i++) {
          IMPORTType importType=(IMPORTType)emfImportList.get(i);
          String msg=importType.getMESSAGE();
          if (msg == null) {
            msg=Messages.getString("String_Node_Str");
          }
          List<String> list=getInstallURL(importType);
          ModuleNeeded componentImportNeeds=new ModuleNeeded(key,importType.getMODULE(),msg,importType.isREQUIRED(),list,importType.getREQUIREDIF());
          initBundleID(importType,componentImportNeeds);
          componentImportNeeds.setMrRequired(importType.isMRREQUIRED());
          componentImportNeeds.setShow(importType.isSHOW());
          componentImportNeeds.setModuleLocaion(importType.getUrlPath());
          importNeedsList.add(componentImportNeeds);
        }
      }
    }
    return importNeedsList;
  }
 else {
    List<ModuleNeeded> importNeedsList=new ArrayList<ModuleNeeded>();
    if (GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsService.class)) {
      IComponentsService service=(IComponentsService)GlobalServiceRegister.getDefault().getService(IComponentsService.class);
      IComponentsFactory compFac=service.getComponentsFactory();
      Set<IComponent> componentList=compFac.getComponents();
      for (      IComponent comp : componentList.toArray(new IComponent[0])) {
        importNeedsList.addAll(comp.getModulesNeeded());
      }
    }
    return importNeedsList;
  }
}