1
1
/*
2
- * Copyright 2002-2024 the original author or authors.
2
+ * Copyright 2002-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -494,21 +494,17 @@ else if (ErrorPredicates.TRANSACTION_EXCEPTION.test(ex)) {
494
494
}));
495
495
}
496
496
else if (ErrorPredicates .RUNTIME_OR_ERROR .test (ex )) {
497
- Mono <Void > mono ;
497
+ Mono <Void > mono = Mono . empty () ;
498
498
if (!beforeCompletionInvoked .get ()) {
499
499
mono = triggerBeforeCompletion (synchronizationManager , status );
500
500
}
501
- else {
502
- mono = Mono .empty ();
503
- }
504
501
result = mono .then (doRollbackOnCommitException (synchronizationManager , status , ex ))
505
502
.then (propagateException );
506
503
}
507
-
508
504
return result ;
509
505
})
510
506
.then (Mono .defer (() -> triggerAfterCommit (synchronizationManager , status ).onErrorResume (ex ->
511
- triggerAfterCompletion (synchronizationManager , status , TransactionSynchronization .STATUS_COMMITTED ).then (Mono .error (ex )))
507
+ triggerAfterCompletion (synchronizationManager , status , TransactionSynchronization .STATUS_COMMITTED ).then (Mono .error (ex )))
512
508
.then (triggerAfterCompletion (synchronizationManager , status , TransactionSynchronization .STATUS_COMMITTED ))
513
509
.then (Mono .defer (() -> {
514
510
if (status .isNewTransaction ()) {
@@ -518,8 +514,8 @@ else if (ErrorPredicates.RUNTIME_OR_ERROR.test(ex)) {
518
514
}))));
519
515
520
516
return commit
521
- .onErrorResume (ex -> cleanupAfterCompletion (synchronizationManager , status )
522
- . then ( Mono . error ( ex ))) .then (cleanupAfterCompletion (synchronizationManager , status ));
517
+ .onErrorResume (ex -> cleanupAfterCompletion (synchronizationManager , status ). then ( Mono . error ( ex )))
518
+ .then (cleanupAfterCompletion (synchronizationManager , status ));
523
519
}
524
520
525
521
/**
@@ -571,8 +567,8 @@ private Mono<Void> processRollback(TransactionSynchronizationManager synchroniza
571
567
}
572
568
return beforeCompletion ;
573
569
}
574
- })).onErrorResume (ErrorPredicates .RUNTIME_OR_ERROR , ex -> triggerAfterCompletion (
575
- synchronizationManager , status , TransactionSynchronization .STATUS_UNKNOWN )
570
+ })).onErrorResume (ErrorPredicates .RUNTIME_OR_ERROR , ex ->
571
+ triggerAfterCompletion ( synchronizationManager , status , TransactionSynchronization .STATUS_UNKNOWN )
576
572
.then (Mono .defer (() -> {
577
573
if (status .isNewTransaction ()) {
578
574
this .transactionExecutionListeners .forEach (listener -> listener .afterRollback (status , ex ));
@@ -623,7 +619,7 @@ else if (status.hasTransaction()) {
623
619
return Mono .empty ();
624
620
}))
625
621
.then (Mono .error (rbex ));
626
- }).then (triggerAfterCompletion (synchronizationManager , status , TransactionSynchronization .STATUS_ROLLED_BACK ))
622
+ }).then (Mono . defer (() -> triggerAfterCompletion (synchronizationManager , status , TransactionSynchronization .STATUS_ROLLED_BACK ) ))
627
623
.then (Mono .defer (() -> {
628
624
this .transactionExecutionListeners .forEach (listener -> listener .afterRollback (status , null ));
629
625
return Mono .empty ();
0 commit comments