Program: 128687
Project: 128687
Buggy source:
/** 
 * Get all object in a folder recursively.
 * @param folder - the folder to search in
 * @param id - the id of the object searched. Specify <code>null</code> to get all objects.
 * @param type - the type searched
 * @param allVersion - <code>true</code> if all version of each object must be return or <code>false</code> if onlythe most recent version
 * @return a list (may be empty) of objects found
 * @throws PersistenceException
 */
@Override protected List<IRepositoryViewObject> getSerializableFromFolder(Project project,Object folder,String id,ERepositoryObjectType type,boolean allVersion,boolean searchInChildren,boolean withDeleted,boolean avoidSaveProject,boolean... recursiveCall) throws PersistenceException {
  List<IRepositoryViewObject> toReturn=new VersionList(allVersion);
  FolderHelper folderHelper=getFolderHelper(project.getEmfProject());
  if (folder != null) {
    IFolder physicalFolder;
    FolderItem currentFolderItem=null;
    if (folder instanceof IFolder) {
      if (!((IFolder)folder).getName().equals(BIN)) {
        currentFolderItem=folderHelper.getFolder(((IFolder)folder).getProjectRelativePath());
        if (((IFolder)folder).getLocation().toPortableString().contains(BIN)) {
        }
 else         if (currentFolderItem == null) {
          currentFolderItem=folderHelper.createFolder(((IFolder)folder).getProjectRelativePath().toPortableString());
        }
      }
      physicalFolder=(IFolder)folder;
    }
 else {
      currentFolderItem=(FolderItem)folder;
      physicalFolder=getPhysicalProject(project).getFolder(folderHelper.getFullFolderPath(currentFolderItem));
    }
    List<String> propertyFounds=new ArrayList<String>();
    List<String> folderNamesFounds=new ArrayList<String>();
    List<Item> toRemoveFromFolder=new ArrayList<Item>();
    if (currentFolderItem != null) {
      for (      Item curItem : new ArrayList<Item>(currentFolderItem.getChildren())) {
        Property property=curItem.getProperty();
        if (property != null) {
          if (curItem instanceof FolderItem && searchInChildren) {
            folderNamesFounds.add(curItem.getProperty().getLabel());
            toReturn.addAll(getSerializableFromFolder(project,curItem,id,type,allVersion,true,withDeleted,avoidSaveProject,true));
          }
 else           if (!(curItem instanceof FolderItem)) {
            if (property.eResource() != null) {
              if (id == null || property.getId().equals(id)) {
                if (withDeleted || !property.getItem().getState().isDeleted()) {
                  toReturn.add(new RepositoryObject(property));
                }
              }
              propertyFounds.add(property.eResource().getURI().lastSegment());
              property.getItem().setParent(currentFolderItem);
              addToHistory(id,type,property.getItem().getState().getPath());
            }
 else {
              toRemoveFromFolder.add(curItem);
            }
          }
        }
 else {
          toRemoveFromFolder.add(curItem);
        }
      }
      if (toRemoveFromFolder.size() != 0) {
        currentFolderItem.getChildren().removeAll(toRemoveFromFolder);
      }
    }
    if (physicalFolder.exists()) {
      List<String> physicalPropertyFounds=new ArrayList<String>();
      List<String> physicalDirectoryFounds=new ArrayList<String>();
      for (      IResource current : ResourceUtils.getMembers(physicalFolder)) {
        if (current instanceof IFile) {
          if (xmiResourceManager.isPropertyFile((IFile)current)) {
            String fileName=((IFile)current).getName();
            physicalPropertyFounds.add(fileName);
            if (!propertyFounds.contains(fileName)) {
              Property property=null;
              try {
                property=xmiResourceManager.loadProperty(current);
              }
 catch (              RuntimeException e) {
                ExceptionHandler.process(e);
              }
              if (property != null) {
                if (property.getItem() == null || property.getItem().getState() == null) {
                  if (type != null) {
                    log.error("String_Node_Str" + property.getLabel() + "String_Node_Str"+ type);
                  }
 else {
                    log.error("String_Node_Str" + property.getLabel());
                  }
                  continue;
                }
                addToHistory(property.getId(),type,property.getItem().getState().getPath());
                if (id == null || property.getId().equals(id)) {
                  if (withDeleted || !property.getItem().getState().isDeleted()) {
                    toReturn.add(new RepositoryObject(property));
                  }
                }
                if (currentFolderItem != null && !currentFolderItem.getChildren().contains(property.getItem())) {
                  currentFolderItem.getChildren().add(property.getItem());
                  property.getItem().setParent(currentFolderItem);
                }
              }
 else {
                log.error(Messages.getString("String_Node_Str") + current);
              }
            }
          }
        }
 else         if (current instanceof IFolder) {
          if (!((IFolder)current).getName().startsWith("String_Node_Str") && !FilesUtils.isSVNFolder(current) && searchInChildren) {
            String fileName=((IFolder)current).getName();
            physicalDirectoryFounds.add(fileName);
            if (!folderNamesFounds.contains(((IFolder)current).getName())) {
              FolderItem parentFolder=folderHelper.getFolder(current.getProjectRelativePath());
              if (parentFolder == null) {
                parentFolder=folderHelper.createFolder(current.getProjectRelativePath().toString());
              }
              parentFolder.setParent(currentFolderItem);
              toReturn.addAll(getSerializableFromFolder(project,(IFolder)current,id,type,allVersion,true,withDeleted,avoidSaveProject,true));
            }
            if (((IFolder)current).getName().equals(BIN)) {
              IResource[] binFolder=ResourceUtils.getMembers((IFolder)current);
              if (binFolder.length == 0 || (binFolder.length == 1 && FilesUtils.isSVNFolder(binFolder[0]))) {
                try {
                  ((IFolder)current).delete(true,null);
                }
 catch (                CoreException e) {
                }
              }
            }
          }
        }
      }
      if (currentFolderItem != null) {
        List<Item> itemsDeleted=new ArrayList<Item>();
        for (        Item curItem : (List<Item>)currentFolderItem.getChildren()) {
          if (!(curItem instanceof FolderItem)) {
            String name;
            if (curItem.eResource() != null) {
              name=curItem.eResource().getURI().lastSegment();
            }
 else {
              name=curItem.getProperty().getLabel() + "String_Node_Str" + curItem.getProperty().getVersion()+ "String_Node_Str"+ FileConstants.PROPERTIES_EXTENSION;
            }
            if (!physicalPropertyFounds.contains(name)) {
              itemsDeleted.add(curItem);
            }
          }
 else           if (searchInChildren && ProxyRepositoryFactory.getInstance().isFullLogonFinished()) {
            if (!physicalDirectoryFounds.contains(curItem.getProperty().getLabel())) {
              itemsDeleted.add(curItem);
            }
          }
        }
        for (        Item item : itemsDeleted) {
          item.setParent(null);
          Iterator<IRepositoryViewObject> it=toReturn.iterator();
          while (it.hasNext()) {
            IRepositoryViewObject object=it.next();
            if (object.getLabel().equals(item.getProperty().getLabel()) && object.getId().equals(item.getProperty().getId()) && object.getVersion().equals(item.getProperty().getVersion())) {
              it.remove();
            }
          }
        }
        currentFolderItem.getChildren().removeAll(itemsDeleted);
      }
    }
  }
  return toReturn;
}

Fixed version (ground truth):
/** 
 * Get all object in a folder recursively.
 * @param folder - the folder to search in
 * @param id - the id of the object searched. Specify <code>null</code> to get all objects.
 * @param type - the type searched
 * @param allVersion - <code>true</code> if all version of each object must be return or <code>false</code> if onlythe most recent version
 * @return a list (may be empty) of objects found
 * @throws PersistenceException
 */
@Override protected List<IRepositoryViewObject> getSerializableFromFolder(Project project,Object folder,String id,ERepositoryObjectType type,boolean allVersion,boolean searchInChildren,boolean withDeleted,boolean avoidSaveProject,boolean... recursiveCall) throws PersistenceException {
  List<IRepositoryViewObject> toReturn=new VersionList(allVersion);
  FolderHelper folderHelper=getFolderHelper(project.getEmfProject());
  if (folder != null) {
    IFolder physicalFolder;
    FolderItem currentFolderItem=null;
    if (folder instanceof IFolder) {
      if (!((IFolder)folder).getName().equals(BIN)) {
        currentFolderItem=folderHelper.getFolder(((IFolder)folder).getProjectRelativePath());
        if (((IFolder)folder).getLocation().toPortableString().contains(BIN)) {
        }
 else         if (currentFolderItem == null) {
          currentFolderItem=folderHelper.createFolder(((IFolder)folder).getProjectRelativePath().toPortableString());
        }
      }
      physicalFolder=(IFolder)folder;
    }
 else {
      currentFolderItem=(FolderItem)folder;
      physicalFolder=getPhysicalProject(project).getFolder(folderHelper.getFullFolderPath(currentFolderItem));
    }
    List<String> propertyFounds=new ArrayList<String>();
    List<String> folderNamesFounds=new ArrayList<String>();
    List<Item> toRemoveFromFolder=new ArrayList<Item>();
    if (currentFolderItem != null) {
      for (      Item curItem : new ArrayList<Item>(currentFolderItem.getChildren())) {
        Property property=curItem.getProperty();
        if (property != null) {
          if (curItem instanceof FolderItem && searchInChildren) {
            folderNamesFounds.add(curItem.getProperty().getLabel());
            toReturn.addAll(getSerializableFromFolder(project,curItem,id,type,allVersion,true,withDeleted,avoidSaveProject,true));
          }
 else           if (!(curItem instanceof FolderItem)) {
            if (property.eResource() != null) {
              if (id == null || property.getId().equals(id)) {
                if (withDeleted || !property.getItem().getState().isDeleted()) {
                  toReturn.add(new RepositoryObject(property));
                }
              }
              propertyFounds.add(property.eResource().getURI().lastSegment());
              property.getItem().setParent(currentFolderItem);
              addToHistory(id,type,property.getItem().getState().getPath());
            }
 else {
              toRemoveFromFolder.add(curItem);
            }
          }
        }
 else {
          toRemoveFromFolder.add(curItem);
        }
      }
      if (toRemoveFromFolder.size() != 0) {
        currentFolderItem.getChildren().removeAll(toRemoveFromFolder);
      }
    }
    if (physicalFolder.exists()) {
      List<String> physicalPropertyFounds=new ArrayList<String>();
      List<String> physicalDirectoryFounds=new ArrayList<String>();
      for (      IResource current : ResourceUtils.getMembers(physicalFolder)) {
        if (current instanceof IFile) {
          if (xmiResourceManager.isPropertyFile((IFile)current)) {
            String fileName=((IFile)current).getName();
            physicalPropertyFounds.add(fileName);
            if (!propertyFounds.contains(fileName)) {
              Property property=null;
              try {
                property=xmiResourceManager.loadProperty(current);
              }
 catch (              RuntimeException e) {
                ExceptionHandler.process(e);
              }
              if (property != null) {
                if (property.getItem() == null || property.getItem().getState() == null) {
                  if (type != null) {
                    log.error("String_Node_Str" + property.getLabel() + "String_Node_Str"+ type);
                  }
 else {
                    log.error("String_Node_Str" + property.getLabel());
                  }
                  continue;
                }
                addToHistory(property.getId(),type,property.getItem().getState().getPath());
                if (id == null || property.getId().equals(id)) {
                  if (withDeleted || !property.getItem().getState().isDeleted()) {
                    toReturn.add(new RepositoryObject(property));
                  }
                }
                if (currentFolderItem != null && !currentFolderItem.getChildren().contains(property.getItem())) {
                  currentFolderItem.getChildren().add(property.getItem());
                  property.getItem().setParent(currentFolderItem);
                }
              }
 else {
                log.error(Messages.getString("String_Node_Str") + current);
              }
            }
          }
        }
 else         if (current instanceof IFolder) {
          if (!((IFolder)current).getName().startsWith("String_Node_Str") && !FilesUtils.isSVNFolder(current) && searchInChildren) {
            String fileName=((IFolder)current).getName();
            physicalDirectoryFounds.add(fileName);
            if (!folderNamesFounds.contains(((IFolder)current).getName())) {
              FolderItem parentFolder=folderHelper.getFolder(current.getProjectRelativePath());
              if (parentFolder == null) {
                parentFolder=folderHelper.createFolder(current.getProjectRelativePath().toString());
              }
              parentFolder.setParent(currentFolderItem);
              toReturn.addAll(getSerializableFromFolder(project,(IFolder)current,id,type,allVersion,true,withDeleted,avoidSaveProject,true));
            }
            if (((IFolder)current).getName().equals(BIN)) {
              IResource[] binFolder=ResourceUtils.getMembers((IFolder)current);
              if (binFolder.length == 0 || (binFolder.length == 1 && FilesUtils.isSVNFolder(binFolder[0]))) {
                try {
                  deleteResource(current);
                }
 catch (                PersistenceException e) {
                }
              }
            }
          }
        }
      }
      if (currentFolderItem != null) {
        List<Item> itemsDeleted=new ArrayList<Item>();
        for (        Item curItem : (List<Item>)currentFolderItem.getChildren()) {
          if (!(curItem instanceof FolderItem)) {
            String name;
            if (curItem.eResource() != null) {
              name=curItem.eResource().getURI().lastSegment();
            }
 else {
              name=curItem.getProperty().getLabel() + "String_Node_Str" + curItem.getProperty().getVersion()+ "String_Node_Str"+ FileConstants.PROPERTIES_EXTENSION;
            }
            if (!physicalPropertyFounds.contains(name)) {
              itemsDeleted.add(curItem);
            }
          }
 else           if (searchInChildren && ProxyRepositoryFactory.getInstance().isFullLogonFinished()) {
            if (!physicalDirectoryFounds.contains(curItem.getProperty().getLabel())) {
              itemsDeleted.add(curItem);
            }
          }
        }
        for (        Item item : itemsDeleted) {
          item.setParent(null);
          Iterator<IRepositoryViewObject> it=toReturn.iterator();
          while (it.hasNext()) {
            IRepositoryViewObject object=it.next();
            if (object.getLabel().equals(item.getProperty().getLabel()) && object.getId().equals(item.getProperty().getId()) && object.getVersion().equals(item.getProperty().getVersion())) {
              it.remove();
            }
          }
        }
        currentFolderItem.getChildren().removeAll(itemsDeleted);
      }
    }
  }
  return toReturn;
}