Defend against lambda transaction customizers
Update `TransactionManagerCustomizers` to deal directly with `ClassCastExceptions` assuming that they are because a customizer is implemented using a lambda. See gh-7561
This commit is contained in:
parent
4b853c2107
commit
3c930347c5
|
|
@ -20,6 +20,9 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
|
|
@ -31,6 +34,9 @@ import org.springframework.transaction.PlatformTransactionManager;
|
|||
*/
|
||||
public class TransactionManagerCustomizers {
|
||||
|
||||
private static final Log logger = LogFactory
|
||||
.getLog(TransactionManagerCustomizers.class);
|
||||
|
||||
private final List<PlatformTransactionManagerCustomizer<?>> customizers;
|
||||
|
||||
public TransactionManagerCustomizers(
|
||||
|
|
@ -56,7 +62,17 @@ public class TransactionManagerCustomizers {
|
|||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private void customize(PlatformTransactionManager transactionManager,
|
||||
PlatformTransactionManagerCustomizer customizer) {
|
||||
customizer.customize(transactionManager);
|
||||
try {
|
||||
customizer.customize(transactionManager);
|
||||
}
|
||||
catch (ClassCastException ex) {
|
||||
// Possibly a lambda-defined listener which we could not resolve the generic
|
||||
// event type for
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Non-matching transaction manager type for customizer: "
|
||||
+ customizer, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue