Skip to content

Commit

Permalink
Avoid misleading log message for commit-triggering exception
Browse files Browse the repository at this point in the history
Closes gh-25253
  • Loading branch information
jhoeller committed Jun 17, 2020
1 parent 3aae8b2 commit 299e2c8
Showing 1 changed file with 10 additions and 9 deletions.
@@ -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.
Expand Down Expand Up @@ -295,11 +295,12 @@ protected Object invokeWithinTransaction(Method method, Class<?> targetClass, fi
}

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) {
Expand Down Expand Up @@ -328,12 +329,6 @@ public Object doInTransaction(TransactionStatus status) {
}
}
});

// 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();
Expand All @@ -351,11 +346,17 @@ public Object doInTransaction(TransactionStatus status) {
}
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();
Expand Down

0 comments on commit 299e2c8

Please sign in to comment.