Program: 167971
Project: 167971
Buggy source:
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
  final DeploymentUnit deploymentUnit=phaseContext.getDeploymentUnit();
  if (deploymentUnit.getAttachment(MARKER) != null) {
    return;
  }
  deploymentUnit.putAttachment(MARKER,true);
  if (deploymentUnit.hasAttachment(Attachments.OSGI_MANIFEST)) {
    return;
  }
  final ResourceRoot mainRoot=deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
  final List<ResourceRoot> additionalRoots=deploymentUnit.getAttachment(Attachments.RESOURCE_ROOTS);
  if (mainRoot == null) {
    return;
  }
  List<ResourceRoot> resourceRoots=new ArrayList<ResourceRoot>();
  if (ModuleRootMarker.isModuleRoot(mainRoot)) {
    resourceRoots.add(mainRoot);
  }
  if (additionalRoots != null)   for (  ResourceRoot additionalRoot : additionalRoots) {
    if (ModuleRootMarker.isModuleRoot(additionalRoot)) {
      resourceRoots.add(additionalRoot);
    }
  }
  final ModuleSpecification moduleSpecification=deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
  final ModuleIdentifier moduleIdentifier=deploymentUnit.getAttachment(Attachments.MODULE_IDENTIFIER);
  if (moduleIdentifier == null) {
    throw new DeploymentUnitProcessingException("String_Node_Str" + deploymentUnit.getName());
  }
  ServiceName moduleServiceName=createModuleService(phaseContext,deploymentUnit,resourceRoots,moduleSpecification,moduleIdentifier);
  phaseContext.addDeploymentDependency(moduleServiceName,Attachments.MODULE);
  final List<AdditionalModuleSpecification> additionalModules=deploymentUnit.getAttachment(Attachments.ADDITIONAL_MODULES);
  if (additionalModules == null) {
    return;
  }
  for (  AdditionalModuleSpecification module : additionalModules) {
    ServiceName additionalModuleServiceName=createModuleService(phaseContext,deploymentUnit,module.getResourceRoots(),module,module.getModuleIdentifier());
    phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS,additionalModuleServiceName);
  }
}

Fixed version (ground truth):
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
  final DeploymentUnit deploymentUnit=phaseContext.getDeploymentUnit();
  if (deploymentUnit.getAttachment(MARKER) != null) {
    return;
  }
  deploymentUnit.putAttachment(MARKER,true);
  if (deploymentUnit.hasAttachment(Attachments.OSGI_MANIFEST)) {
    return;
  }
  final ResourceRoot mainRoot=deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
  final List<ResourceRoot> additionalRoots=deploymentUnit.getAttachment(Attachments.RESOURCE_ROOTS);
  if (mainRoot == null) {
    return;
  }
  List<ResourceRoot> resourceRoots=new ArrayList<ResourceRoot>();
  if (ModuleRootMarker.isModuleRoot(mainRoot)) {
    resourceRoots.add(mainRoot);
  }
  if (additionalRoots != null)   for (  ResourceRoot additionalRoot : additionalRoots) {
    if (ModuleRootMarker.isModuleRoot(additionalRoot) && !SubDeploymentMarker.isSubDeployment(additionalRoot)) {
      resourceRoots.add(additionalRoot);
    }
  }
  final ModuleSpecification moduleSpecification=deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
  final ModuleIdentifier moduleIdentifier=deploymentUnit.getAttachment(Attachments.MODULE_IDENTIFIER);
  if (moduleIdentifier == null) {
    throw new DeploymentUnitProcessingException("String_Node_Str" + deploymentUnit.getName());
  }
  ServiceName moduleServiceName=createModuleService(phaseContext,deploymentUnit,resourceRoots,moduleSpecification,moduleIdentifier);
  phaseContext.addDeploymentDependency(moduleServiceName,Attachments.MODULE);
  final List<AdditionalModuleSpecification> additionalModules=deploymentUnit.getAttachment(Attachments.ADDITIONAL_MODULES);
  if (additionalModules == null) {
    return;
  }
  for (  AdditionalModuleSpecification module : additionalModules) {
    ServiceName additionalModuleServiceName=createModuleService(phaseContext,deploymentUnit,module.getResourceRoots(),module,module.getModuleIdentifier());
    phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS,additionalModuleServiceName);
  }
}