Browse Source

Avoid misleading log message for commit-triggering exception

Closes gh-25253
pull/25592/head
Juergen Hoeller 6 years ago
parent
commit
299e2c8c46
  1. 19
      spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -295,11 +295,12 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init @@ -295,11 +295,12 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
}
else {
Object result;
final ThrowableHolder throwableHolder = new ThrowableHolder();
// It's a CallbackPreferringPlatformTransactionManager: pass a TransactionCallback in.
try {
Object result = ((CallbackPreferringPlatformTransactionManager) tm).execute(txAttr,
result = ((CallbackPreferringPlatformTransactionManager) tm).execute(txAttr,
new TransactionCallback<Object>() {
@Override
public Object doInTransaction(TransactionStatus status) {
@ -328,12 +329,6 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init @@ -328,12 +329,6 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
}
}
});
// Check result state: It might indicate a Throwable to rethrow.
if (throwableHolder.throwable != null) {
throw throwableHolder.throwable;
}
return result;
}
catch (ThrowableHolderException ex) {
throw ex.getCause();
@ -351,11 +346,17 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init @@ -351,11 +346,17 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
}
throw ex2;
}
// Check result state: It might indicate a Throwable to rethrow.
if (throwableHolder.throwable != null) {
throw throwableHolder.throwable;
}
return result;
}
}
/**
* Clear the cache.
* Clear the transaction manager cache.
*/
protected void clearTransactionManagerCache() {
this.transactionManagerCache.clear();

Loading…
Cancel
Save