Skip to content

Commit 2ed9a61

Browse files
committed
Rename TransactionSynchronizationManager#currentTransaction()
This commit renames currentTransaction() to forCurrentTransaction() for greater clarity. Closes gh-23086
1 parent 044ea17 commit 2ed9a61

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

spring-tx/src/main/java/org/springframework/transaction/reactive/AbstractReactiveTransactionManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public final Mono<ReactiveTransaction> getReactiveTransaction(@Nullable Transact
101101
// Use defaults if no transaction definition given.
102102
TransactionDefinition def = (definition != null ? definition : TransactionDefinition.withDefaults());
103103

104-
return TransactionSynchronizationManager.currentTransaction()
104+
return TransactionSynchronizationManager.forCurrentTransaction()
105105
.flatMap(synchronizationManager -> {
106106

107107
Object transaction = doGetTransaction(synchronizationManager);
@@ -403,7 +403,7 @@ public final Mono<Void> commit(ReactiveTransaction transaction) throws Transacti
403403
"Transaction is already completed - do not call commit or rollback more than once per transaction"));
404404
}
405405

406-
return TransactionSynchronizationManager.currentTransaction().flatMap(synchronizationManager -> {
406+
return TransactionSynchronizationManager.forCurrentTransaction().flatMap(synchronizationManager -> {
407407
GenericReactiveTransaction reactiveTx = (GenericReactiveTransaction) transaction;
408408
if (reactiveTx.isRollbackOnly()) {
409409
if (reactiveTx.isDebug()) {
@@ -483,7 +483,7 @@ public final Mono<Void> rollback(ReactiveTransaction transaction) throws Transac
483483
return Mono.error(new IllegalTransactionStateException(
484484
"Transaction is already completed - do not call commit or rollback more than once per transaction"));
485485
}
486-
return TransactionSynchronizationManager.currentTransaction().flatMap(synchronizationManager -> {
486+
return TransactionSynchronizationManager.forCurrentTransaction().flatMap(synchronizationManager -> {
487487
GenericReactiveTransaction reactiveTx = (GenericReactiveTransaction) transaction;
488488
return processRollback(synchronizationManager, reactiveTx);
489489
});

spring-tx/src/main/java/org/springframework/transaction/reactive/TransactionSynchronizationManager.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ public TransactionSynchronizationManager(TransactionContext transactionContext)
8282

8383

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

0 commit comments

Comments
 (0)