From 70581d1ea2d9e637f35af10f1c25f79d4e84ed21 Mon Sep 17 00:00:00 2001 From: Qimiao Chen Date: Sun, 15 Mar 2020 19:06:16 +0800 Subject: [PATCH] Improve javadoc in RollbackRuleAttribute regarding nested classes Closes gh-24682 Co-authored-by: Sam Brannen --- .../interceptor/RollbackRuleAttribute.java | 2 +- .../interceptor/RollbackRuleTests.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/RollbackRuleAttribute.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/RollbackRuleAttribute.java index cd4de069f5..07a59cc113 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/RollbackRuleAttribute.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/RollbackRuleAttribute.java @@ -54,7 +54,7 @@ public class RollbackRuleAttribute implements Serializable{ /** * Create a new instance of the {@code RollbackRuleAttribute} class. *

This is the preferred way to construct a rollback rule that matches - * the supplied {@link Exception} class (and subclasses). + * the supplied {@link Exception} class, its subclasses, and its nested classes. * @param clazz throwable class; must be {@link Throwable} or a subclass * of {@code Throwable} * @throws IllegalArgumentException if the supplied {@code clazz} is diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/RollbackRuleTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/RollbackRuleTests.java index 9d05c6d0e0..992053ab40 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/RollbackRuleTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/RollbackRuleTests.java @@ -88,4 +88,19 @@ public class RollbackRuleTests { new RollbackRuleAttribute((String) null)); } + @Test + public void foundEnclosedExceptionWithEnclosingException() { + RollbackRuleAttribute rr = new RollbackRuleAttribute(EnclosingException.class); + assertThat(rr.getDepth(new EnclosingException.EnclosedException())).isEqualTo(0); + } + + @SuppressWarnings("serial") + static class EnclosingException extends RuntimeException { + + @SuppressWarnings("serial") + static class EnclosedException extends RuntimeException { + + } + } + }