1
1
/*
2
- * Copyright 2002-2019 the original author or authors.
2
+ * Copyright 2002-2020 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -307,11 +307,12 @@ protected Object invokeWithinTransaction(Method method, @Nullable Class<?> targe
307
307
}
308
308
309
309
else {
310
+ Object result ;
310
311
final ThrowableHolder throwableHolder = new ThrowableHolder ();
311
312
312
313
// It's a CallbackPreferringPlatformTransactionManager: pass a TransactionCallback in.
313
314
try {
314
- Object result = ((CallbackPreferringPlatformTransactionManager ) tm ).execute (txAttr , status -> {
315
+ result = ((CallbackPreferringPlatformTransactionManager ) tm ).execute (txAttr , status -> {
315
316
TransactionInfo txInfo = prepareTransactionInfo (tm , txAttr , joinpointIdentification , status );
316
317
try {
317
318
return invocation .proceedWithInvocation ();
@@ -336,12 +337,6 @@ protected Object invokeWithinTransaction(Method method, @Nullable Class<?> targe
336
337
cleanupTransactionInfo (txInfo );
337
338
}
338
339
});
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 ;
345
340
}
346
341
catch (ThrowableHolderException ex ) {
347
342
throw ex .getCause ();
@@ -359,11 +354,17 @@ protected Object invokeWithinTransaction(Method method, @Nullable Class<?> targe
359
354
}
360
355
throw ex2 ;
361
356
}
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 ;
362
363
}
363
364
}
364
365
365
366
/**
366
- * Clear the cache.
367
+ * Clear the transaction manager cache.
367
368
*/
368
369
protected void clearTransactionManagerCache () {
369
370
this .transactionManagerCache .clear ();
@@ -682,6 +683,7 @@ public String toString() {
682
683
@ FunctionalInterface
683
684
protected interface InvocationCallback {
684
685
686
+ @ Nullable
685
687
Object proceedWithInvocation () throws Throwable ;
686
688
}
687
689
0 commit comments