Program: 167696
Project: 167696
Buggy source:
private void handleDeployment(final DeploymentPhaseContext phaseContext,final DeploymentUnit deploymentUnit,final ModuleSpecification moduleSpec,final ModuleStructureSpec rootDeploymentSpecification) throws DeploymentUnitProcessingException {
  final Map<VirtualFile,ResourceRoot> resourceRoots=resourceRoots(deploymentUnit);
  moduleSpec.addUserDependencies(rootDeploymentSpecification.getModuleDependencies());
  moduleSpec.addExclusions(rootDeploymentSpecification.getExclusions());
  moduleSpec.addAliases(rootDeploymentSpecification.getAliases());
  moduleSpec.addModuleSystemDependencies(rootDeploymentSpecification.getSystemDependencies());
  for (  final ResourceRoot additionalResourceRoot : rootDeploymentSpecification.getResourceRoots()) {
    final ResourceRoot existingRoot=resourceRoots.get(additionalResourceRoot.getRoot());
    if (existingRoot != null) {
      existingRoot.merge(additionalResourceRoot);
    }
 else     if (!additionalResourceRoot.getRoot().exists()) {
      ServerLogger.DEPLOYMENT_LOGGER.additionalResourceRootDoesNotExist(additionalResourceRoot.getRoot().getPathName());
    }
 else {
      deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS,additionalResourceRoot);
      ResourceRootIndexer.indexResourceRoot(additionalResourceRoot);
      ModuleRootMarker.mark(additionalResourceRoot);
    }
  }
  for (  final String classFileTransformer : rootDeploymentSpecification.getClassFileTransformers()) {
    moduleSpec.addClassFileTransformer(classFileTransformer);
  }
  for (  final ModuleIdentifier dependency : rootDeploymentSpecification.getAnnotationModules()) {
    deploymentUnit.addToAttachmentList(Attachments.ADDITIONAL_ANNOTATION_INDEXES,dependency);
    if (dependency.getName().startsWith(ServiceModuleLoader.MODULE_PREFIX)) {
      phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS,ServiceModuleLoader.moduleServiceName(dependency));
    }
  }
  moduleSpec.setLocalLast(rootDeploymentSpecification.isLocalLast());
  if (rootDeploymentSpecification.getExcludedSubsystems() != null) {
    deploymentUnit.putAttachment(Attachments.EXCLUDED_SUBSYSTEMS,rootDeploymentSpecification.getExcludedSubsystems());
  }
}

Fixed version (ground truth):
private void handleDeployment(final DeploymentPhaseContext phaseContext,final DeploymentUnit deploymentUnit,final ModuleSpecification moduleSpec,final ModuleStructureSpec rootDeploymentSpecification,Set<ModuleIdentifier> additionalModules) throws DeploymentUnitProcessingException {
  final Map<VirtualFile,ResourceRoot> resourceRoots=resourceRoots(deploymentUnit);
  moduleSpec.addUserDependencies(rootDeploymentSpecification.getModuleDependencies());
  moduleSpec.addExclusions(rootDeploymentSpecification.getExclusions());
  moduleSpec.addAliases(rootDeploymentSpecification.getAliases());
  moduleSpec.addModuleSystemDependencies(rootDeploymentSpecification.getSystemDependencies());
  for (  final ResourceRoot additionalResourceRoot : rootDeploymentSpecification.getResourceRoots()) {
    final ResourceRoot existingRoot=resourceRoots.get(additionalResourceRoot.getRoot());
    if (existingRoot != null) {
      existingRoot.merge(additionalResourceRoot);
    }
 else     if (!additionalResourceRoot.getRoot().exists()) {
      ServerLogger.DEPLOYMENT_LOGGER.additionalResourceRootDoesNotExist(additionalResourceRoot.getRoot().getPathName());
    }
 else {
      deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS,additionalResourceRoot);
      ResourceRootIndexer.indexResourceRoot(additionalResourceRoot);
      ModuleRootMarker.mark(additionalResourceRoot);
    }
  }
  for (  final String classFileTransformer : rootDeploymentSpecification.getClassFileTransformers()) {
    moduleSpec.addClassFileTransformer(classFileTransformer);
  }
  for (  final ModuleIdentifier dependency : rootDeploymentSpecification.getAnnotationModules()) {
    deploymentUnit.addToAttachmentList(Attachments.ADDITIONAL_ANNOTATION_INDEXES,dependency);
    if (dependency.getName().startsWith(ServiceModuleLoader.MODULE_PREFIX) && !additionalModules.contains(dependency)) {
      phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS,ServiceModuleLoader.moduleServiceName(dependency));
    }
  }
  moduleSpec.setLocalLast(rootDeploymentSpecification.isLocalLast());
  if (rootDeploymentSpecification.getExcludedSubsystems() != null) {
    deploymentUnit.putAttachment(Attachments.EXCLUDED_SUBSYSTEMS,rootDeploymentSpecification.getExcludedSubsystems());
  }
}