Program: 127261
Project: 127261
Buggy source:
private boolean deleteElements(IProxyRepositoryFactory factory,DeleteActionCache deleteActionCache,final RepositoryNode currentJobNode,Boolean confirm) throws PersistenceException, BusinessException {
  boolean needReturn=false;
  final boolean[] enableDeleting=new boolean[1];
  enableDeleting[0]=true;
  final IRepositoryViewObject objToDelete=currentJobNode.getObject();
  final List<ContextReferenceBean> checkContext=checkContextFromProcess(factory,deleteActionCache,currentJobNode);
  if (checkContext.size() > 0) {
    Display.getDefault().syncExec(new Runnable(){
      @Override public void run(){
        ContextReferenceDialog dialog=new ContextReferenceDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),objToDelete,checkContext);
        int returnCode=dialog.open();
switch (returnCode) {
case Window.OK:
          enableDeleting[0]=true;
        break;
case Window.CANCEL:
      enableDeleting[0]=false;
    break;
}
}
}
);
}
if (!enableDeleting[0]) {
return true;
}
AbstractResourceChangesService resChangeService=TDQServiceRegister.getInstance().getResourceChangeService(AbstractResourceChangesService.class);
ERepositoryObjectType nodeType=(ERepositoryObjectType)currentJobNode.getProperties(EProperties.CONTENT_TYPE);
if (nodeType != null && nodeType.isSubItem()) {
Display.getDefault().syncExec(new Runnable(){
@Override public void run(){
final DeleteTableAction deleteTableAction=new DeleteTableAction();
deleteTableAction.setWorkbenchPart(getWorkbenchPart());
deleteTableAction.run();
}
}
);
needReturn=true;
}
 else {
if (factory.getStatus(objToDelete) == ERepositoryStatus.DELETED) {
if (!confirmFromDialog && resChangeService != null) {
List<IRepositoryNode> dependentNodes=resChangeService.getDependentNodes(currentJobNode);
if (dependentNodes != null && !dependentNodes.isEmpty()) {
  resChangeService.openDependcesDialog(dependentNodes);
  return true;
}
}
if (confirm == null) {
if (confirmFromDialog) {
  confirm=confirmFromDialog;
}
 else {
  Display.getDefault().syncExec(new Runnable(){
    @Override public void run(){
      String title=Messages.getString("String_Node_Str");
      String message=currentJobNode.getProperties(EProperties.LABEL) + "String_Node_Str" + Messages.getString("String_Node_Str")+ "String_Node_Str"+ Messages.getString("String_Node_Str");
      confirmFromDialog=MessageDialog.openQuestion(new Shell(),title,message);
    }
  }
);
  confirm=confirmFromDialog;
}
}
if (confirm) {
deleteActionCache.closeOpenedEditor(objToDelete);
if (currentJobNode.getType() == ENodeType.SIMPLE_FOLDER) {
  boolean success=true;
  for (  IRepositoryNode curNode : currentJobNode.getChildren()) {
    try {
      deleteElements(factory,deleteActionCache,(RepositoryNode)curNode,confirm);
    }
 catch (    Exception e) {
      ExceptionHandler.process(e);
      success=false;
    }
  }
  if (success) {
    if (currentJobNode.getObject() != null && currentJobNode.getObject().getProperty() != null && currentJobNode.getObject().getProperty().getItem() != null) {
      Item fitem=currentJobNode.getObject().getProperty().getItem();
      if ((fitem instanceof FolderItem) && (((FolderItem)fitem).getType().getValue() == FolderType.FOLDER)) {
        factory.deleteFolder(currentJobNode.getContentType(),RepositoryNodeUtilities.getFolderPath(currentJobNode.getObject().getProperty().getItem()));
      }
 else {
        factory.deleteFolder(currentJobNode.getContentType(),RepositoryNodeUtilities.getPath(currentJobNode));
      }
    }
 else {
      factory.deleteFolder(currentJobNode.getContentType(),RepositoryNodeUtilities.getPath(currentJobNode));
    }
  }
}
 else {
  if (resChangeService != null && objToDelete != null && objToDelete.getProperty() != null) {
    Item item=objToDelete.getProperty().getItem();
    if (item != null) {
      resChangeService.removeAllDependecies(item);
    }
  }
  for (  IRepositoryContentHandler handler : RepositoryContentManager.getHandlers()) {
    handler.deleteNode(objToDelete);
  }
  factory.deleteObjectPhysical(objToDelete);
  ExpressionPersistance.getInstance().jobDeleted(objToDelete.getLabel());
}
}
}
 else {
factory.deleteObjectLogical(objToDelete);
updateRelatedViews();
removeConnFromSQLExplorer(currentJobNode);
}
}
return needReturn;
}

Fixed version (ground truth):
private boolean deleteElements(IProxyRepositoryFactory factory,DeleteActionCache deleteActionCache,final RepositoryNode currentJobNode,Boolean confirm) throws PersistenceException, BusinessException {
  boolean needReturn=false;
  final boolean[] enableDeleting=new boolean[1];
  enableDeleting[0]=true;
  final IRepositoryViewObject objToDelete=currentJobNode.getObject();
  final List<ContextReferenceBean> checkContext=checkContextFromProcess(factory,deleteActionCache,currentJobNode);
  if (checkContext.size() > 0) {
    Display.getDefault().syncExec(new Runnable(){
      @Override public void run(){
        ContextReferenceDialog dialog=new ContextReferenceDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),objToDelete,checkContext);
        int returnCode=dialog.open();
switch (returnCode) {
case Window.OK:
          enableDeleting[0]=true;
        break;
case Window.CANCEL:
      enableDeleting[0]=false;
    break;
}
}
}
);
}
if (!enableDeleting[0]) {
return true;
}
AbstractResourceChangesService resChangeService=TDQServiceRegister.getInstance().getResourceChangeService(AbstractResourceChangesService.class);
ERepositoryObjectType nodeType=(ERepositoryObjectType)currentJobNode.getProperties(EProperties.CONTENT_TYPE);
if (nodeType != null && nodeType.isSubItem()) {
Display.getDefault().syncExec(new Runnable(){
@Override public void run(){
final DeleteTableAction deleteTableAction=new DeleteTableAction();
deleteTableAction.setWorkbenchPart(getWorkbenchPart());
deleteTableAction.run();
}
}
);
needReturn=true;
}
 else {
if (factory.getStatus(objToDelete) == ERepositoryStatus.DELETED) {
if (!confirmFromDialog && resChangeService != null) {
List<IRepositoryNode> dependentNodes=resChangeService.getDependentNodes(currentJobNode);
if (dependentNodes != null && !dependentNodes.isEmpty()) {
  resChangeService.openDependcesDialog(dependentNodes);
  return true;
}
}
if (confirm == null) {
if (confirmFromDialog) {
  confirm=confirmFromDialog;
}
 else {
  Display.getDefault().syncExec(new Runnable(){
    @Override public void run(){
      String title=Messages.getString("String_Node_Str");
      String message=currentJobNode.getProperties(EProperties.LABEL) + "String_Node_Str" + Messages.getString("String_Node_Str")+ "String_Node_Str"+ Messages.getString("String_Node_Str");
      confirmFromDialog=MessageDialog.openQuestion(new Shell(),title,message);
    }
  }
);
  confirm=confirmFromDialog;
}
}
if (confirm) {
deleteActionCache.closeOpenedEditor(objToDelete);
if (currentJobNode.getType() == ENodeType.SIMPLE_FOLDER) {
  boolean success=true;
  for (  IRepositoryNode curNode : currentJobNode.getChildren()) {
    try {
      deleteElements(factory,deleteActionCache,(RepositoryNode)curNode,confirm);
    }
 catch (    Exception e) {
      ExceptionHandler.process(e);
      success=false;
    }
  }
  if (success) {
    if (currentJobNode.getObject() != null && currentJobNode.getObject().getProperty() != null && currentJobNode.getObject().getProperty().getItem() != null) {
      Item fitem=currentJobNode.getObject().getProperty().getItem();
      if ((fitem instanceof FolderItem) && (((FolderItem)fitem).getType().getValue() == FolderType.FOLDER)) {
        factory.deleteFolder(currentJobNode.getContentType(),RepositoryNodeUtilities.getFolderPath(currentJobNode.getObject().getProperty().getItem()));
      }
 else {
        factory.deleteFolder(currentJobNode.getContentType(),RepositoryNodeUtilities.getPath(currentJobNode));
      }
    }
 else {
      factory.deleteFolder(currentJobNode.getContentType(),RepositoryNodeUtilities.getPath(currentJobNode));
    }
  }
}
 else {
  if (resChangeService != null && objToDelete != null && objToDelete.getProperty() != null) {
    Item item=objToDelete.getProperty().getItem();
    if (item != null) {
      resChangeService.removeAllDependecies(item);
    }
  }
  for (  IRepositoryContentHandler handler : RepositoryContentManager.getHandlers()) {
    handler.deleteNode(objToDelete);
  }
  if (nodeType == ERepositoryObjectType.ROUTINES || nodeType == ERepositoryObjectType.PIG_UDF) {
    forceBuild=true;
  }
  factory.deleteObjectPhysical(objToDelete);
  ExpressionPersistance.getInstance().jobDeleted(objToDelete.getLabel());
}
}
}
 else {
factory.deleteObjectLogical(objToDelete);
updateRelatedViews();
removeConnFromSQLExplorer(currentJobNode);
}
}
return needReturn;
}