AMQP-334 Fix Nested Cause Classification

Consider Foo caused by Bar caused by Baz.

If Bar is categorized TRUE and Baz categorized FALSE, classiy() should
return TRUE (hit on Bar), but it returned FALSE.

The early exit from the cause traversal was not taken because we
were always testing against the top level throwable (Bar).

Add a test to verify this scenario; test against the cause on
each iteration through the loop.
This commit is contained in:
Gary Russell
2013-10-02 11:17:39 -04:00
parent 6396f11878
commit aad050ba47
2 changed files with 48 additions and 1 deletions

View File

@@ -110,7 +110,7 @@ public class BinaryExceptionClassifier extends SubclassClassifier<Throwable, Boo
if (classified.equals(this.getDefault())) {
Throwable cause = classifiable;
do {
if (this.getClassified().containsKey(classifiable.getClass())) {
if (this.getClassified().containsKey(cause.getClass())) {
return classified; // non-default classification
}
cause = cause.getCause();