Program: 28536
Project: 28536
Buggy source:
/** 
 * Processing in this method is performed for each module that is in the process of being loaded by the container.  This method will collect information from each archive (module) and produce  <code>BeanDeploymentArchive</code> information for each module. The <code>BeanDeploymentArchive</code>s are stored in the <code>Deployment</code>  (that will eventually be handed off to <code>Weld</code>.  Once this method is called for all modules (and <code>BeanDeploymentArchive</code> information has been collected for all <code>Weld</code> modules), a relationship structure is produced defining the accessiblity rules for the <code>BeanDeploymentArchive</code>s. 
 */
@Override public WeldApplicationContainer load(WeldContainer container,DeploymentContext context){
  DeployCommandParameters deployParams=context.getCommandParameters(DeployCommandParameters.class);
  ApplicationInfo appInfo=applicationRegistry.get(deployParams.name);
  ReadableArchive archive=context.getSource();
  WeldBootstrap bootstrap=context.getTransientAppMetaData(WELD_BOOTSTRAP,WeldBootstrap.class);
  if (bootstrap == null) {
    bootstrap=new WeldBootstrap();
    Application app=context.getModuleMetaData(Application.class);
    appToBootstrap.put(app,bootstrap);
    context.addTransientAppMetaData(WELD_BOOTSTRAP,bootstrap);
    appInfo.addTransientAppMetaData(WELD_BOOTSTRAP,bootstrap);
    appInfo.addTransientAppMetaData(WELD_BOOTSTRAP_SHUTDOWN,"String_Node_Str");
  }
  EjbBundleDescriptor ejbBundle=getEjbBundleFromContext(context);
  EjbServices ejbServices=null;
  Set<EjbDescriptor> ejbs=new HashSet<EjbDescriptor>();
  if (ejbBundle != null) {
    ejbs.addAll(ejbBundle.getEjbs());
    ejbServices=new EjbServicesImpl(services);
  }
  DeploymentImpl deploymentImpl=context.getTransientAppMetaData(WELD_DEPLOYMENT,DeploymentImpl.class);
  if (deploymentImpl == null) {
    deploymentImpl=new DeploymentImpl(archive,ejbs,context,archiveFactory);
    TransactionServices transactionServices=new TransactionServicesImpl(services);
    deploymentImpl.getServices().add(TransactionServices.class,transactionServices);
    SecurityServices securityServices=new SecurityServicesImpl();
    deploymentImpl.getServices().add(SecurityServices.class,securityServices);
    ProxyServices proxyServices=new ProxyServicesImpl(services);
    deploymentImpl.getServices().add(ProxyServices.class,proxyServices);
    BootstrapConfigurationImpl bootstrapConfiguration=new BootstrapConfigurationImpl();
    deploymentImpl.getServices().add(BootstrapConfiguration.class,bootstrapConfiguration);
  }
 else {
    deploymentImpl.scanArchive(archive,ejbs,context);
  }
  deploymentImpl.addDeployedEjbs(ejbs);
  if (ejbBundle != null && (!deploymentImpl.getServices().contains(EjbServices.class))) {
    deploymentImpl.getServices().add(EjbServices.class,ejbServices);
  }
  BeanDeploymentArchive bda=deploymentImpl.getBeanDeploymentArchiveForArchive(archive.getName());
  WebBundleDescriptor wDesc=context.getModuleMetaData(WebBundleDescriptor.class);
  if (wDesc != null) {
    wDesc.setExtensionProperty(WELD_EXTENSION,"String_Node_Str");
    wDesc.addAppListenerDescriptorToFirst(new AppListenerDescriptorImpl(WELD_LISTENER));
    wDesc.addAppListenerDescriptor(new AppListenerDescriptorImpl(WELD_CONTEXT_LISTENER));
    for (    ServletFilterMapping sfMapping : wDesc.getServletFilterMappings()) {
      String displayName=((ServletFilterMappingDescriptor)sfMapping).getDisplayName();
      if (WELD_CONVERSATION_FILTER_NAME.equals(displayName)) {
        ServletFilterDescriptor ref=new ServletFilterDescriptor();
        ref.setClassName(WELD_CONVERSATION_FILTER_CLASS);
        ref.setName(WELD_CONVERSATION_FILTER_NAME);
        wDesc.addServletFilter(ref);
        break;
      }
    }
  }
  BundleDescriptor bundle=(wDesc != null) ? wDesc : ejbBundle;
  if (bundle != null) {
    InjectionManager injectionMgr=services.getService(InjectionManager.class);
    InjectionServices injectionServices=new InjectionServicesImpl(injectionMgr,bundle,deploymentImpl);
    if (logger.isLoggable(Level.FINE)) {
      logger.log(Level.FINE,CDILoggerInfo.ADDING_INJECTION_SERVICES,new Object[]{injectionServices,bda.getId()});
    }
    bda.getServices().add(InjectionServices.class,injectionServices);
    if (bda.getBeanDeploymentArchives().size() != 0) {
      for (      BeanDeploymentArchive subBda : bda.getBeanDeploymentArchives()) {
        if (logger.isLoggable(Level.FINE)) {
          logger.log(Level.FINE,CDILoggerInfo.ADDING_INJECTION_SERVICES,new Object[]{injectionServices,subBda.getId()});
        }
        subBda.getServices().add(InjectionServices.class,injectionServices);
      }
    }
    bundleToBeanDeploymentArchive.put(bundle,bda);
  }
  WeldApplicationContainer wbApp=new WeldApplicationContainer(bootstrap);
  context.addTransientAppMetaData(WELD_DEPLOYMENT,deploymentImpl);
  appInfo.addTransientAppMetaData(WELD_DEPLOYMENT,deploymentImpl);
  return wbApp;
}

Fixed version (ground truth):
/** 
 * Processing in this method is performed for each module that is in the process of being loaded by the container.  This method will collect information from each archive (module) and produce  <code>BeanDeploymentArchive</code> information for each module. The <code>BeanDeploymentArchive</code>s are stored in the <code>Deployment</code>  (that will eventually be handed off to <code>Weld</code>.  Once this method is called for all modules (and <code>BeanDeploymentArchive</code> information has been collected for all <code>Weld</code> modules), a relationship structure is produced defining the accessiblity rules for the <code>BeanDeploymentArchive</code>s. 
 */
@Override public WeldApplicationContainer load(WeldContainer container,DeploymentContext context){
  DeployCommandParameters deployParams=context.getCommandParameters(DeployCommandParameters.class);
  ApplicationInfo appInfo=applicationRegistry.get(deployParams.name);
  ReadableArchive archive=context.getSource();
  WeldBootstrap bootstrap=context.getTransientAppMetaData(WELD_BOOTSTRAP,WeldBootstrap.class);
  if (bootstrap == null) {
    bootstrap=new WeldBootstrap();
    Application app=context.getModuleMetaData(Application.class);
    appToBootstrap.put(app,bootstrap);
    context.addTransientAppMetaData(WELD_BOOTSTRAP,bootstrap);
    appInfo.addTransientAppMetaData(WELD_BOOTSTRAP,bootstrap);
    appInfo.addTransientAppMetaData(WELD_BOOTSTRAP_SHUTDOWN,"String_Node_Str");
  }
  EjbBundleDescriptor ejbBundle=getEjbBundleFromContext(context);
  EjbServices ejbServices=null;
  Set<EjbDescriptor> ejbs=new HashSet<EjbDescriptor>();
  if (ejbBundle != null) {
    ejbs.addAll(ejbBundle.getEjbs());
    ejbServices=new EjbServicesImpl(services);
  }
  DeploymentImpl deploymentImpl=context.getTransientAppMetaData(WELD_DEPLOYMENT,DeploymentImpl.class);
  if (deploymentImpl == null) {
    deploymentImpl=new DeploymentImpl(archive,ejbs,context,archiveFactory);
    TransactionServices transactionServices=new TransactionServicesImpl(services);
    deploymentImpl.getServices().add(TransactionServices.class,transactionServices);
    SecurityServices securityServices=new SecurityServicesImpl();
    deploymentImpl.getServices().add(SecurityServices.class,securityServices);
    ProxyServices proxyServices=new ProxyServicesImpl(services);
    deploymentImpl.getServices().add(ProxyServices.class,proxyServices);
    BootstrapConfigurationImpl bootstrapConfiguration=new BootstrapConfigurationImpl();
    deploymentImpl.getServices().add(BootstrapConfiguration.class,bootstrapConfiguration);
  }
 else {
    deploymentImpl.scanArchive(archive,ejbs,context);
  }
  deploymentImpl.addDeployedEjbs(ejbs);
  if (ejbBundle != null && (!deploymentImpl.getServices().contains(EjbServices.class))) {
    deploymentImpl.getServices().add(EjbServices.class,ejbServices);
  }
  BeanDeploymentArchive bda=deploymentImpl.getBeanDeploymentArchiveForArchive(archive.getName());
  WebBundleDescriptor wDesc=context.getModuleMetaData(WebBundleDescriptor.class);
  if (wDesc != null) {
    wDesc.setExtensionProperty(WELD_EXTENSION,"String_Node_Str");
    wDesc.addAppListenerDescriptorToFirst(new AppListenerDescriptorImpl(WELD_LISTENER));
    wDesc.addAppListenerDescriptor(new AppListenerDescriptorImpl(WELD_CONTEXT_LISTENER));
    for (    ServletFilterMapping sfMapping : wDesc.getServletFilterMappings()) {
      String displayName=((ServletFilterMappingDescriptor)sfMapping).getDisplayName();
      if (WELD_CONVERSATION_FILTER_NAME.equals(displayName)) {
        ServletFilterDescriptor ref=new ServletFilterDescriptor();
        ref.setClassName(WELD_CONVERSATION_FILTER_CLASS);
        ref.setName(WELD_CONVERSATION_FILTER_NAME);
        wDesc.addServletFilter(ref);
        break;
      }
    }
  }
  BundleDescriptor bundle=(wDesc != null) ? wDesc : ejbBundle;
  if (bundle != null) {
    InjectionManager injectionMgr=services.getService(InjectionManager.class);
    InjectionServices injectionServices=new InjectionServicesImpl(injectionMgr,bundle,deploymentImpl);
    if (logger.isLoggable(Level.FINE)) {
      logger.log(Level.FINE,CDILoggerInfo.ADDING_INJECTION_SERVICES,new Object[]{injectionServices,bda.getId()});
    }
    bda.getServices().add(InjectionServices.class,injectionServices);
    if (bda.getBeanDeploymentArchives().size() != 0) {
      for (      BeanDeploymentArchive subBda : bda.getBeanDeploymentArchives()) {
        if (logger.isLoggable(Level.FINE)) {
          logger.log(Level.FINE,CDILoggerInfo.ADDING_INJECTION_SERVICES,new Object[]{injectionServices,subBda.getId()});
        }
        subBda.getServices().add(InjectionServices.class,injectionServices);
      }
    }
    bundleToBeanDeploymentArchive.put(bundle,bda);
  }
  WeldApplicationContainer wbApp=new WeldApplicationContainer();
  context.addTransientAppMetaData(WELD_DEPLOYMENT,deploymentImpl);
  appInfo.addTransientAppMetaData(WELD_DEPLOYMENT,deploymentImpl);
  return wbApp;
}