nus-yam/ex-repair huggingface dataset:
Program: 95537
Project: 95537
Buggy source:
/** 
 * Checks if there are unused Test Data in this TDManagerPO  (Data column without a parameter).
 * @return true if there are unused Test Data in this TDManagerPO., false otherwise.
 */
public boolean checkHasUnusedTestData(){
  for (  String colId : getDataManager().getUniqueIds()) {
    boolean hasColIdParam=false;
    for (ListIterator<IParamDescriptionPO> paramListIter=getParameterListIter(); paramListIter.hasNext(); ) {
      IParamDescriptionPO paramDescr=paramListIter.next();
      if (colId.equals(paramDescr.getUniqueId())) {
        hasColIdParam=true;
        break;
      }
    }
    if (!hasColIdParam) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Checks if there are unused Test Data in this TDManagerPO  (Data column without a parameter).
 * @return true if there are unused Test Data in this TDManagerPO., false otherwise.
 */
public boolean checkHasUnusedTestData(){
  if (getReferencedDataCube() == null) {
    for (    String colId : getDataManager().getUniqueIds()) {
      boolean hasColIdParam=false;
      for (ListIterator<IParamDescriptionPO> paramListIter=getParameterListIter(); paramListIter.hasNext(); ) {
        IParamDescriptionPO paramDescr=paramListIter.next();
        if (colId.equals(paramDescr.getUniqueId())) {
          hasColIdParam=true;
          break;
        }
      }
      if (!hasColIdParam) {
        return true;
      }
    }
  }
  return false;
}
Program: 95538
Project: 95538
Buggy source:
/** 
 * @param tdc the test data cube to search for reusage
 * @param session The session into which the test cases will be loaded.
 * @return list of ITestDataCubePO
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public static List<ITestDataCubePO> computeReuser(IParameterInterfacePO tdc,EntityManager session){
  CriteriaBuilder builder=session.getCriteriaBuilder();
  CriteriaQuery query=builder.createQuery();
  Root from=query.from(PoMaker.getTestDataCubeClass());
  query.select(from).where(builder.isNotNull(from.get("String_Node_Str")));
  List<ITestDataCubePO> queryResult=session.createQuery(query).getResultList();
  List<ITestDataCubePO> result=new ArrayList<ITestDataCubePO>();
  for (  ITestDataCubePO pio : queryResult) {
    if (areEqual(pio.getReferencedDataCube(),tdc)) {
      result.add(pio);
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * @param tdc the test data cube to search for reusage
 * @param session The session into which the test cases will be loaded.
 * @return list of ITestDataCubePO
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public static List<ITestDataCubePO> computeReuser(IParameterInterfacePO tdc,EntityManager session){
  CriteriaBuilder builder=session.getCriteriaBuilder();
  CriteriaQuery query=builder.createQuery();
  Root from=query.from(PoMaker.getTestDataCubeClass());
  query.select(from).where(builder.and(builder.isNotNull(from.get("String_Node_Str")),builder.equal(from.get("String_Node_Str"),tdc.getParentProjectId())));
  List<ITestDataCubePO> queryResult=session.createQuery(query).getResultList();
  List<ITestDataCubePO> result=new ArrayList<ITestDataCubePO>();
  for (  ITestDataCubePO pio : queryResult) {
    if (areEqual(pio.getReferencedDataCube(),tdc)) {
      result.add(pio);
    }
  }
  return result;
}
Program: 95539
Project: 95539
Buggy source:
/** 
 * @return the action property descriptor.
 */
private IPropertyDescriptor getActionPropDesc(){
  if (m_actionPropDesc == null) {
    ComboBoxPropertyDescriptor cbpd=new ComboBoxPropertyDescriptor(m_actionTypeController,P_ELEMENT_DISPLAY_ACTIONTYPE,m_actionTypes);
    cbpd.setLabelProvider(new LabelProvider(){
      public String getText(      Object element){
        if (element instanceof Integer) {
          return m_actionTypes[((Integer)element).intValue()];
        }
        Assert.notReached(Messages.WrongElementType + StringConstants.DOT);
        return String.valueOf(element);
      }
    }
);
    cbpd.setCategory(P_ACTION_CAT);
    m_actionPropDesc=cbpd;
  }
  return m_actionPropDesc;
}

Fixed version (ground truth):
/** 
 * @return the action property descriptor.
 */
private IPropertyDescriptor getActionPropDesc(){
  if (m_actionPropDesc == null) {
    ComboBoxPropertyDescriptor cbpd=new ComboBoxPropertyDescriptor(m_actionTypeController,P_ELEMENT_DISPLAY_ACTIONTYPE,m_actionTypes);
    cbpd.setLabelProvider(new LabelProvider(){
      public String getText(      Object element){
        if (element instanceof Integer) {
          int temp=((Integer)element).intValue();
          if (temp < m_actionTypes.length) {
            return m_actionTypes[temp];
          }
        }
        Assert.notReached(Messages.WrongElementType + StringConstants.DOT);
        return String.valueOf(element);
      }
    }
);
    cbpd.setCategory(P_ACTION_CAT);
    m_actionPropDesc=cbpd;
  }
  return m_actionPropDesc;
}
Program: 95540
Project: 95540
Buggy source:
/** 
 * @param componentNames the names of the components to support
 * @param toolkitDescriptor the descriptor of the belonging toolkit
 */
public void addSimpleExtensions(List<String> componentNames,ToolkitDescriptor toolkitDescriptor){
  Component graphicsComponent=null;
  for (  Component comp : getComponents()) {
    if (comp.getType().equalsIgnoreCase("String_Node_Str")) {
      graphicsComponent=comp;
    }
  }
  cleanPreviousSimpleExtension(graphicsComponent);
  for (  String componentName : componentNames) {
    String cleanName=componentName.trim();
    ConcreteComponent myComponent=new ConcreteComponent();
    myComponent.setType(cleanName);
    myComponent.setTesterClass("String_Node_Str");
    myComponent.setComponentClass(new ComponentClass(cleanName));
    myComponent.addRealizedType("String_Node_Str");
    myComponent.setToolkitDesriptor(toolkitDescriptor);
    myComponent.addAllRealizer(myComponent);
    myComponent.getRealizers().add(myComponent);
    graphicsComponent.addAllRealizer(myComponent);
    myComponent.addRealized(graphicsComponent);
    m_componentsByType.put(myComponent.getType(),myComponent);
    m_simpleExtensionComponents.add(myComponent);
  }
  getConcreteComponents().addAll(m_simpleExtensionComponents);
  getComponents().addAll(m_simpleExtensionComponents);
}

Fixed version (ground truth):
/** 
 * @param componentNames the names of the components to support
 * @param toolkitDescriptor the descriptor of the belonging toolkit
 */
public void addSimpleExtensions(List<String> componentNames,ToolkitDescriptor toolkitDescriptor){
  Component graphicsComponent=null;
  for (  Component comp : getComponents()) {
    if (comp.getType().equalsIgnoreCase("String_Node_Str")) {
      graphicsComponent=comp;
    }
  }
  cleanPreviousSimpleExtension(graphicsComponent);
  for (  String componentName : componentNames) {
    String cleanName=componentName.trim();
    if (m_componentsByType.containsKey(cleanName)) {
      continue;
    }
    ConcreteComponent myComponent=new ConcreteComponent();
    myComponent.setType(cleanName);
    myComponent.setTesterClass("String_Node_Str");
    myComponent.setComponentClass(new ComponentClass(cleanName));
    myComponent.addRealizedType("String_Node_Str");
    myComponent.setToolkitDesriptor(toolkitDescriptor);
    myComponent.addAllRealizer(myComponent);
    myComponent.getRealizers().add(myComponent);
    graphicsComponent.addAllRealizer(myComponent);
    myComponent.addRealized(graphicsComponent);
    m_componentsByType.put(myComponent.getType(),myComponent);
    m_simpleExtensionComponents.add(myComponent);
  }
  getConcreteComponents().addAll(m_simpleExtensionComponents);
  getComponents().addAll(m_simpleExtensionComponents);
}
Program: 95541
Project: 95541
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public String toString(){
  StringBuilder sb=new StringBuilder();
  for (  String elem : m_valueSet) {
    sb.append(elem.trim() + "String_Node_Str");
  }
  if (sb.length() > 0) {
    sb.replace(sb.lastIndexOf("String_Node_Str"),sb.lastIndexOf("String_Node_Str"),"String_Node_Str");
  }
  return sb.toString().trim();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public String toString(){
  StringBuilder sb=new StringBuilder();
  for (  String elem : m_valueSet) {
    sb.append(elem.trim() + StringConstants.COMMA + StringConstants.SPACE);
  }
  if (sb.length() > 0) {
    sb.replace(sb.lastIndexOf("String_Node_Str"),sb.lastIndexOf("String_Node_Str"),"String_Node_Str");
  }
  return sb.toString().trim();
}
Program: 95542
Project: 95542
Buggy source:
/** 
 * Constructor 
 */
public ValueSet(){
  m_valueSet=new HashSet<>();
}

Fixed version (ground truth):
/** 
 * Constructor 
 */
public ValueSet(){
  m_valueSet=new LinkedHashSet<>();
}
Program: 95543
Project: 95543
Buggy source:
/** 
 * {@inheritDoc} 
 */
public Object getAdapter(Class targetedClass,Object objectToAdapt){
  if (targetedClass.isAssignableFrom(IContainerAdapter.class)) {
    if (objectToAdapt instanceof ListCell) {
      return new CustomContainerAdapter((ListCell<?>)objectToAdapt);
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public Object getAdapter(Class targetedClass,Object objectToAdapt){
  if (targetedClass == IContainerAdapter.class) {
    if (objectToAdapt instanceof ListCell) {
      return new CustomContainerAdapter((ListCell<?>)objectToAdapt);
    }
  }
  return null;
}
Program: 95544
Project: 95544
Buggy source:
/** 
 * @param targetAdapterClass Type of the adapter
 * @param objectToAdapt object that should be adapted
 * @return Returns an adapter for the objectToAdapt of typetargetAdapterClass. The collection of all supported adapter factories is iterated. The first value that is not null will be returned. <code>Null</code> will only be returned if no adapter can be found for the targetAdapterClass, none of the given factories can handle the objectToAdapt or the objectToAdapt itself is <code>null</code>.
 */
public Object getAdapter(Class targetAdapterClass,Object objectToAdapt){
  if (objectToAdapt == null) {
    return null;
  }
  Collection<IAdapterFactory> registeredFactories=null;
  Class superClass=objectToAdapt.getClass();
  while (registeredFactories == null && superClass != Object.class) {
    registeredFactories=m_registrationMap.get(superClass);
    superClass=superClass.getSuperclass();
  }
  if (registeredFactories == null) {
    return null;
  }
  for (Iterator<IAdapterFactory> iterator=registeredFactories.iterator(); iterator.hasNext(); ) {
    IAdapterFactory adapterFactory=iterator.next();
    Object object=adapterFactory.getAdapter(targetAdapterClass,objectToAdapt);
    if (object != null) {
      return object;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * @param targetAdapterClass Type of the adapter
 * @param objectToAdapt object that should be adapted
 * @return Returns an adapter for the objectToAdapt of typetargetAdapterClass. The collection of all supported adapter factories is iterated. The first value that is not null will be returned. <code>Null</code> will only be returned if no adapter can be found for the targetAdapterClass, none of the given factories can handle the objectToAdapt or the objectToAdapt itself is <code>null</code>.
 */
public Object getAdapter(Class targetAdapterClass,Object objectToAdapt){
  if (objectToAdapt == null) {
    return null;
  }
  Collection<IAdapterFactory> registeredFactories=null;
  Class superClass=objectToAdapt.getClass();
  registeredFactories=findAdapterFactories(objectToAdapt,superClass);
  while (registeredFactories != null && superClass != Object.class) {
    for (Iterator<IAdapterFactory> iterator=registeredFactories.iterator(); iterator.hasNext(); ) {
      IAdapterFactory adapterFactory=iterator.next();
      Object object=adapterFactory.getAdapter(targetAdapterClass,objectToAdapt);
      if (object != null) {
        return object;
      }
    }
    superClass=superClass.getSuperclass();
    registeredFactories=findAdapterFactories(objectToAdapt,superClass);
  }
  return null;
}
Program: 95545
Project: 95545
Buggy source:
/** 
 * {@inheritDoc} 
 */
public Object getAdapter(Class targetedClass,Object objectToAdapt){
  if (targetedClass.isAssignableFrom(IContainerAdapter.class)) {
    if (objectToAdapt instanceof ButtonBar) {
      return new ButtonBarContainerAdapter<ButtonBar>((ButtonBar)objectToAdapt);
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public Object getAdapter(Class targetedClass,Object objectToAdapt){
  if (targetedClass == IContainerAdapter.class) {
    if (objectToAdapt instanceof ButtonBar) {
      return new ButtonBarContainerAdapter<ButtonBar>((ButtonBar)objectToAdapt);
    }
  }
  return null;
}
Program: 95546
Project: 95546
Buggy source:
@Override public Object getAdapter(Class targetAdapterClass,Object objectToAdapt){
  IComponent returnvalue=null;
  if (targetAdapterClass.isAssignableFrom(IComponent.class)) {
    returnvalue=getComponentAdapter(objectToAdapt);
  }
  if (returnvalue == null && targetAdapterClass.isAssignableFrom(IContainerAdapter.class)) {
    returnvalue=getContainerAdapter(objectToAdapt);
  }
  if (returnvalue == null && targetAdapterClass.isAssignableFrom(IComponent.class) && objectToAdapt instanceof Node) {
    return new JavaFXComponentAdapter<Node>((Node)objectToAdapt);
  }
  return returnvalue;
}

Fixed version (ground truth):
@Override public Object getAdapter(Class targetAdapterClass,Object objectToAdapt){
  IComponent returnvalue=null;
  if (targetAdapterClass.isAssignableFrom(IComponent.class)) {
    returnvalue=getComponentAdapter(objectToAdapt);
  }
  if (returnvalue == null && targetAdapterClass == IContainerAdapter.class) {
    returnvalue=getContainerAdapter(objectToAdapt);
  }
  if (returnvalue == null && targetAdapterClass.isAssignableFrom(IComponent.class) && objectToAdapt instanceof Node) {
    return new JavaFXComponentAdapter<Node>((Node)objectToAdapt);
  }
  return returnvalue;
}
Program: 95547
Project: 95547
Buggy source:
/** 
 * Get instances of the given arguments
 * @param args the values for the arguments
 * @param argsSplit the argument separator
 * @param parameterClasses the classes for the arguments
 * @return Object array containing the created objects with the specified value
 * @throws NoSuchMethodException
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 * @throws InstantiationException
 */
public static Object[] getParameterValues(String args,@Nullable String argsSplit,Class<?>[] parameterClasses) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
  String[] argValues;
  if (!StringUtils.isEmpty(argsSplit)) {
    argValues=args.split(argsSplit);
  }
 else {
    argValues=new String[]{args};
  }
  if (argValues.length != parameterClasses.length) {
    throw new StepExecutionException("String_Node_Str",EventFactory.createActionError(TestErrorEvent.INVALID_INPUT));
  }
  Object[] argObjects=new Object[argValues.length];
  for (int i=0; i < argValues.length; i++) {
    argObjects[i]=ConstructorUtils.invokeExactConstructor(parameterClasses[i],argValues[i]);
  }
  return argObjects;
}

Fixed version (ground truth):
/** 
 * Get instances of the given arguments
 * @param args the values for the arguments
 * @param argsSplit the argument separator
 * @param parameterClasses the classes for the arguments
 * @return Object array containing the created objects with the specified value
 * @throws NoSuchMethodException
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 * @throws InstantiationException
 */
public static Object[] getParameterValues(String args,@Nullable String argsSplit,Class<?>[] parameterClasses) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
  String[] argValues;
  if (!StringUtils.isEmpty(argsSplit)) {
    argValues=StringUtils.splitPreserveAllTokens(args,argsSplit);
  }
 else {
    argValues=new String[]{args};
  }
  if (argValues.length != parameterClasses.length) {
    throw new StepExecutionException("String_Node_Str",EventFactory.createActionError(TestErrorEvent.INVALID_INPUT));
  }
  Object[] argObjects=new Object[argValues.length];
  for (int i=0; i < argValues.length; i++) {
    argObjects[i]=ConstructorUtils.invokeExactConstructor(parameterClasses[i],argValues[i]);
  }
  return argObjects;
}
Program: 95548
Project: 95548
Buggy source:
/** 
 * Get instances of the given arguments
 * @param args the values for the arguments
 * @param argsSplit the argument separator
 * @param parameterClasses the classes for the arguments
 * @return Object array containing the created objects with the specified value
 * @throws NoSuchMethodException
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 * @throws InstantiationException
 */
public static Object[] getParameterValues(String args,@Nullable String argsSplit,Class<?>[] parameterClasses) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
  String[] argValues;
  if (!StringUtils.isEmpty(argsSplit)) {
    argValues=args.split(argsSplit);
  }
 else {
    argValues=new String[]{args};
  }
  if (argValues.length != parameterClasses.length) {
    throw new StepExecutionException("String_Node_Str",EventFactory.createActionError(TestErrorEvent.INVALID_INPUT));
  }
  Object[] argObjects=new Object[argValues.length];
  for (int i=0; i < argValues.length; i++) {
    argObjects[i]=ConstructorUtils.invokeExactConstructor(parameterClasses[i],argValues[i]);
  }
  return argObjects;
}

Fixed version (ground truth):
/** 
 * Get instances of the given arguments
 * @param args the values for the arguments
 * @param argsSplit the argument separator
 * @param parameterClasses the classes for the arguments
 * @return Object array containing the created objects with the specified value
 * @throws NoSuchMethodException
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 * @throws InstantiationException
 */
public static Object[] getParameterValues(String args,@Nullable String argsSplit,Class<?>[] parameterClasses) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
  String[] argValues;
  if (!StringUtils.isEmpty(argsSplit)) {
    argValues=StringUtils.splitPreserveAllTokens(args,argsSplit);
  }
 else {
    argValues=new String[]{args};
  }
  if (argValues.length != parameterClasses.length) {
    throw new StepExecutionException("String_Node_Str",EventFactory.createActionError(TestErrorEvent.INVALID_INPUT));
  }
  Object[] argObjects=new Object[argValues.length];
  for (int i=0; i < argValues.length; i++) {
    argObjects[i]=ConstructorUtils.invokeExactConstructor(parameterClasses[i],argValues[i]);
  }
  return argObjects;
}
Program: 95550
Project: 95550
Buggy source:
/** 
 * Clicks on a menu item
 * @param robot the robot
 * @param item  the menu item
 */
private void clickMenuItem(IRobot robot,JMenuItem item){
  if (EnvironmentUtils.isMacOS()) {
    TimeUtil.delay(300);
  }
  if (!item.isEnabled()) {
    throw new StepExecutionException("String_Node_Str",EventFactory.createActionError(TestErrorEvent.MENU_ITEM_NOT_ENABLED));
  }
  if (item.getParent() instanceof JPopupMenu && ((JPopupMenu)item.getParent()).getInvoker().getParent() instanceof JMenuBar) {
    if (!EnvironmentUtils.isMacOS()) {
      robot.click(item,null,ClickOptions.create().setClickType(ClickOptions.ClickType.RELEASED).setFirstHorizontal(false));
    }
 else {
      item.doClick(100);
    }
  }
 else {
    if (!EnvironmentUtils.isMacOS()) {
      robot.click(item,null,ClickOptions.create().setClickType(ClickOptions.ClickType.RELEASED));
    }
 else {
      item.doClick(100);
    }
  }
}

Fixed version (ground truth):
/** 
 * Clicks on a menu item
 * @param robot the robot
 * @param item  the menu item
 */
private void clickMenuItem(IRobot robot,JMenuItem item){
  if (EnvironmentUtils.isMacOS()) {
    TimeUtil.delay(300);
  }
  if (!item.isEnabled()) {
    throw new StepExecutionException("String_Node_Str",EventFactory.createActionError(TestErrorEvent.MENU_ITEM_NOT_ENABLED));
  }
  MenuSelectionManager selectionmanager=MenuSelectionManager.defaultManager();
  MenuElement[] menus=new MenuElement[0];
  if (selectionmanager != null) {
    menus=MenuSelectionManager.defaultManager().getSelectedPath();
  }
  if (item.getParent() instanceof JPopupMenu && ((JPopupMenu)item.getParent()).getInvoker().getParent() instanceof JMenuBar) {
    if (!EnvironmentUtils.isMacOS() || (menus.length > 0 && menus[0] instanceof JPopupMenu)) {
      robot.click(item,null,ClickOptions.create().setClickType(ClickOptions.ClickType.RELEASED).setFirstHorizontal(false));
    }
 else {
      item.doClick();
    }
  }
 else {
    if (!EnvironmentUtils.isMacOS() || (menus.length > 0 && menus[0] instanceof JPopupMenu)) {
      robot.click(item,null,ClickOptions.create().setClickType(ClickOptions.ClickType.RELEASED));
    }
 else {
      item.doClick();
    }
  }
}
Program: 95551
Project: 95551
Buggy source:
/** 
 * Refreshes the original versions, which were possibly modified in editor
 * @throws ProjectDeletedException if the project was deleted in another instance
 */
private void refreshOriginalVersions() throws ProjectDeletedException {
  try {
    final EntityManager masterSession=GeneralStorage.getInstance().getMasterSession();
    IPersistentObject original=getOriginal();
    if (original != null) {
      masterSession.refresh(masterSession.merge(getWorkVersion()));
      Persistor.instance().getTransaction(masterSession).commit();
      GeneralStorage.getInstance().fireDataModified(original);
    }
  }
 catch (  PersistenceException e) {
    log.error(Messages.RefreshOfOriginalVersionFailed + StringConstants.DOT,e);
    GeneralStorage.getInstance().reloadMasterSession(new NullProgressMonitor());
  }
}

Fixed version (ground truth):
/** 
 * Refreshes the original versions, which were possibly modified in editor
 * @throws ProjectDeletedException if the project was deleted in another instance
 */
private void refreshOriginalVersions() throws ProjectDeletedException {
  try {
    final EntityManager masterSession=GeneralStorage.getInstance().getMasterSession();
    IPersistentObject original=getOriginal();
    if (original != null) {
      masterSession.refresh(masterSession.merge(getWorkVersion()));
      GeneralStorage.getInstance().fireDataModified(original);
    }
  }
 catch (  PersistenceException e) {
    log.error(Messages.RefreshOfOriginalVersionFailed + StringConstants.DOT,e);
    GeneralStorage.getInstance().reloadMasterSession(new NullProgressMonitor());
  }
}
Program: 95553
Project: 95553
Buggy source:
/** 
 * {@inheritDoc} 
 */
public Object executeImpl(ExecutionEvent event){
  IStructuredSelection structuredSelection=getSelection();
  Set<IComponentNamePO> toDelete=new HashSet<IComponentNamePO>();
  for (  Object obj : structuredSelection.toArray()) {
    if (obj instanceof IComponentNamePO) {
      toDelete.add((IComponentNamePO)obj);
    }
  }
  List<String> itemNames=new ArrayList<String>();
  for (  IComponentNamePO compName : toDelete) {
    itemNames.add(compName.getName());
  }
  if (confirmDelete(itemNames)) {
    EntityManager s=GeneralStorage.getInstance().getMasterSession();
    try {
      EntityTransaction tx=Persistor.instance().getTransaction(s);
      Persistor.instance().lockPOSet(s,toDelete);
      for (      IComponentNamePO compName : toDelete) {
        s.remove(s.merge(compName));
      }
      Persistor.instance().commitTransaction(s,tx);
      for (      IComponentNamePO compName : toDelete) {
        DataEventDispatcher.getInstance().fireDataChangedListener(compName,DataState.Deleted,UpdateState.all);
        ComponentNamesBP.getInstance().removeComponentNamePO(compName.getGuid());
      }
    }
 catch (    PMException e) {
      PMExceptionHandler.handlePMExceptionForMasterSession(e);
    }
catch (    ProjectDeletedException e) {
      PMExceptionHandler.handleProjectDeletedException();
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public Object executeImpl(ExecutionEvent event){
  IStructuredSelection structuredSelection=getSelection();
  Set<IComponentNamePO> toDelete=new HashSet<IComponentNamePO>();
  for (  Object obj : structuredSelection.toArray()) {
    if (obj instanceof IComponentNamePO) {
      toDelete.add((IComponentNamePO)obj);
    }
  }
  List<String> itemNames=new ArrayList<String>();
  for (  IComponentNamePO compName : toDelete) {
    itemNames.add(compName.getName());
  }
  if (confirmDelete(itemNames)) {
    EntityManager s=Persistor.instance().openSession();
    try {
      EntityTransaction tx=Persistor.instance().getTransaction(s);
      Persistor.instance().lockPOSet(s,toDelete);
      for (      IComponentNamePO compName : toDelete) {
        s.remove(s.merge(compName));
      }
      Persistor.instance().commitTransaction(s,tx);
      EntityManager masterRO=GeneralStorage.getInstance().getMasterSession();
      IComponentNamePO temp;
      for (      IComponentNamePO compName : toDelete) {
        temp=masterRO.find(compName.getClass(),compName.getId());
        if (temp != null) {
          masterRO.detach(temp);
        }
        ComponentNamesBP.getInstance().removeComponentNamePO(compName.getGuid());
        DataEventDispatcher.getInstance().fireDataChangedListener(compName,DataState.Deleted,UpdateState.all);
      }
    }
 catch (    PMException e) {
      PMExceptionHandler.handlePMExceptionForMasterSession(e);
    }
catch (    ProjectDeletedException e) {
      PMExceptionHandler.handleProjectDeletedException();
    }
 finally {
      Persistor.instance().dropSession(s);
    }
  }
  return null;
}
Program: 95554
Project: 95554
Buggy source:
/** 
 * {@inheritDoc}
 */
public Object executeImpl(ExecutionEvent event){
  IComponentNamePO compName=getSelectedComponentName();
  if (compName != null) {
    EntityManager renameSession=GeneralStorage.getInstance().getMasterSession();
    try {
      ProjectComponentNameMapper compNameMapper=new ProjectComponentNameMapper(new ComponentNamesDecorator(renameSession),GeneralStorage.getInstance().getProject());
      String newName=getNewName(event,compNameMapper,compName);
      if (newName != null) {
        EntityTransaction tx=Persistor.instance().getTransaction(renameSession);
        rename(compNameMapper,compName.getGuid(),newName);
        Persistor.instance().commitTransaction(renameSession,tx);
        compNameMapper.getCompNameCache().updateStandardMapperAndCleanup(GeneralStorage.getInstance().getProject().getId());
        IComponentNamePO eventCompName=ComponentNamesBP.getInstance().getCompNamePo(compName.getGuid());
        DataEventDispatcher.getInstance().fireDataChangedListener(eventCompName,DataState.Renamed,UpdateState.all);
      }
    }
 catch (    PMException e) {
      PMExceptionHandler.handlePMExceptionForMasterSession(e);
    }
catch (    ProjectDeletedException e) {
      PMExceptionHandler.handleProjectDeletedException();
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public Object executeImpl(ExecutionEvent event){
  IComponentNamePO compName=getSelectedComponentName();
  if (compName != null) {
    EntityManager renameSession=Persistor.instance().openSession();
    try {
      ProjectComponentNameMapper compNameMapper=new ProjectComponentNameMapper(new ComponentNamesDecorator(renameSession),GeneralStorage.getInstance().getProject());
      String newName=getNewName(event,compNameMapper,compName);
      if (newName != null) {
        EntityTransaction tx=Persistor.instance().getTransaction(renameSession);
        rename(compNameMapper,compName.getGuid(),newName);
        Persistor.instance().commitTransaction(renameSession,tx);
        compNameMapper.getCompNameCache().updateStandardMapperAndCleanup(GeneralStorage.getInstance().getProject().getId());
        IComponentNamePO eventCompName=ComponentNamesBP.getInstance().getCompNamePo(compName.getGuid());
        DataEventDispatcher.getInstance().fireDataChangedListener(eventCompName,DataState.Renamed,UpdateState.all);
        EntityManager masterRO=GeneralStorage.getInstance().getMasterSession();
        IComponentNamePO refreshCN;
        refreshCN=masterRO.find(compName.getClass(),compName.getId());
        if (refreshCN != null) {
          masterRO.refresh(refreshCN);
        }
      }
    }
 catch (    PMException e) {
      PMExceptionHandler.handlePMExceptionForMasterSession(e);
    }
catch (    ProjectDeletedException e) {
      PMExceptionHandler.handleProjectDeletedException();
    }
 finally {
      Persistor.instance().dropSession(renameSession);
    }
  }
  return null;
}
Program: 95555
Project: 95555
Buggy source:
/** 
 * register handler for project load and data change to clear caches
 */
public ComponentNameBrowserContentProvider(){
  DataEventDispatcher ded=DataEventDispatcher.getInstance();
  ded.addProjectLoadedListener(this,true);
  ded.addDataChangedListener(this,true);
}

Fixed version (ground truth):
/** 
 * register handler for project load and data change to clear caches
 */
public ComponentNameBrowserContentProvider(){
  DataEventDispatcher ded=DataEventDispatcher.getInstance();
  ded.addProjectLoadedListener(this,true);
  ded.addDataChangedListener(this,false);
}
Program: 95557
Project: 95557
Buggy source:
/** 
 * Tries to select a menu item in a menu defined by an Index-Path
 * @param indexPath the menu item to select
 */
public void selectMenuItemByIndexpath(String indexPath){
  int[] indexItems=MenuUtilBase.splitIndexPath(indexPath);
  checkPathLength(indexItems.length);
  try {
    final IMenuItemComponent item=navigateToMenuItem(getAndCheckMenu(),indexItems);
    checkIsNull(item);
    item.selectMenuItem();
    if (EnvironmentUtils.isMacOS() && item.isShowing()) {
      MenuSelectionManager.defaultManager().clearSelectedPath();
    }
  }
 catch (  StepExecutionException e) {
    try {
      closeMenu(getAndCheckMenu(),indexItems);
    }
 catch (    StepExecutionException e1) {
      if (getLog().isInfoEnabled()) {
        getLog().info("String_Node_Str");
      }
    }
    throwMenuItemNotFound();
  }
}

Fixed version (ground truth):
/** 
 * Tries to select a menu item in a menu defined by an Index-Path
 * @param indexPath the menu item to select
 */
public void selectMenuItemByIndexpath(String indexPath){
  int[] indexItems=MenuUtilBase.splitIndexPath(indexPath);
  checkPathLength(indexItems.length);
  try {
    final IMenuItemComponent item=navigateToMenuItem(getAndCheckMenu(),indexItems);
    checkIsNull(item);
    item.selectMenuItem();
    if (EnvironmentUtils.isMacOS() && item.isShowing()) {
      closeMenu(getAndCheckMenu(),indexItems);
    }
  }
 catch (  StepExecutionException e) {
    try {
      closeMenu(getAndCheckMenu(),indexItems);
    }
 catch (    StepExecutionException e1) {
      if (getLog().isInfoEnabled()) {
        getLog().info("String_Node_Str");
      }
    }
    throwMenuItemNotFound();
  }
}
Program: 95558
Project: 95558
Buggy source:
/** 
 * Tries to select a menu item in a menu defined by a Text-Path
 * @param namePath the menu item to select
 * @param operator operator used for matching
 */
public void selectMenuItem(String namePath,final String operator){
  String[] menuItems=MenuUtilBase.splitPath(namePath);
  if (menuItems.length == 0) {
    throw new StepExecutionException("String_Node_Str",EventFactory.createActionError());
  }
  IMenuItemComponent item=navigateToMenuItem(getAndCheckMenu(),menuItems,operator);
  if (item == null || item.getRealComponent() == null) {
    try {
      closeMenu(getAndCheckMenu(),menuItems,operator);
    }
 catch (    StepExecutionException see) {
      getLog().info("String_Node_Str");
    }
    throwMenuItemNotFound();
  }
  item.selectMenuItem();
  if (EnvironmentUtils.isMacOS() && item.isShowing()) {
    MenuSelectionManager.defaultManager().clearSelectedPath();
  }
}

Fixed version (ground truth):
/** 
 * Tries to select a menu item in a menu defined by a Text-Path
 * @param namePath the menu item to select
 * @param operator operator used for matching
 */
public void selectMenuItem(String namePath,final String operator){
  String[] menuItems=MenuUtilBase.splitPath(namePath);
  if (menuItems.length == 0) {
    throw new StepExecutionException("String_Node_Str",EventFactory.createActionError());
  }
  IMenuItemComponent item=navigateToMenuItem(getAndCheckMenu(),menuItems,operator);
  if (item == null || item.getRealComponent() == null) {
    try {
      closeMenu(getAndCheckMenu(),menuItems,operator);
    }
 catch (    StepExecutionException see) {
      getLog().info("String_Node_Str");
    }
    throwMenuItemNotFound();
  }
  item.selectMenuItem();
  if (EnvironmentUtils.isMacOS() && item.isShowing()) {
    closeMenu(getAndCheckMenu(),menuItems,operator);
  }
}
Program: 95559
Project: 95559
Buggy source:
/** 
 * {@inheritDoc}
 */
protected void closeMenu(IMenuComponent menuBar,int[] path){
  if (menuBar.getRealComponent() instanceof JPopupMenu) {
    for (int i=0; i < path.length; i++) {
      if (((JPopupMenu)menuBar.getRealComponent()).isVisible()) {
        getRobot().keyType(menuBar.getRealComponent(),KeyEvent.VK_ESCAPE);
      }
    }
    return;
  }
  super.closeMenu(menuBar,path);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
protected void closeMenu(IMenuComponent menuBar,int[] path){
  if (closMacMenus()) {
    return;
  }
  if (menuBar.getRealComponent() instanceof JPopupMenu) {
    for (int i=0; i < path.length; i++) {
      if (((JPopupMenu)menuBar.getRealComponent()).isVisible()) {
        getRobot().keyType(menuBar.getRealComponent(),KeyEvent.VK_ESCAPE);
      }
    }
    return;
  }
  super.closeMenu(menuBar,path);
}
Program: 95560
Project: 95560
Buggy source:
/** 
 * Checks if there are unused Test Data in this TDManagerPO  (Data column without a parameter).
 * @return true if there are unused Test Data in this TDManagerPO., false otherwise.
 */
public boolean checkHasUnusedTestData(){
  for (  String colId : getDataManager().getUniqueIds()) {
    boolean hasColIdParam=false;
    for (ListIterator<IParamDescriptionPO> paramListIter=getParameterListIter(); paramListIter.hasNext(); ) {
      IParamDescriptionPO paramDescr=paramListIter.next();
      if (colId.equals(paramDescr.getUniqueId())) {
        hasColIdParam=true;
        break;
      }
    }
    if (!hasColIdParam) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Checks if there are unused Test Data in this TDManagerPO  (Data column without a parameter).
 * @return true if there are unused Test Data in this TDManagerPO., false otherwise.
 */
public boolean checkHasUnusedTestData(){
  if (getReferencedDataCube() == null) {
    for (    String colId : getDataManager().getUniqueIds()) {
      boolean hasColIdParam=false;
      for (ListIterator<IParamDescriptionPO> paramListIter=getParameterListIter(); paramListIter.hasNext(); ) {
        IParamDescriptionPO paramDescr=paramListIter.next();
        if (colId.equals(paramDescr.getUniqueId())) {
          hasColIdParam=true;
          break;
        }
      }
      if (!hasColIdParam) {
        return true;
      }
    }
  }
  return false;
}
Program: 95561
Project: 95561
Buggy source:
/** 
 * @param tdc the test data cube to search for reusage
 * @param session The session into which the test cases will be loaded.
 * @return list of ITestDataCubePO
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public static List<ITestDataCubePO> computeReuser(IParameterInterfacePO tdc,EntityManager session){
  CriteriaBuilder builder=session.getCriteriaBuilder();
  CriteriaQuery query=builder.createQuery();
  Root from=query.from(PoMaker.getTestDataCubeClass());
  query.select(from).where(builder.isNotNull(from.get("String_Node_Str")));
  List<ITestDataCubePO> queryResult=session.createQuery(query).getResultList();
  List<ITestDataCubePO> result=new ArrayList<ITestDataCubePO>();
  for (  ITestDataCubePO pio : queryResult) {
    if (areEqual(pio.getReferencedDataCube(),tdc)) {
      result.add(pio);
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * @param tdc the test data cube to search for reusage
 * @param session The session into which the test cases will be loaded.
 * @return list of ITestDataCubePO
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public static List<ITestDataCubePO> computeReuser(IParameterInterfacePO tdc,EntityManager session){
  CriteriaBuilder builder=session.getCriteriaBuilder();
  CriteriaQuery query=builder.createQuery();
  Root from=query.from(PoMaker.getTestDataCubeClass());
  query.select(from).where(builder.and(builder.isNotNull(from.get("String_Node_Str")),builder.equal(from.get("String_Node_Str"),tdc.getParentProjectId())));
  List<ITestDataCubePO> queryResult=session.createQuery(query).getResultList();
  List<ITestDataCubePO> result=new ArrayList<ITestDataCubePO>();
  for (  ITestDataCubePO pio : queryResult) {
    if (areEqual(pio.getReferencedDataCube(),tdc)) {
      result.add(pio);
    }
  }
  return result;
}
Program: 95562
Project: 95562
Buggy source:
/** 
 * Refreshes the original versions, which were possibly modified in editor
 * @throws ProjectDeletedException if the project was deleted in another instance
 */
private void refreshOriginalVersions() throws ProjectDeletedException {
  try {
    final EntityManager masterSession=GeneralStorage.getInstance().getMasterSession();
    IPersistentObject original=getOriginal();
    if (original != null) {
      masterSession.refresh(masterSession.merge(getWorkVersion()));
      Persistor.instance().getTransaction(masterSession).commit();
      GeneralStorage.getInstance().fireDataModified(original);
    }
  }
 catch (  PersistenceException e) {
    log.error(Messages.RefreshOfOriginalVersionFailed + StringConstants.DOT,e);
    GeneralStorage.getInstance().reloadMasterSession(new NullProgressMonitor());
  }
}

Fixed version (ground truth):
/** 
 * Refreshes the original versions, which were possibly modified in editor
 * @throws ProjectDeletedException if the project was deleted in another instance
 */
private void refreshOriginalVersions() throws ProjectDeletedException {
  try {
    final EntityManager masterSession=GeneralStorage.getInstance().getMasterSession();
    IPersistentObject original=getOriginal();
    if (original != null) {
      masterSession.refresh(masterSession.merge(getWorkVersion()));
      GeneralStorage.getInstance().fireDataModified(original);
    }
  }
 catch (  PersistenceException e) {
    log.error(Messages.RefreshOfOriginalVersionFailed + StringConstants.DOT,e);
    GeneralStorage.getInstance().reloadMasterSession(new NullProgressMonitor());
  }
}
Program: 95564
Project: 95564
Buggy source:
/** 
 * {@inheritDoc} 
 */
public Object executeImpl(ExecutionEvent event){
  IStructuredSelection structuredSelection=getSelection();
  Set<IComponentNamePO> toDelete=new HashSet<IComponentNamePO>();
  for (  Object obj : structuredSelection.toArray()) {
    if (obj instanceof IComponentNamePO) {
      toDelete.add((IComponentNamePO)obj);
    }
  }
  List<String> itemNames=new ArrayList<String>();
  for (  IComponentNamePO compName : toDelete) {
    itemNames.add(compName.getName());
  }
  if (confirmDelete(itemNames)) {
    EntityManager s=GeneralStorage.getInstance().getMasterSession();
    try {
      EntityTransaction tx=Persistor.instance().getTransaction(s);
      Persistor.instance().lockPOSet(s,toDelete);
      for (      IComponentNamePO compName : toDelete) {
        s.remove(s.merge(compName));
      }
      Persistor.instance().commitTransaction(s,tx);
      for (      IComponentNamePO compName : toDelete) {
        DataEventDispatcher.getInstance().fireDataChangedListener(compName,DataState.Deleted,UpdateState.all);
        ComponentNamesBP.getInstance().removeComponentNamePO(compName.getGuid());
      }
    }
 catch (    PMException e) {
      PMExceptionHandler.handlePMExceptionForMasterSession(e);
    }
catch (    ProjectDeletedException e) {
      PMExceptionHandler.handleProjectDeletedException();
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public Object executeImpl(ExecutionEvent event){
  IStructuredSelection structuredSelection=getSelection();
  Set<IComponentNamePO> toDelete=new HashSet<IComponentNamePO>();
  for (  Object obj : structuredSelection.toArray()) {
    if (obj instanceof IComponentNamePO) {
      toDelete.add((IComponentNamePO)obj);
    }
  }
  List<String> itemNames=new ArrayList<String>();
  for (  IComponentNamePO compName : toDelete) {
    itemNames.add(compName.getName());
  }
  if (confirmDelete(itemNames)) {
    EntityManager s=Persistor.instance().openSession();
    try {
      EntityTransaction tx=Persistor.instance().getTransaction(s);
      Persistor.instance().lockPOSet(s,toDelete);
      for (      IComponentNamePO compName : toDelete) {
        s.remove(s.merge(compName));
      }
      Persistor.instance().commitTransaction(s,tx);
      EntityManager masterRO=GeneralStorage.getInstance().getMasterSession();
      IComponentNamePO temp;
      for (      IComponentNamePO compName : toDelete) {
        temp=masterRO.find(compName.getClass(),compName.getId());
        if (temp != null) {
          masterRO.detach(temp);
        }
        ComponentNamesBP.getInstance().removeComponentNamePO(compName.getGuid());
        DataEventDispatcher.getInstance().fireDataChangedListener(compName,DataState.Deleted,UpdateState.all);
      }
    }
 catch (    PMException e) {
      PMExceptionHandler.handlePMExceptionForMasterSession(e);
    }
catch (    ProjectDeletedException e) {
      PMExceptionHandler.handleProjectDeletedException();
    }
 finally {
      Persistor.instance().dropSession(s);
    }
  }
  return null;
}
Program: 95565
Project: 95565
Buggy source:
/** 
 * {@inheritDoc}
 */
public Object executeImpl(ExecutionEvent event){
  IComponentNamePO compName=getSelectedComponentName();
  if (compName != null) {
    EntityManager renameSession=GeneralStorage.getInstance().getMasterSession();
    try {
      ProjectComponentNameMapper compNameMapper=new ProjectComponentNameMapper(new ComponentNamesDecorator(renameSession),GeneralStorage.getInstance().getProject());
      String newName=getNewName(event,compNameMapper,compName);
      if (newName != null) {
        EntityTransaction tx=Persistor.instance().getTransaction(renameSession);
        rename(compNameMapper,compName.getGuid(),newName);
        Persistor.instance().commitTransaction(renameSession,tx);
        compNameMapper.getCompNameCache().updateStandardMapperAndCleanup(GeneralStorage.getInstance().getProject().getId());
        IComponentNamePO eventCompName=ComponentNamesBP.getInstance().getCompNamePo(compName.getGuid());
        DataEventDispatcher.getInstance().fireDataChangedListener(eventCompName,DataState.Renamed,UpdateState.all);
      }
    }
 catch (    PMException e) {
      PMExceptionHandler.handlePMExceptionForMasterSession(e);
    }
catch (    ProjectDeletedException e) {
      PMExceptionHandler.handleProjectDeletedException();
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public Object executeImpl(ExecutionEvent event){
  IComponentNamePO compName=getSelectedComponentName();
  if (compName != null) {
    EntityManager renameSession=Persistor.instance().openSession();
    try {
      ProjectComponentNameMapper compNameMapper=new ProjectComponentNameMapper(new ComponentNamesDecorator(renameSession),GeneralStorage.getInstance().getProject());
      String newName=getNewName(event,compNameMapper,compName);
      if (newName != null) {
        EntityTransaction tx=Persistor.instance().getTransaction(renameSession);
        rename(compNameMapper,compName.getGuid(),newName);
        Persistor.instance().commitTransaction(renameSession,tx);
        compNameMapper.getCompNameCache().updateStandardMapperAndCleanup(GeneralStorage.getInstance().getProject().getId());
        IComponentNamePO eventCompName=ComponentNamesBP.getInstance().getCompNamePo(compName.getGuid());
        DataEventDispatcher.getInstance().fireDataChangedListener(eventCompName,DataState.Renamed,UpdateState.all);
        EntityManager masterRO=GeneralStorage.getInstance().getMasterSession();
        IComponentNamePO refreshCN;
        refreshCN=masterRO.find(compName.getClass(),compName.getId());
        if (refreshCN != null) {
          masterRO.refresh(refreshCN);
        }
      }
    }
 catch (    PMException e) {
      PMExceptionHandler.handlePMExceptionForMasterSession(e);
    }
catch (    ProjectDeletedException e) {
      PMExceptionHandler.handleProjectDeletedException();
    }
 finally {
      Persistor.instance().dropSession(renameSession);
    }
  }
  return null;
}
Program: 95566
Project: 95566
Buggy source:
/** 
 * register handler for project load and data change to clear caches
 */
public ComponentNameBrowserContentProvider(){
  DataEventDispatcher ded=DataEventDispatcher.getInstance();
  ded.addProjectLoadedListener(this,true);
  ded.addDataChangedListener(this,true);
}

Fixed version (ground truth):
/** 
 * register handler for project load and data change to clear caches
 */
public ComponentNameBrowserContentProvider(){
  DataEventDispatcher ded=DataEventDispatcher.getInstance();
  ded.addProjectLoadedListener(this,true);
  ded.addDataChangedListener(this,false);
}
Program: 95568
Project: 95568
Buggy source:
/** 
 * {@inheritDoc} 
 */
public Object getAdapter(Class targetedClass,Object objectToAdapt){
  if (targetedClass.isAssignableFrom(IContainerAdapter.class)) {
    if (objectToAdapt instanceof ListCell) {
      return new CustomContainerAdapter((ListCell<?>)objectToAdapt);
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public Object getAdapter(Class targetedClass,Object objectToAdapt){
  if (targetedClass == IContainerAdapter.class) {
    if (objectToAdapt instanceof ListCell) {
      return new CustomContainerAdapter((ListCell<?>)objectToAdapt);
    }
  }
  return null;
}
Program: 95569
Project: 95569
Buggy source:
/** 
 * @param targetAdapterClass Type of the adapter
 * @param objectToAdapt object that should be adapted
 * @return Returns an adapter for the objectToAdapt of typetargetAdapterClass. The collection of all supported adapter factories is iterated. The first value that is not null will be returned. <code>Null</code> will only be returned if no adapter can be found for the targetAdapterClass, none of the given factories can handle the objectToAdapt or the objectToAdapt itself is <code>null</code>.
 */
public Object getAdapter(Class targetAdapterClass,Object objectToAdapt){
  if (objectToAdapt == null) {
    return null;
  }
  Collection<IAdapterFactory> registeredFactories=null;
  Class superClass=objectToAdapt.getClass();
  while (registeredFactories == null && superClass != Object.class) {
    registeredFactories=m_registrationMap.get(superClass);
    superClass=superClass.getSuperclass();
  }
  if (registeredFactories == null) {
    return null;
  }
  for (Iterator<IAdapterFactory> iterator=registeredFactories.iterator(); iterator.hasNext(); ) {
    IAdapterFactory adapterFactory=iterator.next();
    Object object=adapterFactory.getAdapter(targetAdapterClass,objectToAdapt);
    if (object != null) {
      return object;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * @param targetAdapterClass Type of the adapter
 * @param objectToAdapt object that should be adapted
 * @return Returns an adapter for the objectToAdapt of typetargetAdapterClass. The collection of all supported adapter factories is iterated. The first value that is not null will be returned. <code>Null</code> will only be returned if no adapter can be found for the targetAdapterClass, none of the given factories can handle the objectToAdapt or the objectToAdapt itself is <code>null</code>.
 */
public Object getAdapter(Class targetAdapterClass,Object objectToAdapt){
  if (objectToAdapt == null) {
    return null;
  }
  Collection<IAdapterFactory> registeredFactories=null;
  Class superClass=objectToAdapt.getClass();
  registeredFactories=findAdapterFactories(objectToAdapt,superClass);
  while (registeredFactories != null && superClass != Object.class) {
    for (Iterator<IAdapterFactory> iterator=registeredFactories.iterator(); iterator.hasNext(); ) {
      IAdapterFactory adapterFactory=iterator.next();
      Object object=adapterFactory.getAdapter(targetAdapterClass,objectToAdapt);
      if (object != null) {
        return object;
      }
    }
    superClass=superClass.getSuperclass();
    registeredFactories=findAdapterFactories(objectToAdapt,superClass);
  }
  return null;
}