From fd8e69eddeafb1e451a2e079dd4f56c3efa8d069 Mon Sep 17 00:00:00 2001 From: Emmanuel Hugonnet Date: Fri, 1 Mar 2024 17:01:24 +0100 Subject: [PATCH] [WFCORE-6503]: Failing if unexisting attribute is used Signed-off-by: Emmanuel Hugonnet --- .../jboss/as/controller/logging/ControllerLogger.java | 10 +++++++--- .../persistence/yaml/YamlConfigurationExtension.java | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/controller/src/main/java/org/jboss/as/controller/logging/ControllerLogger.java b/controller/src/main/java/org/jboss/as/controller/logging/ControllerLogger.java index 78ab8c6e9a3..cfb9974f8a2 100644 --- a/controller/src/main/java/org/jboss/as/controller/logging/ControllerLogger.java +++ b/controller/src/main/java/org/jboss/as/controller/logging/ControllerLogger.java @@ -3744,7 +3744,7 @@ OperationFailedRuntimeException capabilityAlreadyRegisteredInContext(String capa @Message(id = 501, value = "An invalid UUID string '%s' was found at '%s'. A new value will be generated.") void uuidNotValid(String corruptedUuid, String path); - @Message(id = 502, value = "No child resource called %s could be found at address %s'.") + @Message(id = 502, value = "No child resource called '%s' could be found at address '%s'.") IllegalArgumentException noChildResource(String name, String address); @Message(id = 503, value = "Failed to publish configuration, because the remote name %s is not valid.") @@ -3756,9 +3756,13 @@ OperationFailedRuntimeException capabilityAlreadyRegisteredInContext(String capa @Message(id = 505, value = "Unsuported deployment yaml file %s with attributes %s") IllegalArgumentException unsupportedDeployment(String deployment, Set attribues); - @Message(id = 506, value = "The yaml element \"%s\" and its sub-elements are ignored.") + @Message(id = 506, value = "The yaml element '%s' and its sub-elements are ignored.") String ignoreYamlElement(String element); - @Message(id = NONE, value = "Thus ignoring element \"%s\".") + @Message(id = NONE, value = " Thus ignoring element '%s'.") String ignoreYamlSubElement(String element); + + @Message(id = 507, value = "No attribute called '%s' is defined at address '%s'.") + IllegalArgumentException noAttributeDefined(String name, String address); + } 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 d1e20dee0e9..3173da71891 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 @@ -239,10 +239,12 @@ private void processResource(PathAddress parentAddress, Map yaml } else { if (value != null && resourceRegistration.getAttributeNames(PathAddress.EMPTY_ADDRESS).contains(name)) { //we are processing an attribute: - MGMT_OP_LOGGER.debugf("We are processing the attribute %s for address %s", name, address.getParent().toCLIStyleString()); + MGMT_OP_LOGGER.debugf("We are processing the attribute %s for address %s", name, parentAddress.toCLIStyleString()); processAttribute(parentAddress, rootRegistration, name, value, postExtensionOps, xmlOperations); } else if (value == null) { MGMT_OP_LOGGER.noAttributeSetForAddress(address.toCLIStyleString()); + } else { + throw MGMT_OP_LOGGER.noAttributeDefined(name, address.toCLIStyleString()); } } } else {