diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2017-10-25 13:43:47 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2017-10-25 14:03:11 +0200 |
commit | ebb655851d033639d5d771043175bed7dc2547b9 (patch) | |
tree | 39d63b6e7615156744da6eac606e6ac68e75ef82 /messagebus | |
parent | f671f4e689e1dc2f9e878ac678c626096cece26e (diff) |
Expose underlying errors.
Diffstat (limited to 'messagebus')
-rwxr-xr-x | messagebus/src/main/java/com/yahoo/messagebus/routing/RoutingNode.java | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/messagebus/src/main/java/com/yahoo/messagebus/routing/RoutingNode.java b/messagebus/src/main/java/com/yahoo/messagebus/routing/RoutingNode.java index 1169973f118..b46981935aa 100755 --- a/messagebus/src/main/java/com/yahoo/messagebus/routing/RoutingNode.java +++ b/messagebus/src/main/java/com/yahoo/messagebus/routing/RoutingNode.java @@ -106,10 +106,13 @@ public class RoutingNode implements ReplyHandler { public void send() { if (!resolve(0)) { notifyAbort("Route resolution failed."); - } else if (hasUnconsumedErrors()) { - notifyAbort("Errors found while resolving route."); } else { - notifyTransmit(); + String errors = getUnconsumedErrors(); + if (errors != null) { + notifyAbort("Errors found while resolving route: " + errors); + } else { + notifyTransmit(); + } } } @@ -300,14 +303,14 @@ public class RoutingNode implements ReplyHandler { } /** - * Returns whether or not transmitting along this routing tree can possibly succeed. This evaluates to false if + * Return any errors preventing transmitting along this routing tree to possibly succeed. This might happen if * either a) there are no leaf nodes to send to, or b) some leaf node contains a fatal error that is not masked by a * routing policy above it in the tree. If only transient errors would reach this, the resend flag is set to true. * - * @return True if no error reaches this. + * @return The errors concatenated or null. */ - private boolean hasUnconsumedErrors() { - boolean hasError = false; + private String getUnconsumedErrors() { + StringBuilder errors = null; Deque<RoutingNode> stack = new ArrayDeque<>(); stack.push(this); @@ -315,7 +318,8 @@ public class RoutingNode implements ReplyHandler { RoutingNode node = stack.pop(); if (node.reply != null) { for (int i = 0; i < node.reply.getNumErrors(); ++i) { - int errorCode = node.reply.getError(i).getCode(); + Error error = node.reply.getError(i); + int errorCode = error.getCode(); RoutingNode it = node; while (it != null) { if (it.routingContext != null && it.routingContext.isConsumableError(errorCode)) { @@ -325,11 +329,14 @@ public class RoutingNode implements ReplyHandler { it = it.parent; } if (errorCode != ErrorCode.NONE) { + if (errors == null) { + errors = new StringBuilder(); + } + errors.append(error.toString()); shouldRetry = resender != null && resender.canRetry(errorCode); if (!shouldRetry) { - return true; // no need to continue + return errors.toString(); // no need to continue } - hasError = true; } } } else { @@ -339,7 +346,7 @@ public class RoutingNode implements ReplyHandler { } } - return hasError; + return errors != null ? errors.toString() : null; } /** |