Merge branch '2.7.x' into 3.0.x

Closes gh-37631
3.0.x
Andy Wilkinson 1 year ago
commit 04054b6670

@ -139,11 +139,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")

@ -17,6 +17,7 @@
package org.springframework.boot.autoconfigure.transaction;
import org.springframework.beans.factory.ObjectProvider;
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;
@ -31,6 +32,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;
@ -95,4 +97,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;
@ -177,6 +182,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 {
@ -293,6 +308,12 @@ class TransactionAutoConfigurationTests {
}
@Configuration(proxyBeanMethods = false)
@EnableTransactionManagement(mode = AdviceMode.ASPECTJ)
static class AspectJTransactionManagementConfiguration {
}
interface TransactionalService {
@Transactional

Loading…
Cancel
Save