Program: 95874
Project: 95874
Buggy source:
/** 
 * delete a project
 * @param proj project to delete
 * @param isActProject flag to label the actual project
 * @throws PMAlreadyLockedException if project is already locked in db
 * @throws PMDirtyVersionException if project to delete is modified in the meantime
 * @throws JBException if a session cannot closed
 * @throws PMExtProjDeletedException if a project (but not the current) was deleted by another user
 * @throws ProjectDeletedException if the current project was deleted by another user
 * @throws InterruptedException if the operation was canceled
 */
public static void deleteProject(IProjectPO proj,boolean isActProject) throws PMDirtyVersionException, PMAlreadyLockedException, PMExtProjDeletedException, ProjectDeletedException, JBException, InterruptedException {
  Validate.notNull(proj,"String_Node_Str");
  EntityManager deleteSess=null;
  IProjectPO p=null;
  final Long projId=proj.getId();
  try {
    if (isActProject) {
      EntityManager s=GeneralStorage.getInstance().getMasterSession();
      IProjectPO currProj=s.find(NodeMaker.getProjectPOClass(),projId,LockModeType.READ);
      if (currProj == null) {
        throw new ProjectDeletedException(Messages.ProjectWasDeleted,MessageIDs.E_CURRENT_PROJ_DEL);
      }
    }
  }
 catch (  PersistenceException e) {
    handleDBExceptionForMasterSession(proj,e);
  }
  try {
    deleteSess=Persistor.instance().openSession();
    EntityTransaction tx=Persistor.instance().getTransaction(deleteSess);
    p=deleteSess.find(NodeMaker.getProjectPOClass(),projId);
    if (p == null) {
      if (isActProject) {
        throw new ProjectDeletedException("String_Node_Str",MessageIDs.E_CURRENT_PROJ_DEL);
      }
      throw new PMExtProjDeletedException(Messages.ProjectWasDeleted + StringConstants.DOT,MessageIDs.E_DELETED_OBJECT);
    }
    Persistor.instance().lockPO(deleteSess,p);
    deleteProjectIndependentDBObjects(deleteSess,p);
    List<ISpecPersistable> specObjList=new ArrayList<ISpecPersistable>(p.getSpecObjCont().getSpecObjList());
    List<IExecPersistable> execObjList=new ArrayList<IExecPersistable>(p.getExecObjCont().getExecObjList());
    for (    ISpecPersistable po : specObjList) {
      PersistenceUtil.removeChildNodes(po,deleteSess);
      p.getSpecObjCont().removeSpecObject(po);
      Persistor.instance().deletePO(deleteSess,po);
    }
    for (    IExecPersistable po : execObjList) {
      PersistenceUtil.removeChildNodes(po,deleteSess);
      p.getExecObjCont().removeExecObject(po);
      Persistor.instance().deletePO(deleteSess,po);
    }
    deleteSess.flush();
    Persistor.instance().deletePO(deleteSess,p);
    CompNamePM.deleteCompNames(deleteSess,projId);
    Persistor.instance().commitTransaction(deleteSess,tx);
    tx=null;
  }
 catch (  PersistenceException e) {
    handleDBExceptionForAnySession(p,e,deleteSess);
  }
 finally {
    Persistor.instance().dropSession(deleteSess);
  }
  ProjectNameBP.getInstance().checkAndDeleteName(proj.getGuid());
}

Fixed version (ground truth):
/** 
 * delete a project
 * @param proj project to delete
 * @param isActProject flag to label the actual project
 * @throws PMAlreadyLockedException if project is already locked in db
 * @throws PMDirtyVersionException if project to delete is modified in the meantime
 * @throws JBException if a session cannot closed
 * @throws PMExtProjDeletedException if a project (but not the current) was deleted by another user
 * @throws ProjectDeletedException if the current project was deleted by another user
 * @throws InterruptedException if the operation was canceled
 */
public static void deleteProject(IProjectPO proj,boolean isActProject) throws PMDirtyVersionException, PMAlreadyLockedException, PMExtProjDeletedException, ProjectDeletedException, JBException, InterruptedException {
  Validate.notNull(proj,"String_Node_Str");
  EntityManager deleteSess=null;
  IProjectPO p=null;
  final Long projId=proj.getId();
  try {
    if (isActProject) {
      EntityManager s=GeneralStorage.getInstance().getMasterSession();
      IProjectPO currProj=s.find(NodeMaker.getProjectPOClass(),projId);
      if (currProj == null) {
        throw new ProjectDeletedException(Messages.ProjectWasDeleted,MessageIDs.E_CURRENT_PROJ_DEL);
      }
    }
  }
 catch (  PersistenceException e) {
    handleDBExceptionForMasterSession(proj,e);
  }
  try {
    deleteSess=Persistor.instance().openSession();
    EntityTransaction tx=Persistor.instance().getTransaction(deleteSess);
    p=deleteSess.find(NodeMaker.getProjectPOClass(),projId);
    if (p == null) {
      if (isActProject) {
        throw new ProjectDeletedException("String_Node_Str",MessageIDs.E_CURRENT_PROJ_DEL);
      }
      throw new PMExtProjDeletedException(Messages.ProjectWasDeleted + StringConstants.DOT,MessageIDs.E_DELETED_OBJECT);
    }
    Persistor.instance().lockPO(deleteSess,p);
    deleteProjectIndependentDBObjects(deleteSess,p);
    List<ISpecPersistable> specObjList=new ArrayList<ISpecPersistable>(p.getSpecObjCont().getSpecObjList());
    List<IExecPersistable> execObjList=new ArrayList<IExecPersistable>(p.getExecObjCont().getExecObjList());
    for (    ISpecPersistable po : specObjList) {
      PersistenceUtil.removeChildNodes(po,deleteSess);
      p.getSpecObjCont().removeSpecObject(po);
      Persistor.instance().deletePO(deleteSess,po);
    }
    for (    IExecPersistable po : execObjList) {
      PersistenceUtil.removeChildNodes(po,deleteSess);
      p.getExecObjCont().removeExecObject(po);
      Persistor.instance().deletePO(deleteSess,po);
    }
    deleteSess.flush();
    Persistor.instance().deletePO(deleteSess,p);
    CompNamePM.deleteCompNames(deleteSess,projId);
    Persistor.instance().commitTransaction(deleteSess,tx);
    tx=null;
  }
 catch (  PersistenceException e) {
    handleDBExceptionForAnySession(p,e,deleteSess);
  }
 finally {
    Persistor.instance().dropSession(deleteSess);
  }
  ProjectNameBP.getInstance().checkAndDeleteName(proj.getGuid());
}