Program: 29556
Project: 29556
Buggy source:
/** 
 * Method to read complete application and all defined descriptor for given app. Method is used to identify scope and validation for all defined jndi names at different namespace.
 * @param application
 * @return
 */
public boolean validateResourceDescriptor(Application application){
  CommonResourceBundleDescriptor commonResourceBundleDescriptor=(CommonResourceBundleDescriptor)application;
  Vector appLevel=new Vector();
  if (commonResourceBundleDescriptor != null) {
    appLevel.add(commonResourceBundleDescriptor.getName());
    Set<MailSessionDescriptor> mailSessionDescriptors=commonResourceBundleDescriptor.getMailSessionDescriptors();
    if (isExistingMailSession(mailSessionDescriptors,commonResourceBundleDescriptor.getName())) {
      return false;
    }
    Set<DataSourceDefinitionDescriptor> dataSourceDefinitionDescriptors=commonResourceBundleDescriptor.getDataSourceDefinitionDescriptors();
    if (isExistingDataSourceDefinition(dataSourceDefinitionDescriptors,commonResourceBundleDescriptor.getName())) {
      return false;
    }
    validNameSpaceDetails.put(APP_KEYS,appLevel);
  }
  Set<ApplicationClientDescriptor> appClientDescs=application.getBundleDescriptors(ApplicationClientDescriptor.class);
  Vector appClientLevel=new Vector();
  for (  ApplicationClientDescriptor acd : appClientDescs) {
    appClientLevel.add(acd.getName());
    Set<MailSessionDescriptor> mailSessionDescriptors=acd.getMailSessionDescriptors();
    if (isExistingMailSession(mailSessionDescriptors,acd.getName())) {
      return false;
    }
    Set<DataSourceDefinitionDescriptor> dataSourceDefinitionDescriptors=acd.getDataSourceDefinitionDescriptors();
    if (isExistingDataSourceDefinition(dataSourceDefinitionDescriptors,acd.getName())) {
      return false;
    }
  }
  validNameSpaceDetails.put(APPCLIENT_KEYS,appClientLevel);
  Set<ConnectorDescriptor> connectorDescs=application.getBundleDescriptors(ConnectorDescriptor.class);
  Vector cdLevel=new Vector();
  for (  ConnectorDescriptor cd : connectorDescs) {
    cdLevel.add(cd.getName());
    Set<MailSessionDescriptor> mailSessionDescriptors=cd.getMailSessionDescriptors();
    if (isExistingMailSession(mailSessionDescriptors,cd.getName())) {
      return false;
    }
    Set<DataSourceDefinitionDescriptor> dataSourceDefinitionDescriptors=cd.getDataSourceDefinitionDescriptors();
    if (isExistingDataSourceDefinition(dataSourceDefinitionDescriptors,cd.getName())) {
      return false;
    }
  }
  validNameSpaceDetails.put(CONNECTOR_KEYS,cdLevel);
  Set<EjbBundleDescriptor> ejbBundleDescs=application.getBundleDescriptors(EjbBundleDescriptor.class);
  Vector ebdLevel=new Vector();
  Vector edLevel=new Vector();
  for (  EjbBundleDescriptor ebd : ejbBundleDescs) {
    ebdLevel.add(ebd.getName());
    Set<MailSessionDescriptor> mailSessionDescriptors=ebd.getMailSessionDescriptors();
    if (isExistingMailSession(mailSessionDescriptors,ebd.getName())) {
      return false;
    }
    Set<DataSourceDefinitionDescriptor> dataSourceDefinitionDescriptors=ebd.getDataSourceDefinitionDescriptors();
    if (isExistingDataSourceDefinition(dataSourceDefinitionDescriptors,ebd.getName())) {
      return false;
    }
    Set<EjbDescriptor> ejbDescriptors=(Set<EjbDescriptor>)ebd.getEjbs();
    for (Iterator itr=ejbDescriptors.iterator(); itr.hasNext(); ) {
      EjbDescriptor ejbDescriptor=(EjbDescriptor)itr.next();
      edLevel.add(ebd.getName() + "String_Node_Str" + ejbDescriptor.getName());
      mailSessionDescriptors=ejbDescriptor.getMailSessionDescriptors();
      if (isExistingMailSession(mailSessionDescriptors,ebd.getName() + "String_Node_Str" + ejbDescriptor.getName())) {
        return false;
      }
      dataSourceDefinitionDescriptors=ejbDescriptor.getDataSourceDefinitionDescriptors();
      if (isExistingDataSourceDefinition(dataSourceDefinitionDescriptors,ebd.getName() + "String_Node_Str" + ejbDescriptor.getName())) {
        return false;
      }
    }
  }
  validNameSpaceDetails.put(EJBBUNDLE_KEYS,ebdLevel);
  validNameSpaceDetails.put(EJB_KEYS,edLevel);
  Set<WebBundleDescriptor> webBundleDescs=application.getBundleDescriptors(WebBundleDescriptor.class);
  Vector wbdLevel=new Vector();
  for (  WebBundleDescriptor wbd : webBundleDescs) {
    wbdLevel.add(wbd.getName());
    Set<MailSessionDescriptor> mailSessionDescriptors=wbd.getMailSessionDescriptors();
    if (isExistingMailSession(mailSessionDescriptors,wbd.getName())) {
      return false;
    }
    Set<DataSourceDefinitionDescriptor> dataSourceDefinitionDescriptors=wbd.getDataSourceDefinitionDescriptors();
    if (isExistingDataSourceDefinition(dataSourceDefinitionDescriptors,wbd.getName())) {
      return false;
    }
  }
  validNameSpaceDetails.put(WEBBUNDLE_KEYS,wbdLevel);
  if (allUniqueResource) {
    return compareDescriptors();
  }
  return allUniqueResource;
}

Fixed version (ground truth):
/** 
 * Method to read complete application and all defined descriptor for given app. Method is used to identify scope and validation for all defined jndi names at different namespace.
 * @param application
 * @return
 */
public boolean validateResourceDescriptor(Application application){
  CommonResourceBundleDescriptor commonResourceBundleDescriptor=(CommonResourceBundleDescriptor)application;
  Vector appLevel=new Vector();
  if (commonResourceBundleDescriptor != null) {
    Set<MailSessionDescriptor> mailSessionDescriptors=commonResourceBundleDescriptor.getMailSessionDescriptors();
    if (isExistingMailSession(mailSessionDescriptors,commonResourceBundleDescriptor.getName())) {
      return false;
    }
    Set<DataSourceDefinitionDescriptor> dataSourceDefinitionDescriptors=commonResourceBundleDescriptor.getDataSourceDefinitionDescriptors();
    if (isExistingDataSourceDefinition(dataSourceDefinitionDescriptors,commonResourceBundleDescriptor.getName())) {
      return false;
    }
    if (mailSessionDescriptors.size() > 0 || dataSourceDefinitionDescriptors.size() > 0) {
      appLevel.add(commonResourceBundleDescriptor.getName());
    }
    validNameSpaceDetails.put(APP_KEYS,appLevel);
  }
  Set<ApplicationClientDescriptor> appClientDescs=application.getBundleDescriptors(ApplicationClientDescriptor.class);
  Vector appClientLevel=new Vector();
  for (  ApplicationClientDescriptor acd : appClientDescs) {
    Set<MailSessionDescriptor> mailSessionDescriptors=acd.getMailSessionDescriptors();
    if (isExistingMailSession(mailSessionDescriptors,acd.getName())) {
      return false;
    }
    Set<DataSourceDefinitionDescriptor> dataSourceDefinitionDescriptors=acd.getDataSourceDefinitionDescriptors();
    if (isExistingDataSourceDefinition(dataSourceDefinitionDescriptors,acd.getName())) {
      return false;
    }
    if (mailSessionDescriptors.size() > 0 || dataSourceDefinitionDescriptors.size() > 0) {
      appClientLevel.add(acd.getName());
    }
  }
  validNameSpaceDetails.put(APPCLIENT_KEYS,appClientLevel);
  Set<ConnectorDescriptor> connectorDescs=application.getBundleDescriptors(ConnectorDescriptor.class);
  Vector cdLevel=new Vector();
  for (  ConnectorDescriptor cd : connectorDescs) {
    Set<MailSessionDescriptor> mailSessionDescriptors=cd.getMailSessionDescriptors();
    if (isExistingMailSession(mailSessionDescriptors,cd.getName())) {
      return false;
    }
    Set<DataSourceDefinitionDescriptor> dataSourceDefinitionDescriptors=cd.getDataSourceDefinitionDescriptors();
    if (isExistingDataSourceDefinition(dataSourceDefinitionDescriptors,cd.getName())) {
      return false;
    }
    if (mailSessionDescriptors.size() > 0 || dataSourceDefinitionDescriptors.size() > 0) {
      cdLevel.add(cd.getName());
    }
  }
  validNameSpaceDetails.put(CONNECTOR_KEYS,cdLevel);
  Set<EjbBundleDescriptor> ejbBundleDescs=application.getBundleDescriptors(EjbBundleDescriptor.class);
  Vector ebdLevel=new Vector();
  Vector edLevel=new Vector();
  for (  EjbBundleDescriptor ebd : ejbBundleDescs) {
    Set<MailSessionDescriptor> mailSessionDescriptors=ebd.getMailSessionDescriptors();
    if (isExistingMailSession(mailSessionDescriptors,ebd.getName())) {
      return false;
    }
    Set<DataSourceDefinitionDescriptor> dataSourceDefinitionDescriptors=ebd.getDataSourceDefinitionDescriptors();
    if (isExistingDataSourceDefinition(dataSourceDefinitionDescriptors,ebd.getName())) {
      return false;
    }
    if (mailSessionDescriptors.size() > 0 || dataSourceDefinitionDescriptors.size() > 0) {
      ebdLevel.add(ebd.getName());
    }
    Set<EjbDescriptor> ejbDescriptors=(Set<EjbDescriptor>)ebd.getEjbs();
    for (Iterator itr=ejbDescriptors.iterator(); itr.hasNext(); ) {
      EjbDescriptor ejbDescriptor=(EjbDescriptor)itr.next();
      mailSessionDescriptors=ejbDescriptor.getMailSessionDescriptors();
      if (isExistingMailSession(mailSessionDescriptors,ebd.getName() + "String_Node_Str" + ejbDescriptor.getName())) {
        return false;
      }
      dataSourceDefinitionDescriptors=ejbDescriptor.getDataSourceDefinitionDescriptors();
      if (isExistingDataSourceDefinition(dataSourceDefinitionDescriptors,ebd.getName() + "String_Node_Str" + ejbDescriptor.getName())) {
        return false;
      }
      if (mailSessionDescriptors.size() > 0 || dataSourceDefinitionDescriptors.size() > 0) {
        edLevel.add(ebd.getName() + "String_Node_Str" + ejbDescriptor.getName());
      }
    }
  }
  validNameSpaceDetails.put(EJBBUNDLE_KEYS,ebdLevel);
  validNameSpaceDetails.put(EJB_KEYS,edLevel);
  Set<WebBundleDescriptor> webBundleDescs=application.getBundleDescriptors(WebBundleDescriptor.class);
  Vector wbdLevel=new Vector();
  for (  WebBundleDescriptor wbd : webBundleDescs) {
    Set<MailSessionDescriptor> mailSessionDescriptors=wbd.getMailSessionDescriptors();
    if (isExistingMailSession(mailSessionDescriptors,wbd.getName())) {
      return false;
    }
    Set<DataSourceDefinitionDescriptor> dataSourceDefinitionDescriptors=wbd.getDataSourceDefinitionDescriptors();
    if (isExistingDataSourceDefinition(dataSourceDefinitionDescriptors,wbd.getName())) {
      return false;
    }
    if (mailSessionDescriptors.size() > 0 || dataSourceDefinitionDescriptors.size() > 0) {
      wbdLevel.add(wbd.getName());
    }
  }
  validNameSpaceDetails.put(WEBBUNDLE_KEYS,wbdLevel);
  if (allUniqueResource) {
    return compareDescriptors();
  }
  return allUniqueResource;
}