[jboss-jira] [JBoss JIRA] (WFCORE-442) AbstractMultiTargetHandler-based handlers do not propagate failures to the top level failure-description
Brian Stansberry (JIRA)
issues at jboss.org
Thu May 21 11:39:19 EDT 2015
[ https://issues.jboss.org/browse/WFCORE-442?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13070104#comment-13070104 ]
Brian Stansberry edited comment on WFCORE-442 at 5/21/15 11:39 AM:
-------------------------------------------------------------------
Emmanuel had a commit in his WFCORE-287 work to address this, but there was a lot of other work in the same area in master so it's not in. I'll have to see if it can still be used or massaged a bit and used, etc.
https://github.com/ehsavoie/wildfly-core/commit/ad5f28cae338fcdd5a01aad7ea38e34a70ae9d3a
Here's the key bits in case that commit gets flushed out of that repo. In GlobalOperationHandlers (but note that this diff is against some unknown previous version of it in Emmanuel's branch):
{code}
@@ -217,6 +219,34 @@ public void handleResult(OperationContext.ResultAction resultAction, OperationCo
}
}
});
+
+ context.completeStep(new OperationContext.RollbackHandler() {
+ @Override
+ public void handleRollback(OperationContext context, ModelNode operation) {
+ if (!context.hasFailureDescription()) {
+ String op = operation.require(OP).asString();
+ Map<PathAddress, ModelNode> failures = new HashMap<PathAddress, ModelNode>();
+ for (ModelNode resultItem : result.asList()) {
+ if (resultItem.hasDefined(FAILURE_DESCRIPTION)) {
+ final PathAddress failedAddress = PathAddress.pathAddress(resultItem.get(ADDRESS));
+ ModelNode failedDesc = resultItem.get(FAILURE_DESCRIPTION);
+ failures.put(failedAddress, failedDesc);
+ }
+ }
+
+ if (failures.size() == 1) {
+ Map.Entry<PathAddress, ModelNode> entry = failures.entrySet().iterator().next();
+ if (entry.getValue().getType() == ModelType.STRING) {
+ context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.wildcardOperationFailedAtSingleAddress(op, entry.getKey(), entry.getValue().asString()));
+ } else {
+ context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.wildcardOperationFailedAtSingleAddressWithComplexFailure(op, entry.getKey()));
+ }
+ } else if (failures.size() > 1) {
+ context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.wildcardOperationFailedAtMultipleAddresses(op, failures.keySet()));
+ }
+ }
+ }
+ });
} else {
doExecute(context, operation, filteredData, ignoreMissingResource, predicate);
}
{code}
was (Author: brian.stansberry):
Emmanuel had a commit in his WFCORE-287 work to address this, but there was a lot of other work in the same area in master so it's not in. I'll have to see if it can still be used or massaged a bit and used, etc.
https://github.com/ehsavoie/wildfly-core/commit/ad5f28cae338fcdd5a01aad7ea38e34a70ae9d3a
> AbstractMultiTargetHandler-based handlers do not propagate failures to the top level failure-description
> --------------------------------------------------------------------------------------------------------
>
> Key: WFCORE-442
> URL: https://issues.jboss.org/browse/WFCORE-442
> Project: WildFly Core
> Issue Type: Bug
> Components: Domain Management
> Affects Versions: 1.0.0.Alpha13
> Reporter: Brian Stansberry
> Assignee: Brian Stansberry
> Fix For: 2.0.0.Alpha3
>
>
> An example is worth a thousand words:
> {code}
> [standalone at localhost:9990 /] /path=*:query(where={read-only=1})
> {
> "outcome" => "failed",
> "result" => [
> {
> "address" => [("path" => "jboss.server.temp.dir")],
> "outcome" => "failed",
> "result" => {
> "name" => "jboss.server.temp.dir",
> "path" => "/Users/hbraun/dev/prj/wildfly-core/core-build/target/wildfly-core-1.0.0.Alpha14-SNAPSHOT/standalone/tmp",
> "read-only" => true,
> "relative-to" => undefined
> },
> "rolled-back" => true
> },
> {
> "address" => [("path" => "user.home")],
> "outcome" => "failed",
> "result" => {
> "name" => "user.home",
> "path" => "/Users/hbraun",
> "read-only" => true,
> "relative-to" => undefined
> },
> "rolled-back" => true
> },
> {
> "address" => [("path" => "jboss.server.base.dir")],
> "outcome" => "failed",
> "result" => {
> "name" => "jboss.server.base.dir",
> "path" => "/Users/hbraun/dev/prj/wildfly-core/core-build/target/wildfly-core-1.0.0.Alpha14-SNAPSHOT/standalone",
> "read-only" => true,
> "relative-to" => undefined
> },
> "rolled-back" => true
> },
> {
> "address" => [("path" => "java.home")],
> "outcome" => "failed",
> "result" => {
> "name" => "java.home",
> "path" => "/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre",
> "read-only" => true,
> "relative-to" => undefined
> },
> "rolled-back" => true
> },
> {
> "address" => [("path" => "user.dir")],
> "outcome" => "failed",
> "result" => {
> "name" => "user.dir",
> "path" => "/Users/hbraun/dev/prj/wildfly-core/core-build/target/wildfly-core-1.0.0.Alpha14-SNAPSHOT",
> "read-only" => true,
> "relative-to" => undefined
> },
> "rolled-back" => true
> },
> {
> "address" => [("path" => "jboss.server.data.dir")],
> "outcome" => "failed",
> "result" => {
> "name" => "jboss.server.data.dir",
> "path" => "/Users/hbraun/dev/prj/wildfly-core/core-build/target/wildfly-core-1.0.0.Alpha14-SNAPSHOT/standalone/data",
> "read-only" => true,
> "relative-to" => undefined
> },
> "rolled-back" => true
> },
> {
> "address" => [("path" => "jboss.home.dir")],
> "outcome" => "failed",
> "result" => {
> "name" => "jboss.home.dir",
> "path" => "/Users/hbraun/dev/prj/wildfly-core/core-build/target/wildfly-core-1.0.0.Alpha14-SNAPSHOT",
> "read-only" => true,
> "relative-to" => undefined
> },
> "rolled-back" => true
> },
> {
> "address" => [("path" => "jboss.server.log.dir")],
> "outcome" => "failed",
> "result" => {
> "name" => "jboss.server.log.dir",
> "path" => "/Users/hbraun/dev/prj/wildfly-core/core-build/target/wildfly-core-1.0.0.Alpha14-SNAPSHOT/standalone/log",
> "read-only" => true,
> "relative-to" => undefined
> },
> "rolled-back" => true
> },
> {
> "address" => [("path" => "jboss.server.config.dir")],
> "outcome" => "failed",
> "result" => {
> "name" => "jboss.server.config.dir",
> "path" => "/Users/hbraun/dev/prj/wildfly-core/core-build/target/wildfly-core-1.0.0.Alpha14-SNAPSHOT/standalone/configuration",
> "read-only" => true,
> "relative-to" => undefined
> },
> "rolled-back" => true
> },
> {
> "address" => [("path" => "jboss.controller.temp.dir")],
> "outcome" => "failed",
> "result" => {
> "name" => "jboss.controller.temp.dir",
> "path" => "/Users/hbraun/dev/prj/wildfly-core/core-build/target/wildfly-core-1.0.0.Alpha14-SNAPSHOT/standalone/tmp",
> "read-only" => true,
> "relative-to" => undefined
> },
> "failure-description" => "Illegal argument for attribute 'read-only'. Expected type BOOLEAN",
> "rolled-back" => true
> }
> ],
> "rolled-back" => true
> }
> {code}
> One item in the set has a failure description but the overall response does not.
> ReadResourceDescriptionHandler handles similar things but has logic for creating an overall failure-description.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
More information about the jboss-jira
mailing list