Rename TransactionSynchronizationManager#currentTransaction()

This commit renames currentTransaction() to forCurrentTransaction() for
greater clarity.

Closes gh-23086
This commit is contained in:
Sam Brannen 2019-06-05 14:15:07 +03:00
parent 044ea17bf9
commit 2ed9a61ba0
2 changed files with 9 additions and 9 deletions

View File

@ -101,7 +101,7 @@ public abstract class AbstractReactiveTransactionManager implements ReactiveTran
// Use defaults if no transaction definition given. // Use defaults if no transaction definition given.
TransactionDefinition def = (definition != null ? definition : TransactionDefinition.withDefaults()); TransactionDefinition def = (definition != null ? definition : TransactionDefinition.withDefaults());
return TransactionSynchronizationManager.currentTransaction() return TransactionSynchronizationManager.forCurrentTransaction()
.flatMap(synchronizationManager -> { .flatMap(synchronizationManager -> {
Object transaction = doGetTransaction(synchronizationManager); Object transaction = doGetTransaction(synchronizationManager);
@ -403,7 +403,7 @@ public abstract class AbstractReactiveTransactionManager implements ReactiveTran
"Transaction is already completed - do not call commit or rollback more than once per transaction")); "Transaction is already completed - do not call commit or rollback more than once per transaction"));
} }
return TransactionSynchronizationManager.currentTransaction().flatMap(synchronizationManager -> { return TransactionSynchronizationManager.forCurrentTransaction().flatMap(synchronizationManager -> {
GenericReactiveTransaction reactiveTx = (GenericReactiveTransaction) transaction; GenericReactiveTransaction reactiveTx = (GenericReactiveTransaction) transaction;
if (reactiveTx.isRollbackOnly()) { if (reactiveTx.isRollbackOnly()) {
if (reactiveTx.isDebug()) { if (reactiveTx.isDebug()) {
@ -483,7 +483,7 @@ public abstract class AbstractReactiveTransactionManager implements ReactiveTran
return Mono.error(new IllegalTransactionStateException( return Mono.error(new IllegalTransactionStateException(
"Transaction is already completed - do not call commit or rollback more than once per transaction")); "Transaction is already completed - do not call commit or rollback more than once per transaction"));
} }
return TransactionSynchronizationManager.currentTransaction().flatMap(synchronizationManager -> { return TransactionSynchronizationManager.forCurrentTransaction().flatMap(synchronizationManager -> {
GenericReactiveTransaction reactiveTx = (GenericReactiveTransaction) transaction; GenericReactiveTransaction reactiveTx = (GenericReactiveTransaction) transaction;
return processRollback(synchronizationManager, reactiveTx); return processRollback(synchronizationManager, reactiveTx);
}); });

View File

@ -82,13 +82,13 @@ public class TransactionSynchronizationManager {
/** /**
* Return the TransactionSynchronizationManager of the current transaction. * Get the {@link TransactionSynchronizationManager} that is associated with
* Mainly intended for code that wants to bind resources or synchronizations. * the current transaction context.
* rollback-only but not throw an application exception. * <p>Mainly intended for code that wants to bind resources or synchronizations.
* @throws NoTransactionException if the transaction info cannot be found, * @throws NoTransactionException if the transaction info cannot be found &mdash;
* because the method was invoked outside a managed transaction. * for example, because the method was invoked outside a managed transaction
*/ */
public static Mono<TransactionSynchronizationManager> currentTransaction() { public static Mono<TransactionSynchronizationManager> forCurrentTransaction() {
return TransactionContextManager.currentContext().map(TransactionSynchronizationManager::new); return TransactionContextManager.currentContext().map(TransactionSynchronizationManager::new);
} }