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
659b459f
Commit
659b459f
authored
Sep 22, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the auto-configured LocaleContextResolver conditional on missing bean
Closes gh-23419
parent
20193715
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
WebFluxAutoConfiguration.java
.../autoconfigure/web/reactive/WebFluxAutoConfiguration.java
+8
-0
WebFluxAutoConfigurationTests.java
...configure/web/reactive/WebFluxAutoConfigurationTests.java
+19
-0
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfiguration.java
View file @
659b459f
...
...
@@ -69,6 +69,7 @@ import org.springframework.web.reactive.result.method.annotation.ArgumentResolve
import
org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter
;
import
org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMapping
;
import
org.springframework.web.reactive.result.view.ViewResolver
;
import
org.springframework.web.server.i18n.LocaleContextResolver
;
/**
* {@link EnableAutoConfiguration Auto-configuration} for {@link EnableWebFlux WebFlux}.
...
...
@@ -264,6 +265,13 @@ public class WebFluxAutoConfiguration {
return
super
.
createRequestMappingHandlerMapping
();
}
@Bean
@Override
@ConditionalOnMissingBean
public
LocaleContextResolver
localeContextResolver
()
{
return
super
.
localeContextResolver
();
}
}
@Configuration
(
proxyBeanMethods
=
false
)
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java
View file @
659b459f
...
...
@@ -73,6 +73,8 @@ import org.springframework.web.reactive.result.method.annotation.RequestMappingH
import
org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMapping
;
import
org.springframework.web.reactive.result.view.ViewResolutionResultHandler
;
import
org.springframework.web.reactive.result.view.ViewResolver
;
import
org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver
;
import
org.springframework.web.server.i18n.LocaleContextResolver
;
import
org.springframework.web.util.pattern.PathPattern
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
...
@@ -452,6 +454,13 @@ class WebFluxAutoConfigurationTests {
});
}
@Test
void
customLocaleContextResolver
()
{
this
.
contextRunner
.
withUserConfiguration
(
LocaleContextResolverConfiguration
.
class
)
.
run
((
context
)
->
assertThat
(
context
).
hasSingleBean
(
LocaleContextResolver
.
class
)
.
hasBean
(
"customLocaleContextResolver"
));
}
private
Map
<
PathPattern
,
Object
>
getHandlerMap
(
ApplicationContext
context
)
{
HandlerMapping
mapping
=
context
.
getBean
(
"resourceHandlerMapping"
,
HandlerMapping
.
class
);
if
(
mapping
instanceof
SimpleUrlHandlerMapping
)
{
...
...
@@ -676,4 +685,14 @@ class WebFluxAutoConfigurationTests {
}
@Configuration
(
proxyBeanMethods
=
false
)
static
class
LocaleContextResolverConfiguration
{
@Bean
LocaleContextResolver
customLocaleContextResolver
()
{
return
new
AcceptHeaderLocaleContextResolver
();
}
}
}
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