@ -1030,26 +1030,28 @@ marks a transaction for rollback only in the case of runtime, unchecked exceptio
@@ -1030,26 +1030,28 @@ marks a transaction for rollback only in the case of runtime, unchecked exceptio
That is, when the thrown exception is an instance or subclass of `RuntimeException`.
(`Error` instances also, by default, result in a rollback).
However, starting with Spring Framework 5.2.0 the default configuration also provides support for Vavr's `Try` method to trigger transaction rollbacks when it returns a 'Failure'. This allows you to handle functional-style errors using Try and have the transaction automatically rolled back in case of a failure.
As of Spring Framework 5.2, the default configuration also provides support for
Vavr's `Try` method to trigger transaction rollbacks when it returns a 'Failure'.
This allows you to handle functional-style errors using Try and have the transaction
automatically rolled back in case of a failure. For more information on Vavr's Try,
refer to the [official Vavr documentation](https://www.vavr.io/vavr-docs/#_try).
Here's an example of how to use Vavr's Try:
Here's an example of how to use Vavr's Try with a transactional method:
// If transactionMethod throws an exception, it will be caught by the Try instance created with Try.of() and wrapped inside the Failure class, which can be checked using the isFailure() method on the Try instance.
return Try.of(serviceA::transactionalMethod);
}
@Transactional
public Try<String> myTransactionalMethod() {
// If myDataAccessOperation throws an exception, it will be caught by the
// Try instance created with Try.of() and wrapped inside the Failure class
// which can be checked using the isFailure() method on the Try instance.
return Try.of(delegate::myDataAccessOperation);
}
----
For more information on Vavr's Try, refer to the [official Vavr documentation](https://www.vavr.io/vavr-docs/#_try).
Checked exceptions that are
thrown from a transactional method do not result in rollback in the default
configuration.
You can configure exactly which `Exception` types mark a transaction for rollback,
including checked exceptions by specifying _rollback rules_.
Checked exceptions that are thrown from a transactional method do not result in a rollback
in the default configuration. You can configure exactly which `Exception` types mark a
transaction for rollback, including checked exceptions by specifying _rollback rules_.
@ -281,11 +281,11 @@ public class ConcurrentTaskScheduler extends ConcurrentTaskExecutor implements T
@@ -281,11 +281,11 @@ public class ConcurrentTaskScheduler extends ConcurrentTaskExecutor implements T
@ -294,48 +294,45 @@ public class ConcurrentTaskScheduler extends ConcurrentTaskExecutor implements T
@@ -294,48 +294,45 @@ public class ConcurrentTaskScheduler extends ConcurrentTaskExecutor implements T