Program: 148334
Project: 148334
Buggy source:
protected void addSubMenu(TreeEntry entry,int position){
  ArrayList<WSMenuEntry> list=new ArrayList<WSMenuEntry>();
  if (entry.getParentTreeEntry() == null) {
    WSMenu menu=((WSMenu)viewer.getInput());
    for (int i=0; i < menu.getMenuEntries().length; i++) {
      if ((position == i) && (location != LOCATION_AFTER))       list.add(entry.getWsMenuEntry());
      list.add(menu.getMenuEntries()[i]);
      if ((position == i) && (location == LOCATION_AFTER))       list.add(entry.getWsMenuEntry());
    }
    menu.setMenuEntries(list.toArray(new WSMenuEntry[list.size()]));
    viewer.setExpandedState(menu,true);
    viewer.refresh(menu,true);
    System.out.println("String_Node_Str");
    return;
  }
  WSMenuEntry wsParent=entry.getParentTreeEntry().getWsMenuEntry();
  if ((wsParent.getSubMenus() == null) || (wsParent.getSubMenus().length == 0)) {
    System.out.println("String_Node_Str");
    wsParent.setSubMenus(new WSMenuEntry[]{entry.getWsMenuEntry()});
    viewer.setExpandedState(entry.getParentTreeEntry(),true);
    viewer.refresh(entry.getParentTreeEntry(),true);
    return;
  }
  for (int i=0; i < wsParent.getSubMenus().length; i++) {
    if ((position == i) && (location != LOCATION_AFTER))     list.add(entry.getWsMenuEntry());
    list.add(wsParent.getSubMenus()[i]);
    if ((position == i) && (location != LOCATION_BEFORE))     list.add(entry.getWsMenuEntry());
  }
  wsParent.setSubMenus(list.toArray(new WSMenuEntry[list.size()]));
  viewer.setExpandedState(entry.getParentTreeEntry(),true);
  viewer.refresh(entry.getParentTreeEntry(),true);
}

Fixed version (ground truth):
protected void addSubMenu(TreeEntry entry,int position){
  ArrayList<WSMenuEntry> list=new ArrayList<WSMenuEntry>();
  if (entry.getParentTreeEntry() == null) {
    WSMenu menu=((WSMenu)viewer.getInput());
    for (int i=0; i < menu.getMenuEntries().length; i++) {
      if ((position == i) && (location != LOCATION_AFTER))       list.add(entry.getWsMenuEntry());
      list.add(menu.getMenuEntries()[i]);
      if ((position == i) && (location == LOCATION_AFTER))       list.add(entry.getWsMenuEntry());
    }
    menu.setMenuEntries(list.toArray(new WSMenuEntry[list.size()]));
    viewer.setExpandedState(menu,true);
    viewer.refresh(menu,true);
    log.info("String_Node_Str");
    return;
  }
  WSMenuEntry wsParent=entry.getParentTreeEntry().getWsMenuEntry();
  if ((wsParent.getSubMenus() == null) || (wsParent.getSubMenus().length == 0)) {
    log.info("String_Node_Str");
    wsParent.setSubMenus(new WSMenuEntry[]{entry.getWsMenuEntry()});
    viewer.setExpandedState(entry.getParentTreeEntry(),true);
    viewer.refresh(entry.getParentTreeEntry(),true);
    return;
  }
  for (int i=0; i < wsParent.getSubMenus().length; i++) {
    if ((position == i) && (location != LOCATION_AFTER))     list.add(entry.getWsMenuEntry());
    list.add(wsParent.getSubMenus()[i]);
    if ((position == i) && (location != LOCATION_BEFORE))     list.add(entry.getWsMenuEntry());
  }
  wsParent.setSubMenus(list.toArray(new WSMenuEntry[list.size()]));
  viewer.setExpandedState(entry.getParentTreeEntry(),true);
  viewer.refresh(entry.getParentTreeEntry(),true);
}