@@ -854,15 +854,22 @@ public Object invokeWithinTransaction(Method method, @Nullable Class<?> targetCl
854
854
createTransactionIfNecessary (tm , txAttr , joinpointIdentification ).flatMap (it -> {
855
855
try {
856
856
// Need re-wrapping until we get hold of the exception through usingWhen.
857
- return Mono .<Object , ReactiveTransactionInfo >usingWhen (Mono .just (it ), txInfo -> {
858
- try {
859
- return (Mono <?>) invocation .proceedWithInvocation ();
860
- }
861
- catch (Throwable ex ) {
862
- return Mono .error (ex );
863
- }
864
- }, this ::commitTransactionAfterReturning , txInfo -> Mono .empty ())
865
- .onErrorResume (ex -> completeTransactionAfterThrowing (it , ex ).then (Mono .error (ex )));
857
+ return Mono
858
+ .<Object , ReactiveTransactionInfo >usingWhen (
859
+ Mono .just (it ),
860
+ txInfo -> {
861
+ try {
862
+ return (Mono <?>) invocation .proceedWithInvocation ();
863
+ }
864
+ catch (Throwable ex ) {
865
+ return Mono .error (ex );
866
+ }
867
+ },
868
+ this ::commitTransactionAfterReturning ,
869
+ (txInfo , err ) -> Mono .empty (),
870
+ this ::commitTransactionAfterReturning )
871
+ .onErrorResume (ex ->
872
+ completeTransactionAfterThrowing (it , ex ).then (Mono .error (ex )));
866
873
}
867
874
catch (Throwable ex ) {
868
875
// target invocation exception
@@ -877,15 +884,22 @@ public Object invokeWithinTransaction(Method method, @Nullable Class<?> targetCl
877
884
createTransactionIfNecessary (tm , txAttr , joinpointIdentification ).flatMapMany (it -> {
878
885
try {
879
886
// Need re-wrapping until we get hold of the exception through usingWhen.
880
- return Flux .usingWhen (Mono .just (it ), txInfo -> {
881
- try {
882
- return this .adapter .toPublisher (invocation .proceedWithInvocation ());
883
- }
884
- catch (Throwable ex ) {
885
- return Mono .error (ex );
886
- }
887
- }, this ::commitTransactionAfterReturning , txInfo -> Mono .empty ())
888
- .onErrorResume (ex -> completeTransactionAfterThrowing (it , ex ).then (Mono .error (ex )));
887
+ return Flux
888
+ .usingWhen (
889
+ Mono .just (it ),
890
+ txInfo -> {
891
+ try {
892
+ return this .adapter .toPublisher (invocation .proceedWithInvocation ());
893
+ }
894
+ catch (Throwable ex ) {
895
+ return Mono .error (ex );
896
+ }
897
+ },
898
+ this ::commitTransactionAfterReturning ,
899
+ (txInfo , ex ) -> Mono .empty (),
900
+ this ::commitTransactionAfterReturning )
901
+ .onErrorResume (ex ->
902
+ completeTransactionAfterThrowing (it , ex ).then (Mono .error (ex )));
889
903
}
890
904
catch (Throwable ex ) {
891
905
// target invocation exception
0 commit comments