Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
4f86233c
Commit
4f86233c
authored
Feb 10, 2019
by
Jeffrey van der Laan
Committed by
Andy Wilkinson
Feb 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not auto-configure OEMIV filter when user defines registration bean
See gh-15889
parent
88fd84aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
2 deletions
+58
-2
JpaBaseConfiguration.java
...work/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java
+3
-1
AbstractJpaAutoConfigurationTests.java
...oconfigure/orm/jpa/AbstractJpaAutoConfigurationTests.java
+55
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java
View file @
4f86233c
/*
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -39,6 +39,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplicat
...
@@ -39,6 +39,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplicat
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type
;
import
org.springframework.boot.autoconfigure.domain.EntityScanPackages
;
import
org.springframework.boot.autoconfigure.domain.EntityScanPackages
;
import
org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers
;
import
org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers
;
import
org.springframework.boot.autoconfigure.web.servlet.ConditionalOnMissingFilterBean
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder
;
import
org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
...
@@ -211,6 +212,7 @@ public abstract class JpaBaseConfiguration implements BeanFactoryAware {
...
@@ -211,6 +212,7 @@ public abstract class JpaBaseConfiguration implements BeanFactoryAware {
@ConditionalOnClass
(
WebMvcConfigurer
.
class
)
@ConditionalOnClass
(
WebMvcConfigurer
.
class
)
@ConditionalOnMissingBean
({
OpenEntityManagerInViewInterceptor
.
class
,
@ConditionalOnMissingBean
({
OpenEntityManagerInViewInterceptor
.
class
,
OpenEntityManagerInViewFilter
.
class
})
OpenEntityManagerInViewFilter
.
class
})
@ConditionalOnMissingFilterBean
(
OpenEntityManagerInViewFilter
.
class
)
@ConditionalOnProperty
(
prefix
=
"spring.jpa"
,
name
=
"open-in-view"
,
havingValue
=
"true"
,
matchIfMissing
=
true
)
@ConditionalOnProperty
(
prefix
=
"spring.jpa"
,
name
=
"open-in-view"
,
havingValue
=
"true"
,
matchIfMissing
=
true
)
protected
static
class
JpaWebConfiguration
{
protected
static
class
JpaWebConfiguration
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/AbstractJpaAutoConfigurationTests.java
View file @
4f86233c
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -38,6 +38,7 @@ import org.springframework.boot.test.context.assertj.AssertableApplicationContex
...
@@ -38,6 +38,7 @@ import org.springframework.boot.test.context.assertj.AssertableApplicationContex
import
org.springframework.boot.test.context.runner.ApplicationContextRunner
;
import
org.springframework.boot.test.context.runner.ApplicationContextRunner
;
import
org.springframework.boot.test.context.runner.ContextConsumer
;
import
org.springframework.boot.test.context.runner.ContextConsumer
;
import
org.springframework.boot.test.context.runner.WebApplicationContextRunner
;
import
org.springframework.boot.test.context.runner.WebApplicationContextRunner
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.context.annotation.Primary
;
...
@@ -159,6 +160,32 @@ public abstract class AbstractJpaAutoConfigurationTests {
...
@@ -159,6 +160,32 @@ public abstract class AbstractJpaAutoConfigurationTests {
.
doesNotHaveBean
(
OpenEntityManagerInViewInterceptor
.
class
));
.
doesNotHaveBean
(
OpenEntityManagerInViewInterceptor
.
class
));
}
}
@Test
public
void
openEntityManagerInViewInterceptorIsNotRegisteredWhenFilterRegistrationPresent
()
{
new
WebApplicationContextRunner
()
.
withPropertyValues
(
"spring.datasource.generate-unique-name=true"
)
.
withUserConfiguration
(
TestFilterRegistrationConfiguration
.
class
)
.
withConfiguration
(
AutoConfigurations
.
of
(
DataSourceAutoConfiguration
.
class
,
TransactionAutoConfiguration
.
class
,
this
.
autoConfiguredClass
))
.
run
((
context
)
->
assertThat
(
context
)
.
doesNotHaveBean
(
OpenEntityManagerInViewInterceptor
.
class
));
}
@Test
public
void
openEntityManagerInViewInterceptorAutoConfigurationBacksOffWhenManuallyRegistered
()
{
new
WebApplicationContextRunner
()
.
withPropertyValues
(
"spring.datasource.generate-unique-name=true"
)
.
withUserConfiguration
(
TestInterceptorManualConfiguration
.
class
)
.
withConfiguration
(
AutoConfigurations
.
of
(
DataSourceAutoConfiguration
.
class
,
TransactionAutoConfiguration
.
class
,
this
.
autoConfiguredClass
))
.
run
((
context
)
->
assertThat
(
context
)
.
getBean
(
OpenEntityManagerInViewInterceptor
.
class
)
.
isExactlyInstanceOf
(
TestInterceptorManualConfiguration
.
ManualOpenEntityManagerInViewInterceptor
.
class
));
}
@Test
@Test
public
void
openEntityManagerInViewInterceptorISNotRegisteredWhenExplicitlyOff
()
{
public
void
openEntityManagerInViewInterceptorISNotRegisteredWhenExplicitlyOff
()
{
new
WebApplicationContextRunner
()
new
WebApplicationContextRunner
()
...
@@ -298,6 +325,33 @@ public abstract class AbstractJpaAutoConfigurationTests {
...
@@ -298,6 +325,33 @@ public abstract class AbstractJpaAutoConfigurationTests {
}
}
@Configuration
@TestAutoConfigurationPackage
(
City
.
class
)
protected
static
class
TestFilterRegistrationConfiguration
{
@Bean
public
FilterRegistrationBean
<
OpenEntityManagerInViewFilter
>
OpenEntityManagerInViewFilterFilterRegistrationBean
()
{
return
new
FilterRegistrationBean
<>();
}
}
@Configuration
@TestAutoConfigurationPackage
(
City
.
class
)
protected
static
class
TestInterceptorManualConfiguration
{
@Bean
public
OpenEntityManagerInViewInterceptor
openEntityManagerInViewInterceptor
()
{
return
new
ManualOpenEntityManagerInViewInterceptor
();
}
protected
static
class
ManualOpenEntityManagerInViewInterceptor
extends
OpenEntityManagerInViewInterceptor
{
}
}
@Configuration
@Configuration
protected
static
class
TestConfigurationWithLocalContainerEntityManagerFactoryBean
protected
static
class
TestConfigurationWithLocalContainerEntityManagerFactoryBean
extends
TestConfiguration
{
extends
TestConfiguration
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment