Program: 167695
Project: 167695
Buggy source:
/** 
 * Process the deployment root for module dependency information.
 * @param phaseContext the deployment unit context
 * @throws org.jboss.as.server.deployment.DeploymentUnitProcessingException
 */
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
  final DeploymentUnit deploymentUnit=phaseContext.getDeploymentUnit();
  final ServiceModuleLoader deploymentModuleLoader=deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER);
  final List<ResourceRoot> allResourceRoots=DeploymentUtils.allResourceRoots(deploymentUnit);
  for (  final ResourceRoot resourceRoot : allResourceRoots) {
    final Manifest manifest=resourceRoot.getAttachment(Attachments.MANIFEST);
    if (manifest == null)     continue;
    final String dependencyString=ManifestHelper.getMainAttributeValue(manifest,DEPENDENCIES_ATTR);
    if (dependencyString == null)     continue;
    if (deploymentUnit.getParent() == null && SubDeploymentMarker.isSubDeployment(resourceRoot)) {
      continue;
    }
    final String[] dependencyDefs=dependencyString.split("String_Node_Str");
    for (    final String dependencyDef : dependencyDefs) {
      final String trimmed=dependencyDef.trim();
      if (trimmed.isEmpty()) {
        continue;
      }
      final String[] dependencyParts=trimmed.split("String_Node_Str");
      final ModuleIdentifier dependencyId=ModuleIdentifier.fromString(dependencyParts[0]);
      final boolean export=containsParam(dependencyParts,EXPORT_PARAM);
      final boolean optional=containsParam(dependencyParts,OPTIONAL_PARAM);
      final boolean services=containsParam(dependencyParts,SERVICES_PARAM);
      final boolean annotations=containsParam(dependencyParts,ANNOTATIONS_PARAM);
      final boolean metaInf=containsParam(dependencyParts,META_INF);
      final ModuleLoader dependencyLoader;
      if (dependencyId.getName().startsWith("String_Node_Str")) {
        dependencyLoader=deploymentModuleLoader;
      }
 else {
        dependencyLoader=Module.getBootModuleLoader();
      }
      if (annotations) {
        deploymentUnit.addToAttachmentList(Attachments.ADDITIONAL_ANNOTATION_INDEXES,dependencyId);
        if (dependencyLoader == deploymentModuleLoader) {
          phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS,ServiceModuleLoader.moduleServiceName(dependencyId));
        }
      }
      final ModuleDependency dependency=new ModuleDependency(dependencyLoader,dependencyId,optional,export,services,true);
      if (metaInf) {
        dependency.addImportFilter(PathFilters.getMetaInfSubdirectoriesFilter(),true);
        dependency.addImportFilter(PathFilters.getMetaInfFilter(),true);
      }
      deploymentUnit.addToAttachmentList(Attachments.MANIFEST_DEPENDENCIES,dependency);
    }
  }
}

Fixed version (ground truth):
/** 
 * Process the deployment root for module dependency information.
 * @param phaseContext the deployment unit context
 * @throws org.jboss.as.server.deployment.DeploymentUnitProcessingException
 */
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
  final DeploymentUnit deploymentUnit=phaseContext.getDeploymentUnit();
  final ServiceModuleLoader deploymentModuleLoader=deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER);
  final List<ResourceRoot> allResourceRoots=DeploymentUtils.allResourceRoots(deploymentUnit);
  DeploymentUnit top=deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent();
  Set<ModuleIdentifier> additionalModules=new HashSet<>();
  for (  AdditionalModuleSpecification i : top.getAttachmentList(Attachments.ADDITIONAL_MODULES)) {
    additionalModules.add(i.getModuleIdentifier());
  }
  for (  final ResourceRoot resourceRoot : allResourceRoots) {
    final Manifest manifest=resourceRoot.getAttachment(Attachments.MANIFEST);
    if (manifest == null)     continue;
    final String dependencyString=ManifestHelper.getMainAttributeValue(manifest,DEPENDENCIES_ATTR);
    if (dependencyString == null)     continue;
    if (deploymentUnit.getParent() == null && SubDeploymentMarker.isSubDeployment(resourceRoot)) {
      continue;
    }
    final String[] dependencyDefs=dependencyString.split("String_Node_Str");
    for (    final String dependencyDef : dependencyDefs) {
      final String trimmed=dependencyDef.trim();
      if (trimmed.isEmpty()) {
        continue;
      }
      final String[] dependencyParts=trimmed.split("String_Node_Str");
      final ModuleIdentifier dependencyId=ModuleIdentifier.fromString(dependencyParts[0]);
      final boolean export=containsParam(dependencyParts,EXPORT_PARAM);
      final boolean optional=containsParam(dependencyParts,OPTIONAL_PARAM);
      final boolean services=containsParam(dependencyParts,SERVICES_PARAM);
      final boolean annotations=containsParam(dependencyParts,ANNOTATIONS_PARAM);
      final boolean metaInf=containsParam(dependencyParts,META_INF);
      final ModuleLoader dependencyLoader;
      if (dependencyId.getName().startsWith("String_Node_Str")) {
        dependencyLoader=deploymentModuleLoader;
      }
 else {
        dependencyLoader=Module.getBootModuleLoader();
      }
      if (annotations) {
        deploymentUnit.addToAttachmentList(Attachments.ADDITIONAL_ANNOTATION_INDEXES,dependencyId);
        if (dependencyLoader == deploymentModuleLoader && !additionalModules.contains(dependencyId)) {
          phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS,ServiceModuleLoader.moduleServiceName(dependencyId));
        }
      }
      final ModuleDependency dependency=new ModuleDependency(dependencyLoader,dependencyId,optional,export,services,true);
      if (metaInf) {
        dependency.addImportFilter(PathFilters.getMetaInfSubdirectoriesFilter(),true);
        dependency.addImportFilter(PathFilters.getMetaInfFilter(),true);
      }
      deploymentUnit.addToAttachmentList(Attachments.MANIFEST_DEPENDENCIES,dependency);
    }
  }
}