Program: 28139
Project: 28139
Buggy source:
@Override public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass){
  if (logger.isLoggable(FINE)) {
    logger.log(FINE,CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE,new Object[]{beanClass});
  }
  List<BeanDeploymentArchive> beanDeploymentArchives=getBeanDeploymentArchives();
  ListIterator<BeanDeploymentArchive> lIter=beanDeploymentArchives.listIterator();
  while (lIter.hasNext()) {
    BeanDeploymentArchive bda=lIter.next();
    if (logger.isLoggable(FINE)) {
      logger.log(FINE,CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_CHECKING,new Object[]{beanClass,bda.getId()});
    }
    if (((BeanDeploymentArchiveImpl)bda).getModuleBeanClasses().contains(beanClass.getName())) {
      if (logger.isLoggable(FINE)) {
        logger.log(FINE,CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_ADD_TO_EXISTING,new Object[]{beanClass.getName(),bda});
      }
      return bda;
    }
    if (bda.getBeanDeploymentArchives().size() > 0) {
      for (      BeanDeploymentArchive subBda : bda.getBeanDeploymentArchives()) {
        Collection<String> moduleBeanClassNames=((BeanDeploymentArchiveImpl)subBda).getModuleBeanClasses();
        if (logger.isLoggable(FINE)) {
          logger.log(FINE,CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_CHECKING_SUBBDA,new Object[]{beanClass,subBda.getId()});
        }
        boolean match=moduleBeanClassNames.contains(beanClass.getName());
        if (match) {
          if (logger.isLoggable(FINE)) {
            logger.log(FINE,CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_ADD_TO_EXISTING,new Object[]{beanClass.getName(),subBda});
          }
          return subBda;
        }
      }
    }
  }
  BeanDeploymentArchive extensionBDA=extensionBDAMap.get(beanClass.getClassLoader());
  if (extensionBDA != null) {
    return extensionBDA;
  }
  if (logger.isLoggable(FINE)) {
    logger.log(FINE,CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_CREATE_NEW_BDA,new Object[]{beanClass});
  }
  List<Class<?>> beanClasses=new ArrayList<Class<?>>();
  List<URL> beanXMLUrls=new CopyOnWriteArrayList<URL>();
  Set<EjbDescriptor> ejbs=new HashSet<EjbDescriptor>();
  beanClasses.add(beanClass);
  BeanDeploymentArchive newBda=new BeanDeploymentArchiveImpl(beanClass.getName(),beanClasses,beanXMLUrls,ejbs,context);
  BeansXml beansXml=newBda.getBeansXml();
  if (beansXml == null || !beansXml.getBeanDiscoveryMode().equals(BeanDiscoveryMode.NONE)) {
    if (logger.isLoggable(FINE)) {
      logger.log(FINE,CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_ADD_NEW_BDA_TO_ROOTS,new Object[]{});
    }
    lIter=beanDeploymentArchives.listIterator();
    while (lIter.hasNext()) {
      BeanDeploymentArchive bda=lIter.next();
      bda.getBeanDeploymentArchives().add(newBda);
    }
    if (logger.isLoggable(FINE)) {
      logger.log(FINE,CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_RETURNING_NEWLY_CREATED_BDA,new Object[]{beanClass,newBda});
    }
    beanDeploymentArchives.add(newBda);
    idToBeanDeploymentArchive.put(newBda.getId(),newBda);
    extensionBDAMap.put(beanClass.getClassLoader(),newBda);
    return newBda;
  }
  return null;
}

Fixed version (ground truth):
@Override public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass){
  if (logger.isLoggable(FINE)) {
    logger.log(FINE,CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE,new Object[]{beanClass});
  }
  List<BeanDeploymentArchive> beanDeploymentArchives=getBeanDeploymentArchives();
  ListIterator<BeanDeploymentArchive> lIter=beanDeploymentArchives.listIterator();
  while (lIter.hasNext()) {
    BeanDeploymentArchive bda=lIter.next();
    if (logger.isLoggable(FINE)) {
      logger.log(FINE,CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_CHECKING,new Object[]{beanClass,bda.getId()});
    }
    if (((BeanDeploymentArchiveImpl)bda).getModuleBeanClasses().contains(beanClass.getName())) {
      if (logger.isLoggable(FINE)) {
        logger.log(FINE,CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_ADD_TO_EXISTING,new Object[]{beanClass.getName(),bda});
      }
      return bda;
    }
    if (bda.getBeanDeploymentArchives().size() > 0) {
      for (      BeanDeploymentArchive subBda : bda.getBeanDeploymentArchives()) {
        Collection<String> moduleBeanClassNames=((BeanDeploymentArchiveImpl)subBda).getModuleBeanClasses();
        if (logger.isLoggable(FINE)) {
          logger.log(FINE,CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_CHECKING_SUBBDA,new Object[]{beanClass,subBda.getId()});
        }
        boolean match=moduleBeanClassNames.contains(beanClass.getName());
        if (match) {
          if (logger.isLoggable(FINE)) {
            logger.log(FINE,CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_ADD_TO_EXISTING,new Object[]{beanClass.getName(),subBda});
          }
          return subBda;
        }
      }
    }
  }
  BeanDeploymentArchive extensionBDA=extensionBDAMap.get(beanClass.getClassLoader());
  if (extensionBDA != null) {
    return extensionBDA;
  }
  if (logger.isLoggable(FINE)) {
    logger.log(FINE,CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_CREATE_NEW_BDA,new Object[]{beanClass});
  }
  List<Class<?>> beanClasses=new ArrayList<>();
  List<URL> beanXMLUrls=new CopyOnWriteArrayList<>();
  Set<EjbDescriptor> ejbs=new HashSet<>();
  beanClasses.add(beanClass);
  BeanDeploymentArchive newBda=new BeanDeploymentArchiveImpl(beanClass.getName(),beanClasses,beanXMLUrls,ejbs,context);
  InjectionServices injectionServices=this.getServices().get(InjectionServices.class);
  newBda.getServices().add(InjectionServices.class,injectionServices);
  BeansXml beansXml=newBda.getBeansXml();
  if (beansXml == null || !beansXml.getBeanDiscoveryMode().equals(BeanDiscoveryMode.NONE)) {
    if (logger.isLoggable(FINE)) {
      logger.log(FINE,CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_ADD_NEW_BDA_TO_ROOTS,new Object[]{});
    }
    lIter=beanDeploymentArchives.listIterator();
    while (lIter.hasNext()) {
      BeanDeploymentArchive bda=lIter.next();
      bda.getBeanDeploymentArchives().add(newBda);
    }
    if (logger.isLoggable(FINE)) {
      logger.log(FINE,CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_RETURNING_NEWLY_CREATED_BDA,new Object[]{beanClass,newBda});
    }
    beanDeploymentArchives.add(newBda);
    idToBeanDeploymentArchive.put(newBda.getId(),newBda);
    extensionBDAMap.put(beanClass.getClassLoader(),newBda);
    return newBda;
  }
  return null;
}