diff --git a/controller/src/main/java/org/jboss/as/controller/AbstractOperationContext.java b/controller/src/main/java/org/jboss/as/controller/AbstractOperationContext.java index 28c5473740f..c04bc69e116 100644 --- a/controller/src/main/java/org/jboss/as/controller/AbstractOperationContext.java +++ b/controller/src/main/java/org/jboss/as/controller/AbstractOperationContext.java @@ -1227,6 +1227,7 @@ final boolean isRollingBack() { public final void reloadRequired() { if (processState.isReloadSupported()) { if(isBooting()) { + MGMT_OP_LOGGER.debug("Server is booting so we didn't set the reload required flag"); return; } activeStep.setRestartStamp(processState.setReloadRequired()); diff --git a/controller/src/main/java/org/jboss/as/controller/persistence/yaml/YamlConfigurationExtension.java b/controller/src/main/java/org/jboss/as/controller/persistence/yaml/YamlConfigurationExtension.java index f243173ba33..b0b90c4764d 100644 --- a/controller/src/main/java/org/jboss/as/controller/persistence/yaml/YamlConfigurationExtension.java +++ b/controller/src/main/java/org/jboss/as/controller/persistence/yaml/YamlConfigurationExtension.java @@ -45,6 +45,7 @@ import org.jboss.as.controller.MapAttributeDefinition; import org.jboss.as.controller.ObjectMapAttributeDefinition; import org.jboss.as.controller.ObjectTypeAttributeDefinition; +import org.jboss.as.controller.ParallelBootOperationStepHandler; import org.jboss.as.controller.ParsedBootOp; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.RunningMode; @@ -160,13 +161,29 @@ public void processOperations(ImmutableManagementResourceRegistration rootRegist } MGMT_OP_LOGGER.debug("We are applying YAML files to the configuration"); Map xmlOperations = new HashMap<>(); + ParsedBootOp parallelBootOp = null; for (ParsedBootOp op : postExtensionOps) { - if (op.getChildOperations().isEmpty()) { + List childOperations = op.getChildOperations(); + if (childOperations.isEmpty()) { xmlOperations.put(op.getAddress(), op); } else { - for (ModelNode childOp : op.getChildOperations()) { - ParsedBootOp subOp = new ParsedBootOp(childOp, null); - xmlOperations.put(subOp.getAddress(), subOp); + if (op.handler instanceof ParallelBootOperationStepHandler) { + /* We need to createa new ParsedBootOp so that the handler number of childOperations is different from the number of childOperation of the handler and thus the handler will be properly updated. + * @see ModelCOntrollerImpl.boot(final List bootList, final OperationMessageHandler handler, final OperationTransactionControl control, + * final boolean rollbackOnRuntimeFailure, MutableRootResourceRegistrationProvider parallelBootRootResourceRegistrationProvider, + * final boolean skipModelValidation, final boolean partialModel, final ConfigurationExtension configExtension) + */ + parallelBootOp = new ParsedBootOp(op, op.handler); + for (ModelNode childOp : childOperations) { + ParsedBootOp subOp = new ParsedBootOp(childOp, null); + xmlOperations.put(subOp.getAddress(), subOp); + parallelBootOp.addChildOperation(subOp); + } + } else { + for (ModelNode childOp : childOperations) { + ParsedBootOp subOp = new ParsedBootOp(childOp, null); + xmlOperations.put(subOp.getAddress(), subOp); + } } } } @@ -176,6 +193,21 @@ public void processOperations(ImmutableManagementResourceRegistration rootRegist for (Map.Entry deployment : deployments.entrySet()) { processUnmanagedDeployments(rootRegistration, deployment, xmlOperations, postExtensionOps); } + List reorderedList = new ArrayList<>(postExtensionOps.size()); + for (ParsedBootOp op : postExtensionOps) { + if (parallelBootOp != null && op.getAddress().size() > 0 && "subsystem".equals(op.getAddress().getElement(0).getKey())) { + //The new operations created from the YAML are added to the parallel boot operation enclosing all the subsystem operations + parallelBootOp.addChildOperation(op); + } else if (op.handler instanceof ParallelBootOperationStepHandler) { + //The parallel boot operation is added to the list + reorderedList.add(parallelBootOp); + } else { + //The new operations created from the YAML are added to the list of operations (if they haven't already be added in a subsystem enclosing operation). + reorderedList.add(op); + } + } + postExtensionOps.clear(); + postExtensionOps.addAll(reorderedList); this.configs.clear(); needReload = true; } @@ -424,7 +456,7 @@ private void processAttributes(PathAddress address, ImmutableManagementResourceR } } for (AttributeDefinition def : operationEntry.getOperationDefinition().getParameters()) { - if (def != null && ! attributeNames.contains(def.getName())) { + if (def != null && !attributeNames.contains(def.getName())) { if (!def.isResourceOnly()) { attributes.add(def); } diff --git a/testsuite/manualmode/src/test/java/org/jboss/as/test/manualmode/management/persistence/yaml/YamlExtensionTestCase.java b/testsuite/manualmode/src/test/java/org/jboss/as/test/manualmode/management/persistence/yaml/YamlExtensionTestCase.java index 00c33932546..8e4901b272e 100644 --- a/testsuite/manualmode/src/test/java/org/jboss/as/test/manualmode/management/persistence/yaml/YamlExtensionTestCase.java +++ b/testsuite/manualmode/src/test/java/org/jboss/as/test/manualmode/management/persistence/yaml/YamlExtensionTestCase.java @@ -433,7 +433,7 @@ public void testYamlOperations() throws Exception { result = Operations.readResult(client.execute(Operations.createReadResourceOperation(PathAddress.pathAddress("subsystem", "elytron").toModelNode(), true))); Assert.assertEquals("Yaml operation to undefine disallowed-providers was not executed.", "undefined", result.get("disallowed-providers").asString()); ModelNode permissions = result.get("permission-set").get("default-permissions").get("permissions"); - Assert.assertEquals("Yaml change to port set mail-smtp outbound socket binding is wrong", "[{\"class-name\" => \"org.wildfly.security.auth.permission.LoginPermission\",\"module\" => \"org.wildfly.security.elytron-base\",\"target-name\" => \"*\"}]", permissions.asString()); + Assert.assertEquals("Yaml change to set default permissions is wrong", "[{\"class-name\" => \"org.wildfly.security.auth.permission.LoginPermission\",\"module\" => \"org.wildfly.security.elytron-base\",\"target-name\" => \"*\"}]", permissions.asString()); } @Test