Skip to content

Commit 5d325ca

Browse files
committed
Improve wording for transactional rollback rule semantics
Closes gh-35346
1 parent 68762b5 commit 5d325ca

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

framework-docs/modules/ROOT/pages/data-access/transaction/declarative/rolling-back.adoc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,13 @@ rollback rules may be configured via the `rollbackFor`/`noRollbackFor` and
8686
`rollbackForClassName`/`noRollbackForClassName` attributes, which allow rules to be
8787
defined based on exception types or patterns, respectively.
8888
89-
When a rollback rule is defined with an exception type, that type will be used to match
90-
against the type of a thrown exception and its super types, providing type safety and
91-
avoiding any unintentional matches that may occur when using a pattern. For example, a
92-
value of `jakarta.servlet.ServletException.class` will only match thrown exceptions of
93-
type `jakarta.servlet.ServletException` and its subclasses.
89+
When a rollback rule is defined with an exception type – for example, via `rollbackFor` –
90+
that type will be used to match against the type of a thrown exception. Specifically,
91+
given a configured exception type `C`, a thrown exception of type `T` will be considered
92+
a match against `C` if `T` is equal to `C` or a subclass of `C`. This provides type
93+
safety and avoids any unintentional matches that may occur when using a pattern. For
94+
example, a value of `jakarta.servlet.ServletException.class` will only match thrown
95+
exceptions of type `jakarta.servlet.ServletException` and its subclasses.
9496
9597
When a rollback rule is defined with an exception pattern, the pattern can be a fully
9698
qualified class name or a substring of a fully qualified class name for an exception type

spring-tx/src/main/java/org/springframework/transaction/annotation/Transactional.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,12 @@
5656
* {@link #rollbackForClassName}/{@link #noRollbackForClassName}, which allow
5757
* rules to be specified as types or patterns, respectively.
5858
*
59-
* <p>When a rollback rule is defined with an exception type, that type will be
60-
* used to match against the type of a thrown exception and its super types,
61-
* providing type safety and avoiding any unintentional matches that may occur
59+
* <p>When a rollback rule is defined with an exception type &mdash; for example,
60+
* via {@link #rollbackFor} &mdash; that type will be used to match against the
61+
* type of a thrown exception. Specifically, given a configured exception type
62+
* {@code C}, a thrown exception of type {@code T} will be considered a match
63+
* against {@code C} if {@code T} is equal to {@code C} or a subclass of {@code C}.
64+
* This provides type safety and avoids any unintentional matches that may occur
6265
* when using a pattern. For example, a value of
6366
* {@code jakarta.servlet.ServletException.class} will only match thrown exceptions
6467
* of type {@code jakarta.servlet.ServletException} and its subclasses.

0 commit comments

Comments
 (0)