Program: 28140
Project: 28140
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);
  }
  boolean isSubArchive=archive.getParentArchive() != null;
  String archiveName=!isSubArchive ? appInfo.getName() : archive.getName();
  if (isSubArchive) {
    archiveName=BeanDeploymentArchiveImpl.stripMavenVersion(archiveName);
  }
  if (!context.getArchiveHandler().getArchiveType().isEmpty()) {
    archiveName=String.format("String_Node_Str",archiveName,context.getArchiveHandler().getArchiveType());
  }
  DeploymentImpl deploymentImpl=context.getTransientAppMetaData(WELD_DEPLOYMENT,DeploymentImpl.class);
  if (deploymentImpl == null) {
    deploymentImpl=new DeploymentImpl(archive,ejbs,context,archiveFactory,archiveName);
    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);
    addWeldListenerToAllWars(context);
  }
 else {
    deploymentImpl.scanArchive(archive,ejbs,context,archiveName);
  }
  deploymentImpl.addDeployedEjbs(ejbs);
  if (ejbBundle != null && (!deploymentImpl.getServices().contains(EjbServices.class))) {
    deploymentImpl.getServices().add(EjbServices.class,ejbServices);
  }
  DeployCommandParameters dc=context.getCommandParameters(DeployCommandParameters.class);
  deploymentImpl.getServices().add(ExternalConfiguration.class,new ExternalConfigurationImpl(System.getProperty("String_Node_Str","String_Node_Str"),dc != null ? !dc.isAvailabilityEnabled() : true));
  BeanDeploymentArchive bda=deploymentImpl.getBeanDeploymentArchiveForArchive(archiveName);
  if (bda != null && !bda.getBeansXml().getBeanDiscoveryMode().equals(BeanDiscoveryMode.NONE)) {
    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));
      wDesc.addAppListenerDescriptor(new AppListenerDescriptorImpl(WeldTerminationListenerProxy.class.getName()));
      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) {
      if (!bda.getBeansXml().getBeanDiscoveryMode().equals(BeanDiscoveryMode.NONE)) {
        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);
        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;
}

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);
  }
  boolean isSubArchive=archive.getParentArchive() != null;
  String archiveName=!isSubArchive ? appInfo.getName() : archive.getName();
  if (isSubArchive) {
    archiveName=BeanDeploymentArchiveImpl.stripMavenVersion(archiveName);
  }
  if (!context.getArchiveHandler().getArchiveType().isEmpty()) {
    archiveName=String.format("String_Node_Str",archiveName,context.getArchiveHandler().getArchiveType());
  }
  DeploymentImpl deploymentImpl=context.getTransientAppMetaData(WELD_DEPLOYMENT,DeploymentImpl.class);
  if (deploymentImpl == null) {
    deploymentImpl=new DeploymentImpl(archive,ejbs,context,archiveFactory,archiveName);
    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);
    addWeldListenerToAllWars(context);
  }
 else {
    deploymentImpl.scanArchive(archive,ejbs,context,archiveName);
  }
  deploymentImpl.addDeployedEjbs(ejbs);
  if (ejbBundle != null && (!deploymentImpl.getServices().contains(EjbServices.class))) {
    deploymentImpl.getServices().add(EjbServices.class,ejbServices);
  }
  DeployCommandParameters dc=context.getCommandParameters(DeployCommandParameters.class);
  deploymentImpl.getServices().add(ExternalConfiguration.class,new ExternalConfigurationImpl(System.getProperty("String_Node_Str","String_Node_Str"),dc != null ? !dc.isAvailabilityEnabled() : true));
  BeanDeploymentArchive bda=deploymentImpl.getBeanDeploymentArchiveForArchive(archiveName);
  if (bda != null && !bda.getBeansXml().getBeanDiscoveryMode().equals(BeanDiscoveryMode.NONE)) {
    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));
      wDesc.addAppListenerDescriptor(new AppListenerDescriptorImpl(WeldTerminationListenerProxy.class.getName()));
      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) {
      if (!bda.getBeansXml().getBeanDiscoveryMode().equals(BeanDiscoveryMode.NONE)) {
        InjectionManager injectionMgr=services.getService(InjectionManager.class);
        InjectionServices injectionServices=new InjectionServicesImpl(injectionMgr,bundle,deploymentImpl);
        deploymentImpl.getServices().add(InjectionServices.class,injectionServices);
        if (logger.isLoggable(Level.FINE)) {
          logger.log(Level.FINE,CDILoggerInfo.ADDING_INJECTION_SERVICES,new Object[]{injectionServices,bda.getId()});
        }
        bda.getServices().add(InjectionServices.class,injectionServices);
        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;
}