Improve javadoc in RollbackRuleAttribute regarding nested classes

Closes gh-24682

Co-authored-by: Sam Brannen <sbrannen@pivotal.io>
This commit is contained in:
Qimiao Chen 2020-03-15 19:06:16 +08:00 committed by GitHub
parent d85a6c0bea
commit 70581d1ea2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -54,7 +54,7 @@ public class RollbackRuleAttribute implements Serializable{
/**
* Create a new instance of the {@code RollbackRuleAttribute} class.
* <p>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

View File

@ -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 {
}
}
}