Merge branch '3.1.x'

Closes gh-37633
pull/37746/head
Andy Wilkinson 1 year ago
commit 76eb5ba8c2

@ -134,11 +134,12 @@ dependencies {
optional("org.opensaml:opensaml-saml-api:4.0.1")
optional("org.opensaml:opensaml-saml-impl:4.0.1")
optional("org.quartz-scheduler:quartz")
optional("org.springframework:spring-jdbc")
optional("org.springframework.integration:spring-integration-core")
optional("org.springframework.integration:spring-integration-jdbc")
optional("org.springframework.integration:spring-integration-jmx")
optional("org.springframework.integration:spring-integration-rsocket")
optional("org.springframework:spring-aspects")
optional("org.springframework:spring-jdbc")
optional("org.springframework:spring-jms")
optional("org.springframework:spring-orm")
optional("org.springframework:spring-tx")

@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@ -16,6 +16,7 @@
package org.springframework.boot.autoconfigure.transaction;
import org.springframework.boot.LazyInitializationExcludeFilter;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@ -29,6 +30,7 @@ import org.springframework.transaction.ReactiveTransactionManager;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.annotation.AbstractTransactionManagementConfiguration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.aspectj.AbstractTransactionAspect;
import org.springframework.transaction.reactive.TransactionalOperator;
import org.springframework.transaction.support.TransactionOperations;
import org.springframework.transaction.support.TransactionTemplate;
@ -85,4 +87,15 @@ public class TransactionAutoConfiguration {
}
@Configuration(proxyBeanMethods = false)
@ConditionalOnBean(AbstractTransactionAspect.class)
static class AspectJTransactionManagementConfiguration {
@Bean
static LazyInitializationExcludeFilter eagerTransactionAspect() {
return LazyInitializationExcludeFilter.forBeanTypes(AbstractTransactionAspect.class);
}
}
}

@ -22,11 +22,15 @@ import javax.sql.DataSource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.LazyInitializationExcludeFilter;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.logging.LogLevel;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@ -35,6 +39,7 @@ import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.ReactiveTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.aspectj.AbstractTransactionAspect;
import org.springframework.transaction.reactive.TransactionalOperator;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.transaction.support.TransactionTemplate;
@ -165,6 +170,16 @@ class TransactionAutoConfigurationTests {
});
}
@Test
void excludesAbstractTransactionAspectFromLazyInit() {
this.contextRunner.withUserConfiguration(AspectJTransactionManagementConfiguration.class)
.withInitializer(new ConditionEvaluationReportLoggingListener(LogLevel.INFO))
.run((context) -> {
LazyInitializationExcludeFilter filter = context.getBean(LazyInitializationExcludeFilter.class);
assertThat(filter.isExcluded(null, null, AbstractTransactionAspect.class)).isTrue();
});
}
@Configuration
static class SinglePlatformTransactionManagerConfiguration {
@ -281,6 +296,12 @@ class TransactionAutoConfigurationTests {
}
@Configuration(proxyBeanMethods = false)
@EnableTransactionManagement(mode = AdviceMode.ASPECTJ)
static class AspectJTransactionManagementConfiguration {
}
interface TransactionalService {
@Transactional

Loading…
Cancel
Save