Program: 167694
Project: 167694
Buggy source:
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
  final DeploymentUnit deploymentUnit=phaseContext.getDeploymentUnit();
  final ModuleLoader moduleLoader=deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER);
  final Boolean computeCompositeIndex=deploymentUnit.getAttachment(Attachments.COMPUTE_COMPOSITE_ANNOTATION_INDEX);
  if (computeCompositeIndex != null && !computeCompositeIndex) {
    return;
  }
  Map<ModuleIdentifier,CompositeIndex> additionalAnnotationIndexes=new HashMap<ModuleIdentifier,CompositeIndex>();
  final List<ModuleIdentifier> additionalModuleIndexes=deploymentUnit.getAttachmentList(Attachments.ADDITIONAL_ANNOTATION_INDEXES);
  final List<Index> indexes=new ArrayList<Index>();
  for (  final ModuleIdentifier moduleIdentifier : additionalModuleIndexes) {
    try {
      Module module=moduleLoader.loadModule(moduleIdentifier);
      final CompositeIndex additionalIndex=ModuleIndexBuilder.buildCompositeIndex(module);
      if (additionalIndex != null) {
        indexes.addAll(additionalIndex.indexes);
        additionalAnnotationIndexes.put(moduleIdentifier,additionalIndex);
      }
 else {
        final Index index=calculateModuleIndex(module);
        indexes.add(index);
      }
    }
 catch (    ModuleLoadException e) {
      throw new DeploymentUnitProcessingException(e);
    }
catch (    IOException e) {
      throw new DeploymentUnitProcessingException(e);
    }
  }
  deploymentUnit.putAttachment(Attachments.ADDITIONAL_ANNOTATION_INDEXES_BY_MODULE,additionalAnnotationIndexes);
  final List<ResourceRoot> allResourceRoots=new ArrayList<ResourceRoot>();
  final List<ResourceRoot> resourceRoots=deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
  for (  ResourceRoot resourceRoot : resourceRoots) {
    if (!SubDeploymentMarker.isSubDeployment(resourceRoot) && ModuleRootMarker.isModuleRoot(resourceRoot)) {
      allResourceRoots.add(resourceRoot);
    }
  }
  allResourceRoots.addAll(handleClassPathItems(deploymentUnit));
  final ResourceRoot deploymentRoot=deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
  if (ModuleRootMarker.isModuleRoot(deploymentRoot)) {
    allResourceRoots.add(deploymentRoot);
  }
  for (  ResourceRoot resourceRoot : allResourceRoots) {
    Index index=resourceRoot.getAttachment(Attachments.ANNOTATION_INDEX);
    if (index != null) {
      indexes.add(index);
    }
  }
  deploymentUnit.putAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX,new CompositeIndex(indexes));
}

Fixed version (ground truth):
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
  final DeploymentUnit deploymentUnit=phaseContext.getDeploymentUnit();
  final ModuleLoader moduleLoader=deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER);
  final Boolean computeCompositeIndex=deploymentUnit.getAttachment(Attachments.COMPUTE_COMPOSITE_ANNOTATION_INDEX);
  if (computeCompositeIndex != null && !computeCompositeIndex) {
    return;
  }
  DeploymentUnit top=deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent();
  Map<ModuleIdentifier,AdditionalModuleSpecification> additionalModuleSpecificationMap=new HashMap<>();
  for (  AdditionalModuleSpecification i : top.getAttachmentList(Attachments.ADDITIONAL_MODULES)) {
    additionalModuleSpecificationMap.put(i.getModuleIdentifier(),i);
  }
  Map<ModuleIdentifier,CompositeIndex> additionalAnnotationIndexes=new HashMap<ModuleIdentifier,CompositeIndex>();
  final List<ModuleIdentifier> additionalModuleIndexes=deploymentUnit.getAttachmentList(Attachments.ADDITIONAL_ANNOTATION_INDEXES);
  final List<Index> indexes=new ArrayList<Index>();
  for (  final ModuleIdentifier moduleIdentifier : additionalModuleIndexes) {
    AdditionalModuleSpecification additional=additionalModuleSpecificationMap.get(moduleIdentifier);
    if (additional != null) {
      for (      ResourceRoot resource : additional.getResourceRoots()) {
        ResourceRootIndexer.indexResourceRoot(resource);
        Index indexAttachment=resource.getAttachment(Attachments.ANNOTATION_INDEX);
        if (indexAttachment != null) {
          indexes.add(indexAttachment);
        }
      }
    }
 else {
      try {
        Module module=moduleLoader.loadModule(moduleIdentifier);
        final CompositeIndex additionalIndex=ModuleIndexBuilder.buildCompositeIndex(module);
        if (additionalIndex != null) {
          indexes.addAll(additionalIndex.indexes);
          additionalAnnotationIndexes.put(moduleIdentifier,additionalIndex);
        }
 else {
          final Index index=calculateModuleIndex(module);
          indexes.add(index);
        }
      }
 catch (      ModuleLoadException e) {
        throw new DeploymentUnitProcessingException(e);
      }
catch (      IOException e) {
        throw new DeploymentUnitProcessingException(e);
      }
    }
  }
  deploymentUnit.putAttachment(Attachments.ADDITIONAL_ANNOTATION_INDEXES_BY_MODULE,additionalAnnotationIndexes);
  final List<ResourceRoot> allResourceRoots=new ArrayList<ResourceRoot>();
  final List<ResourceRoot> resourceRoots=deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
  for (  ResourceRoot resourceRoot : resourceRoots) {
    if (!SubDeploymentMarker.isSubDeployment(resourceRoot) && ModuleRootMarker.isModuleRoot(resourceRoot)) {
      allResourceRoots.add(resourceRoot);
    }
  }
  allResourceRoots.addAll(handleClassPathItems(deploymentUnit));
  final ResourceRoot deploymentRoot=deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
  if (ModuleRootMarker.isModuleRoot(deploymentRoot)) {
    allResourceRoots.add(deploymentRoot);
  }
  for (  ResourceRoot resourceRoot : allResourceRoots) {
    Index index=resourceRoot.getAttachment(Attachments.ANNOTATION_INDEX);
    if (index != null) {
      indexes.add(index);
    }
  }
  deploymentUnit.putAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX,new CompositeIndex(indexes));
}