Program: 118115
Project: 118115
Buggy source:
/** 
 * Create the "Shapes" drawer. 
 */
private static void createComponentsDrawer(List<IComponent> componentList,boolean needHiddenComponent,boolean isFavorite,int a){
  clearGroup();
  List<CreationToolEntry> nodeList=new LinkedList<CreationToolEntry>();
  PaletteDrawer componentsDrawer;
  String name, longName;
  String family;
  String oraFamily;
  List<String> families=new ArrayList<String>();
  HashMap<String,String> familyMap=new HashMap<String,String>();
  CombinedTemplateCreationEntry component;
  Hashtable<String,PaletteDrawer> ht=new Hashtable<String,PaletteDrawer>();
  paletteState=isFavorite;
  List<String> favoriteComponentNames=null;
  if (a == 0) {
    favoriteComponentNames=getFavoritesList();
  }
  Iterator<IComponent> componentIter=componentList.iterator();
  while (componentIter.hasNext()) {
    IComponent xmlComponent=componentIter.next();
    if (xmlComponent.isTechnical()) {
      continue;
    }
    if (xmlComponent.isLoaded()) {
      family=xmlComponent.getTranslatedFamilyName();
      oraFamily=xmlComponent.getOriginalFamilyName();
      String[] strings=family.split(ComponentsFactoryProvider.FAMILY_SEPARATOR_REGEX);
      String[] oraStrings=oraFamily.split(ComponentsFactoryProvider.FAMILY_SEPARATOR_REGEX);
      for (int j=0; j < strings.length; j++) {
        if (!needHiddenComponent && !xmlComponent.isVisible(oraStrings[j])) {
          continue;
        }
        if (a == 0) {
          if (!oraStrings[j].equals("String_Node_Str")) {
            if (isFavorite && !(favoriteComponentNames != null && favoriteComponentNames.contains(xmlComponent.getName()))) {
              continue;
            }
          }
        }
        families.add(strings[j]);
        familyMap.put(strings[j],oraStrings[j]);
      }
    }
  }
  Collections.sort(families);
  List<String> recentlyUsedComponentNames=null;
  List<RecentlyUsedComponent> recentlyUsedComponents=null;
  if (a == 0) {
    recentlyUsedComponents=new LinkedList<TalendEditorPaletteFactory.RecentlyUsedComponent>();
    recentlyUsedComponentNames=getRecentlyUsedList(recentlyUsedComponents);
    Collections.sort(recentlyUsedComponents,new Comparator<TalendEditorPaletteFactory.RecentlyUsedComponent>(){
      @Override public int compare(      RecentlyUsedComponent arg0,      RecentlyUsedComponent arg1){
        return -1 * arg0.getTimestamp().compareTo(arg1.getTimestamp());
      }
    }
);
    families.add(0,FAVORITES);
    familyMap.put(FAVORITES,FAVORITES);
    families.add(1,RECENTLY_USED);
    familyMap.put(RECENTLY_USED,RECENTLY_USED);
    for (    Object element : families) {
      family=(String)element;
      String oraFam=familyMap.get(family);
      componentsDrawer=ht.get(family);
      if (componentsDrawer == null) {
        componentsDrawer=createComponentDrawer(ht,family);
        if (componentsDrawer instanceof IPaletteFilter) {
          ((IPaletteFilter)componentsDrawer).setOriginalName(oraFam);
        }
      }
    }
  }
  boolean noteAeeded=false;
  boolean needAddNote=true;
  boolean needToAdd=false;
  Map<String,IComponent> recentlyUsedMap=new HashMap<String,IComponent>();
  PaletteDrawer drawer=ht.get("String_Node_Str");
  if (drawer == null) {
    drawer=ht.get("String_Node_Str");
    if (drawer == null) {
      drawer=createComponentDrawer(ht,"String_Node_Str");
      if (drawer instanceof IPaletteFilter) {
        ((IPaletteFilter)drawer).setOriginalName("String_Node_Str");
      }
    }
  }
  IPreferenceStore store=DesignerPlugin.getDefault().getPreferenceStore();
  String largeIconsSize=store.getString(TalendDesignerPrefConstants.LARGE_ICONS_SIZE);
  CreationToolEntry noteCreationToolEntry=createNoteEntry(largeIconsSize);
  noteCreationToolEntry.setParent(drawer);
  drawer.add(noteCreationToolEntry);
  componentIter=componentList.iterator();
  while (componentIter.hasNext()) {
    IComponent xmlComponent=componentIter.next();
    if (xmlComponent.isTechnical()) {
      continue;
    }
    family=xmlComponent.getTranslatedFamilyName();
    oraFamily=xmlComponent.getOriginalFamilyName();
    if (filter != null) {
      Pattern pattern=Pattern.compile("String_Node_Str");
      Matcher matcher=pattern.matcher(filter);
      if (!matcher.matches() && filter.length() != 0) {
        filter="String_Node_Str";
      }
      String regex=getFilterRegex(filter);
      needAddNote="String_Node_Str".toLowerCase().matches(regex);
    }
    family=xmlComponent.getTranslatedFamilyName();
    oraFamily=xmlComponent.getOriginalFamilyName();
    if (isFavorite && !(favoriteComponentNames != null && favoriteComponentNames.contains(xmlComponent.getName()))) {
      continue;
    }
    if (xmlComponent.isLoaded()) {
      name=xmlComponent.getName();
      longName=xmlComponent.getLongName();
      ImageDescriptor imageSmall=xmlComponent.getIcon16();
      ImageDescriptor imageLarge;
      if (largeIconsSize.equals("String_Node_Str")) {
        imageLarge=xmlComponent.getIcon24();
      }
 else {
        imageLarge=xmlComponent.getIcon32();
      }
      if (favoriteComponentNames != null && favoriteComponentNames.contains(xmlComponent.getName())) {
        componentsDrawer=ht.get(FAVORITES);
        if (componentsDrawer != null) {
          component=new TalendCombinedTemplateCreationEntry(name,name,Node.class,new PaletteComponentFactory(xmlComponent),imageSmall,imageLarge);
          component.setDescription(longName);
          component.setParent(componentsDrawer);
          componentsDrawer.add(component);
        }
      }
      if (recentlyUsedComponentNames != null && recentlyUsedComponentNames.contains(name)) {
        recentlyUsedMap.put(name,xmlComponent);
      }
      if (isFavorite && !(favoriteComponentNames != null && favoriteComponentNames.contains(xmlComponent.getName()))) {
        continue;
      }
      String[] strings=family.split(ComponentsFactoryProvider.FAMILY_SEPARATOR_REGEX);
      String[] oraStrings=oraFamily.split(ComponentsFactoryProvider.FAMILY_SEPARATOR_REGEX);
      for (int j=0; j < strings.length; j++) {
        if (!needHiddenComponent && !xmlComponent.isVisible(oraStrings[j])) {
          continue;
        }
        component=new TalendCombinedTemplateCreationEntry(name,name,Node.class,new PaletteComponentFactory(xmlComponent),imageSmall,imageLarge);
        component.setDescription(longName);
        if (a == 0) {
          componentsDrawer=ht.get(strings[j]);
          component.setParent(componentsDrawer);
          componentsDrawer.add(component);
        }
 else         if (a == 1) {
          boolean canAdd=true;
          Iterator<CreationToolEntry> iter=nodeList.iterator();
          while (iter.hasNext()) {
            if ((iter.next().getLabel()).equals(component.getLabel())) {
              canAdd=false;
            }
          }
          if (canAdd == true) {
            nodeList.add(component);
          }
        }
      }
    }
  }
  if (a == 0) {
    createRecentlyUsedEntryList(ht,recentlyUsedComponents,recentlyUsedMap);
  }
  if (a == 1) {
    Iterator<CreationToolEntry> iter=nodeList.iterator();
    while (iter.hasNext()) {
      CreationToolEntry entryComponent=iter.next();
      entryComponent.setParent(paGroup);
      paGroup.add(entryComponent);
    }
    palette.add(paGroup);
  }
  setFilter("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Create the "Shapes" drawer. 
 */
private static void createComponentsDrawer(List<IComponent> componentList,boolean needHiddenComponent,boolean isFavorite,int a){
  clearGroup();
  List<CreationToolEntry> nodeList=new LinkedList<CreationToolEntry>();
  PaletteDrawer componentsDrawer;
  String name, longName;
  String family;
  String oraFamily;
  List<String> families=new ArrayList<String>();
  HashMap<String,String> familyMap=new HashMap<String,String>();
  CombinedTemplateCreationEntry component;
  Hashtable<String,PaletteDrawer> ht=new Hashtable<String,PaletteDrawer>();
  paletteState=isFavorite;
  List<String> favoriteComponentNames=null;
  if (a == 0) {
    favoriteComponentNames=getFavoritesList();
  }
  Iterator<IComponent> componentIter=componentList.iterator();
  while (componentIter.hasNext()) {
    IComponent xmlComponent=componentIter.next();
    if (xmlComponent.isTechnical()) {
      continue;
    }
    if (xmlComponent.isLoaded()) {
      family=xmlComponent.getTranslatedFamilyName();
      oraFamily=xmlComponent.getOriginalFamilyName();
      String[] strings=family.split(ComponentsFactoryProvider.FAMILY_SEPARATOR_REGEX);
      String[] oraStrings=oraFamily.split(ComponentsFactoryProvider.FAMILY_SEPARATOR_REGEX);
      for (int j=0; j < strings.length; j++) {
        if (!needHiddenComponent && !xmlComponent.isVisible(oraStrings[j])) {
          continue;
        }
        if (a == 0) {
          if (!oraStrings[j].equals("String_Node_Str")) {
            if (isFavorite && !(favoriteComponentNames != null && favoriteComponentNames.contains(xmlComponent.getName()))) {
              continue;
            }
          }
        }
        families.add(strings[j]);
        familyMap.put(strings[j],oraStrings[j]);
      }
    }
  }
  Collections.sort(families);
  List<String> recentlyUsedComponentNames=null;
  List<RecentlyUsedComponent> recentlyUsedComponents=null;
  if (a == 0) {
    recentlyUsedComponents=new LinkedList<TalendEditorPaletteFactory.RecentlyUsedComponent>();
    recentlyUsedComponentNames=getRecentlyUsedList(recentlyUsedComponents);
    Collections.sort(recentlyUsedComponents,new Comparator<TalendEditorPaletteFactory.RecentlyUsedComponent>(){
      @Override public int compare(      RecentlyUsedComponent arg0,      RecentlyUsedComponent arg1){
        return -1 * arg0.getTimestamp().compareTo(arg1.getTimestamp());
      }
    }
);
    families.add(0,FAVORITES);
    familyMap.put(FAVORITES,FAVORITES);
    families.add(1,RECENTLY_USED);
    familyMap.put(RECENTLY_USED,RECENTLY_USED);
    for (    Object element : families) {
      family=(String)element;
      String oraFam=familyMap.get(family);
      componentsDrawer=ht.get(family);
      if (componentsDrawer == null) {
        componentsDrawer=createComponentDrawer(ht,family);
        if (componentsDrawer instanceof IPaletteFilter) {
          ((IPaletteFilter)componentsDrawer).setOriginalName(oraFam);
        }
      }
    }
  }
  boolean noteAeeded=false;
  boolean needAddNote=true;
  boolean needToAdd=false;
  Map<String,IComponent> recentlyUsedMap=new HashMap<String,IComponent>();
  PaletteDrawer drawer=ht.get("String_Node_Str");
  if (drawer == null) {
    drawer=ht.get("String_Node_Str");
    if (drawer == null) {
      drawer=createComponentDrawer(ht,"String_Node_Str");
      if (drawer instanceof IPaletteFilter) {
        ((IPaletteFilter)drawer).setOriginalName("String_Node_Str");
      }
    }
  }
  IPreferenceStore store=DesignerPlugin.getDefault().getPreferenceStore();
  String largeIconsSize=store.getString(TalendDesignerPrefConstants.LARGE_ICONS_SIZE);
  CreationToolEntry noteCreationToolEntry=createNoteEntry(largeIconsSize);
  noteCreationToolEntry.setParent(drawer);
  drawer.add(noteCreationToolEntry);
  componentIter=componentList.iterator();
  while (componentIter.hasNext()) {
    IComponent xmlComponent=componentIter.next();
    if (xmlComponent.isTechnical()) {
      continue;
    }
    family=xmlComponent.getTranslatedFamilyName();
    oraFamily=xmlComponent.getOriginalFamilyName();
    if (filter != null) {
      Pattern pattern=Pattern.compile("String_Node_Str");
      Matcher matcher=pattern.matcher(filter);
      if (!matcher.matches() && filter.length() != 0) {
        filter="String_Node_Str";
      }
      String regex=getFilterRegex(filter);
      needAddNote="String_Node_Str".toLowerCase().matches(regex);
    }
    family=xmlComponent.getTranslatedFamilyName();
    oraFamily=xmlComponent.getOriginalFamilyName();
    if (isFavorite && !(favoriteComponentNames != null && favoriteComponentNames.contains(xmlComponent.getName()))) {
      continue;
    }
    if (xmlComponent.isLoaded()) {
      name=xmlComponent.getName();
      longName=xmlComponent.getLongName();
      ImageDescriptor imageSmall=xmlComponent.getIcon16();
      ImageDescriptor imageLarge;
      if (largeIconsSize.equals("String_Node_Str")) {
        imageLarge=xmlComponent.getIcon24();
      }
 else {
        imageLarge=xmlComponent.getIcon32();
      }
      if (favoriteComponentNames != null && favoriteComponentNames.contains(xmlComponent.getName())) {
        componentsDrawer=ht.get(FAVORITES);
        if (componentsDrawer != null) {
          component=new TalendCombinedTemplateCreationEntry(name,name,Node.class,xmlComponent,imageSmall,imageLarge);
          component.setDescription(longName);
          component.setParent(componentsDrawer);
          componentsDrawer.add(component);
        }
      }
      if (recentlyUsedComponentNames != null && recentlyUsedComponentNames.contains(name)) {
        recentlyUsedMap.put(name,xmlComponent);
      }
      if (isFavorite && !(favoriteComponentNames != null && favoriteComponentNames.contains(xmlComponent.getName()))) {
        continue;
      }
      String[] strings=family.split(ComponentsFactoryProvider.FAMILY_SEPARATOR_REGEX);
      String[] oraStrings=oraFamily.split(ComponentsFactoryProvider.FAMILY_SEPARATOR_REGEX);
      for (int j=0; j < strings.length; j++) {
        if (!needHiddenComponent && !xmlComponent.isVisible(oraStrings[j])) {
          continue;
        }
        component=new TalendCombinedTemplateCreationEntry(name,name,Node.class,xmlComponent,imageSmall,imageLarge);
        component.setDescription(longName);
        if (a == 0) {
          componentsDrawer=ht.get(strings[j]);
          component.setParent(componentsDrawer);
          componentsDrawer.add(component);
        }
 else         if (a == 1) {
          boolean canAdd=true;
          Iterator<CreationToolEntry> iter=nodeList.iterator();
          while (iter.hasNext()) {
            if ((iter.next().getLabel()).equals(component.getLabel())) {
              canAdd=false;
            }
          }
          if (canAdd == true) {
            nodeList.add(component);
          }
        }
      }
    }
  }
  if (a == 0) {
    createRecentlyUsedEntryList(ht,recentlyUsedComponents,recentlyUsedMap);
  }
  if (a == 1) {
    Iterator<CreationToolEntry> iter=nodeList.iterator();
    while (iter.hasNext()) {
      CreationToolEntry entryComponent=iter.next();
      entryComponent.setParent(paGroup);
      paGroup.add(entryComponent);
    }
    palette.add(paGroup);
  }
  setFilter("String_Node_Str");
}