Skip to content

Commit 299e2c8

Browse files
committed
Avoid misleading log message for commit-triggering exception
Closes gh-25253
1 parent 3aae8b2 commit 299e2c8

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

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

Lines changed: 10 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.
@@ -295,11 +295,12 @@ protected Object invokeWithinTransaction(Method method, Class<?> targetClass, fi
295295
}
296296

297297
else {
298+
Object result;
298299
final ThrowableHolder throwableHolder = new ThrowableHolder();
299300

300301
// It's a CallbackPreferringPlatformTransactionManager: pass a TransactionCallback in.
301302
try {
302-
Object result = ((CallbackPreferringPlatformTransactionManager) tm).execute(txAttr,
303+
result = ((CallbackPreferringPlatformTransactionManager) tm).execute(txAttr,
303304
new TransactionCallback<Object>() {
304305
@Override
305306
public Object doInTransaction(TransactionStatus status) {
@@ -328,12 +329,6 @@ public Object doInTransaction(TransactionStatus status) {
328329
}
329330
}
330331
});
331-
332-
// Check result state: It might indicate a Throwable to rethrow.
333-
if (throwableHolder.throwable != null) {
334-
throw throwableHolder.throwable;
335-
}
336-
return result;
337332
}
338333
catch (ThrowableHolderException ex) {
339334
throw ex.getCause();
@@ -351,11 +346,17 @@ public Object doInTransaction(TransactionStatus status) {
351346
}
352347
throw ex2;
353348
}
349+
350+
// Check result state: It might indicate a Throwable to rethrow.
351+
if (throwableHolder.throwable != null) {
352+
throw throwableHolder.throwable;
353+
}
354+
return result;
354355
}
355356
}
356357

357358
/**
358-
* Clear the cache.
359+
* Clear the transaction manager cache.
359360
*/
360361
protected void clearTransactionManagerCache() {
361362
this.transactionManagerCache.clear();

0 commit comments

Comments
 (0)