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
6cc272ec
Commit
6cc272ec
authored
Oct 04, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Make sure cache busting works with error pages"
Closes gh-14583
parent
64f04fce
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
13 deletions
+26
-13
FreeMarkerServletWebConfiguration.java
...nfigure/freemarker/FreeMarkerServletWebConfiguration.java
+7
-2
ThymeleafAutoConfiguration.java
...t/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
+4
-5
FreeMarkerAutoConfigurationServletIntegrationTests.java
...r/FreeMarkerAutoConfigurationServletIntegrationTests.java
+11
-4
ThymeleafServletAutoConfigurationTests.java
...ure/thymeleaf/ThymeleafServletAutoConfigurationTests.java
+4
-2
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerServletWebConfiguration.java
View file @
6cc272ec
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
freemarker
;
package
org
.
springframework
.
boot
.
autoconfigure
.
freemarker
;
import
javax.servlet.DispatcherType
;
import
javax.servlet.Servlet
;
import
javax.servlet.Servlet
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
...
@@ -25,6 +26,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
...
@@ -25,6 +26,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication
;
import
org.springframework.boot.autoconfigure.web.ConditionalOnEnabledResourceChain
;
import
org.springframework.boot.autoconfigure.web.ConditionalOnEnabledResourceChain
;
import
org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration
;
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.web.servlet.resource.ResourceUrlEncodingFilter
;
import
org.springframework.web.servlet.resource.ResourceUrlEncodingFilter
;
...
@@ -74,8 +76,11 @@ class FreeMarkerServletWebConfiguration extends AbstractFreeMarkerConfiguration
...
@@ -74,8 +76,11 @@ class FreeMarkerServletWebConfiguration extends AbstractFreeMarkerConfiguration
@Bean
@Bean
@ConditionalOnMissingBean
@ConditionalOnMissingBean
@ConditionalOnEnabledResourceChain
@ConditionalOnEnabledResourceChain
public
ResourceUrlEncodingFilter
resourceUrlEncodingFilter
()
{
public
FilterRegistrationBean
<
ResourceUrlEncodingFilter
>
resourceUrlEncodingFilter
()
{
return
new
ResourceUrlEncodingFilter
();
FilterRegistrationBean
<
ResourceUrlEncodingFilter
>
registration
=
new
FilterRegistrationBean
<>(
new
ResourceUrlEncodingFilter
());
registration
.
setDispatcherTypes
(
DispatcherType
.
REQUEST
,
DispatcherType
.
ERROR
);
return
registration
;
}
}
}
}
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
View file @
6cc272ec
...
@@ -169,12 +169,11 @@ public class ThymeleafAutoConfiguration {
...
@@ -169,12 +169,11 @@ public class ThymeleafAutoConfiguration {
@Bean
@Bean
@ConditionalOnMissingBean
@ConditionalOnMissingBean
@ConditionalOnEnabledResourceChain
@ConditionalOnEnabledResourceChain
public
FilterRegistrationBean
resourceUrlEncodingFilter
()
{
public
FilterRegistrationBean
<
ResourceUrlEncodingFilter
>
resourceUrlEncodingFilter
()
{
FilterRegistrationBean
<
ResourceUrlEncodingFilter
>
filterRegistrationBea
n
=
new
FilterRegistrationBean
<>(
FilterRegistrationBean
<
ResourceUrlEncodingFilter
>
registratio
n
=
new
FilterRegistrationBean
<>(
new
ResourceUrlEncodingFilter
());
new
ResourceUrlEncodingFilter
());
filterRegistrationBean
.
setDispatcherTypes
(
DispatcherType
.
REQUEST
,
registration
.
setDispatcherTypes
(
DispatcherType
.
REQUEST
,
DispatcherType
.
ERROR
);
DispatcherType
.
ERROR
);
return
registration
;
return
filterRegistrationBean
;
}
}
@Configuration
@Configuration
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationServletIntegrationTests.java
View file @
6cc272ec
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
@@ -17,8 +17,10 @@
...
@@ -17,8 +17,10 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
freemarker
;
package
org
.
springframework
.
boot
.
autoconfigure
.
freemarker
;
import
java.io.StringWriter
;
import
java.io.StringWriter
;
import
java.util.EnumSet
;
import
java.util.Locale
;
import
java.util.Locale
;
import
javax.servlet.DispatcherType
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
org.junit.After
;
import
org.junit.After
;
...
@@ -26,6 +28,7 @@ import org.junit.Before;
...
@@ -26,6 +28,7 @@ import org.junit.Before;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.test.util.TestPropertyValues
;
import
org.springframework.boot.test.util.TestPropertyValues
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.mock.web.MockHttpServletRequest
;
import
org.springframework.mock.web.MockHttpServletRequest
;
import
org.springframework.mock.web.MockHttpServletResponse
;
import
org.springframework.mock.web.MockHttpServletResponse
;
import
org.springframework.mock.web.MockServletContext
;
import
org.springframework.mock.web.MockServletContext
;
...
@@ -153,14 +156,18 @@ public class FreeMarkerAutoConfigurationServletIntegrationTests {
...
@@ -153,14 +156,18 @@ public class FreeMarkerAutoConfigurationServletIntegrationTests {
@Test
@Test
public
void
registerResourceHandlingFilterDisabledByDefault
()
{
public
void
registerResourceHandlingFilterDisabledByDefault
()
{
registerAndRefreshContext
();
registerAndRefreshContext
();
assertThat
(
this
.
context
.
getBeansOfType
(
ResourceUrlEncodingFilter
.
class
))
assertThat
(
this
.
context
.
getBeansOfType
(
FilterRegistrationBean
.
class
)).
isEmpty
();
.
isEmpty
();
}
}
@Test
@Test
public
void
registerResourceHandlingFilterOnlyIfResourceChainIsEnabled
()
{
public
void
registerResourceHandlingFilterOnlyIfResourceChainIsEnabled
()
{
registerAndRefreshContext
(
"spring.resources.chain.enabled:true"
);
registerAndRefreshContext
(
"spring.resources.chain.enabled:true"
);
assertThat
(
this
.
context
.
getBean
(
ResourceUrlEncodingFilter
.
class
)).
isNotNull
();
FilterRegistrationBean
<?>
registration
=
this
.
context
.
getBean
(
FilterRegistrationBean
.
class
);
assertThat
(
registration
.
getFilter
())
.
isInstanceOf
(
ResourceUrlEncodingFilter
.
class
);
assertThat
(
registration
).
hasFieldOrPropertyWithValue
(
"dispatcherTypes"
,
EnumSet
.
of
(
DispatcherType
.
REQUEST
,
DispatcherType
.
ERROR
));
}
}
private
void
registerAndRefreshContext
(
String
...
env
)
{
private
void
registerAndRefreshContext
(
String
...
env
)
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafServletAutoConfigurationTests.java
View file @
6cc272ec
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
@@ -51,6 +51,7 @@ import org.springframework.mock.web.MockServletContext;
...
@@ -51,6 +51,7 @@ import org.springframework.mock.web.MockServletContext;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
;
import
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
;
import
org.springframework.web.servlet.ViewResolver
;
import
org.springframework.web.servlet.ViewResolver
;
import
org.springframework.web.servlet.resource.ResourceUrlEncodingFilter
;
import
org.springframework.web.servlet.support.RequestContext
;
import
org.springframework.web.servlet.support.RequestContext
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
@@ -217,7 +218,8 @@ public class ThymeleafServletAutoConfigurationTests {
...
@@ -217,7 +218,8 @@ public class ThymeleafServletAutoConfigurationTests {
load
(
BaseConfiguration
.
class
,
"spring.resources.chain.enabled:true"
);
load
(
BaseConfiguration
.
class
,
"spring.resources.chain.enabled:true"
);
FilterRegistrationBean
<?>
registration
=
this
.
context
FilterRegistrationBean
<?>
registration
=
this
.
context
.
getBean
(
FilterRegistrationBean
.
class
);
.
getBean
(
FilterRegistrationBean
.
class
);
assertThat
(
registration
).
isNotNull
();
assertThat
(
registration
.
getFilter
())
.
isInstanceOf
(
ResourceUrlEncodingFilter
.
class
);
assertThat
(
registration
).
hasFieldOrPropertyWithValue
(
"dispatcherTypes"
,
assertThat
(
registration
).
hasFieldOrPropertyWithValue
(
"dispatcherTypes"
,
EnumSet
.
of
(
DispatcherType
.
REQUEST
,
DispatcherType
.
ERROR
));
EnumSet
.
of
(
DispatcherType
.
REQUEST
,
DispatcherType
.
ERROR
));
}
}
...
...
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