Program: 167793
Project: 167793
Buggy source:
public void addDeploymentOverlays(final List<ModelNode> updates){
  if (domainModel.hasDefined(DEPLOYMENT_OVERLAY)) {
    HostFileRepository remoteRepository=null;
    if (!domainController.getLocalHostInfo().isMasterDomainController()) {
      remoteRepository=domainController.getRemoteFileRepository();
    }
    for (    Property deploymentOverlay : domainModel.get(DEPLOYMENT_OVERLAY).asPropertyList()) {
      String name=deploymentOverlay.getName();
      ModelNode details=deploymentOverlay.getValue();
      PathAddress addr=PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT_OVERLAY,name));
      ModelNode addOp=Util.getEmptyOperation(ADD,addr.toModelNode());
      updates.add(addOp);
      if (details.hasDefined(CONTENT)) {
        for (        Property content : details.get(CONTENT).asPropertyList()) {
          final String contentName=content.getName();
          final ModelNode contentDetails=content.getValue();
          byte[] hash=contentDetails.require(CONTENT).asBytes();
          File[] files=domainController.getLocalFileRepository().getDeploymentFiles(hash);
          if (files == null || files.length == 0) {
            if (remoteRepository != null) {
              remoteRepository.getDeploymentFiles(hash);
            }
          }
          addr=PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT_OVERLAY,name),PathElement.pathElement(CONTENT,contentName));
          addOp=Util.getEmptyOperation(ADD,addr.toModelNode());
          addOp.get(CONTENT).get(HASH).set(contentDetails.get(CONTENT));
          updates.add(addOp);
        }
      }
      if (serverGroup.hasDefined(DEPLOYMENT_OVERLAY)) {
        final ModelNode groupOverlay=serverGroup.get(DEPLOYMENT_OVERLAY).asObject();
        if (groupOverlay.has(name)) {
          ModelNode deploymentsNode=groupOverlay.get(name);
          if (deploymentsNode.has(DEPLOYMENT)) {
            for (            Property content : deploymentsNode.get(DEPLOYMENT).asPropertyList()) {
              final String deploymentName=content.getName();
              final ModelNode deploymentDetails=content.getValue();
              boolean regEx=deploymentDetails.hasDefined(REGULAR_EXPRESSION) ? deploymentDetails.require(REGULAR_EXPRESSION).asBoolean() : false;
              addr=PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT_OVERLAY,name),PathElement.pathElement(DEPLOYMENT,deploymentName));
              addOp=Util.getEmptyOperation(ADD,addr.toModelNode());
              addOp.get(REGULAR_EXPRESSION).set(regEx);
              updates.add(addOp);
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
public void addDeploymentOverlays(final List<ModelNode> updates){
  if (domainModel.hasDefined(DEPLOYMENT_OVERLAY)) {
    HostFileRepository remoteRepository=null;
    if (!domainController.getLocalHostInfo().isMasterDomainController()) {
      remoteRepository=domainController.getRemoteFileRepository();
    }
    for (    Property deploymentOverlay : domainModel.get(DEPLOYMENT_OVERLAY).asPropertyList()) {
      String name=deploymentOverlay.getName();
      ModelNode details=deploymentOverlay.getValue();
      PathAddress addr=PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT_OVERLAY,name));
      ModelNode addOp=Util.getEmptyOperation(ADD,addr.toModelNode());
      updates.add(addOp);
      if (details.hasDefined(CONTENT)) {
        for (        Property content : details.get(CONTENT).asPropertyList()) {
          final String contentName=content.getName();
          final ModelNode contentDetails=content.getValue();
          byte[] hash=contentDetails.require(CONTENT).asBytes();
          File[] files=domainController.getLocalFileRepository().getDeploymentFiles(hash);
          if (files == null || files.length == 0) {
            if (remoteRepository != null) {
              remoteRepository.getDeploymentFiles(hash);
            }
          }
          addr=PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT_OVERLAY,name),PathElement.pathElement(CONTENT,contentName));
          addOp=Util.getEmptyOperation(ADD,addr.toModelNode());
          addOp.get(CONTENT).get(HASH).set(contentDetails.get(CONTENT));
          updates.add(addOp);
        }
      }
      if (serverGroup.hasDefined(DEPLOYMENT_OVERLAY)) {
        final ModelNode groupOverlay=serverGroup.get(DEPLOYMENT_OVERLAY).asObject();
        if (groupOverlay.has(name)) {
          ModelNode deploymentsNode=groupOverlay.get(name);
          if (deploymentsNode.has(DEPLOYMENT)) {
            for (            Property content : deploymentsNode.get(DEPLOYMENT).asPropertyList()) {
              final String deploymentName=content.getName();
              final ModelNode deploymentDetails=content.getValue();
              addr=PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT_OVERLAY,name),PathElement.pathElement(DEPLOYMENT,deploymentName));
              addOp=Util.getEmptyOperation(ADD,addr.toModelNode());
              updates.add(addOp);
            }
          }
        }
      }
    }
  }
}