Skip to content

Commit 7a8fc0e

Browse files
committed
Avoid misleading log message for commit-triggering exception
Closes gh-25253
1 parent 3db0bd2 commit 7a8fc0e

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -307,11 +307,12 @@ protected Object invokeWithinTransaction(Method method, @Nullable Class<?> targe
307307
}
308308

309309
else {
310+
Object result;
310311
final ThrowableHolder throwableHolder = new ThrowableHolder();
311312

312313
// It's a CallbackPreferringPlatformTransactionManager: pass a TransactionCallback in.
313314
try {
314-
Object result = ((CallbackPreferringPlatformTransactionManager) tm).execute(txAttr, status -> {
315+
result = ((CallbackPreferringPlatformTransactionManager) tm).execute(txAttr, status -> {
315316
TransactionInfo txInfo = prepareTransactionInfo(tm, txAttr, joinpointIdentification, status);
316317
try {
317318
return invocation.proceedWithInvocation();
@@ -336,12 +337,6 @@ protected Object invokeWithinTransaction(Method method, @Nullable Class<?> targe
336337
cleanupTransactionInfo(txInfo);
337338
}
338339
});
339-
340-
// Check result state: It might indicate a Throwable to rethrow.
341-
if (throwableHolder.throwable != null) {
342-
throw throwableHolder.throwable;
343-
}
344-
return result;
345340
}
346341
catch (ThrowableHolderException ex) {
347342
throw ex.getCause();
@@ -359,11 +354,17 @@ protected Object invokeWithinTransaction(Method method, @Nullable Class<?> targe
359354
}
360355
throw ex2;
361356
}
357+
358+
// Check result state: It might indicate a Throwable to rethrow.
359+
if (throwableHolder.throwable != null) {
360+
throw throwableHolder.throwable;
361+
}
362+
return result;
362363
}
363364
}
364365

365366
/**
366-
* Clear the cache.
367+
* Clear the transaction manager cache.
367368
*/
368369
protected void clearTransactionManagerCache() {
369370
this.transactionManagerCache.clear();
@@ -682,6 +683,7 @@ public String toString() {
682683
@FunctionalInterface
683684
protected interface InvocationCallback {
684685

686+
@Nullable
685687
Object proceedWithInvocation() throws Throwable;
686688
}
687689

0 commit comments

Comments
 (0)