From 5e1552b71867b657a4985fcfb356ffc489acc48e Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 28 Jul 2014 15:31:46 -0700 Subject: [PATCH 1/2] Retain default order in HttpMessageConverters The original fix for gh-1293 (commit 05e6af23) caused test failures due to the fact that Spring Boot's MappingJackson2HttpMessageConverter was added before Spring's default StringHttpMessageConverter. This commit changes the HttpMessageConverters logic so that additional converts are added just before any default converter of the same type. This allows additional converters to be added whilst still retaining the sensible ordering of the default converters. Fixes gh-1293 --- .../web/HttpMessageConverters.java | 25 ++++++++---- .../web/HttpMessageConvertersTests.java | 39 ++++++++++++------- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpMessageConverters.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpMessageConverters.java index ac52b71fd98..f779ffff6b7 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpMessageConverters.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpMessageConverters.java @@ -67,16 +67,27 @@ public class HttpMessageConverters implements Iterable> /** * Create a new {@link HttpMessageConverters} instance with the specified additional * converters. - * @param additionalConverters additional converters to be added. New converters will - * be added to the front of the list, overrides will replace existing items without - * changing the order. The {@link #getConverters()} methods can be used for further - * converter manipulation. + * @param additionalConverters additional converters to be added. Items are added just + * before any default converter of the same type (or at the front of the list if no + * default converter is found) The {@link #getConverters()} methods can be used for + * further converter manipulation. */ public HttpMessageConverters(Collection> additionalConverters) { List> converters = new ArrayList>(); - List> defaultConverters = getDefaultConverters(); - converters.addAll(additionalConverters); - converters.addAll(defaultConverters); + List> processing = new ArrayList>( + additionalConverters); + for (HttpMessageConverter defaultConverter : getDefaultConverters()) { + Iterator> iterator = processing.iterator(); + while (iterator.hasNext()) { + HttpMessageConverter candidate = iterator.next(); + if (ClassUtils.isAssignableValue(defaultConverter.getClass(), candidate)) { + converters.add(candidate); + iterator.remove(); + } + } + converters.add(defaultConverter); + } + converters.addAll(0, processing); this.converters = Collections.unmodifiableList(converters); } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/HttpMessageConvertersTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/HttpMessageConvertersTests.java index 49ad34abf80..91ae26af35e 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/HttpMessageConvertersTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/HttpMessageConvertersTests.java @@ -34,6 +34,7 @@ import org.springframework.http.converter.xml.SourceHttpMessageConverter; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; @@ -65,27 +66,35 @@ public class HttpMessageConvertersTests { } @Test - public void overrideExistingConverter() { - MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); - HttpMessageConverters converters = new HttpMessageConverters(converter); - assertTrue(converters.getConverters().contains(converter)); - int count = 0; - for (HttpMessageConverter httpMessageConverter : converters) { - if (httpMessageConverter instanceof MappingJackson2HttpMessageConverter) { - count++; + public void addBeforeExistingConverter() { + MappingJackson2HttpMessageConverter converter1 = new MappingJackson2HttpMessageConverter(); + MappingJackson2HttpMessageConverter converter2 = new MappingJackson2HttpMessageConverter(); + HttpMessageConverters converters = new HttpMessageConverters(converter1, + converter2); + assertTrue(converters.getConverters().contains(converter1)); + assertTrue(converters.getConverters().contains(converter2)); + List httpConverters = new ArrayList(); + for (HttpMessageConverter candidate : converters) { + if (candidate instanceof MappingJackson2HttpMessageConverter) { + httpConverters.add((MappingJackson2HttpMessageConverter) candidate); } } // The existing converter is still there, but with a lower priority - assertEquals(2, count); - assertEquals(0, converters.getConverters().indexOf(converter)); + assertEquals(3, httpConverters.size()); + assertEquals(0, httpConverters.indexOf(converter1)); + assertEquals(1, httpConverters.indexOf(converter2)); + assertNotEquals(0, converters.getConverters().indexOf(converter1)); } @Test - public void addNewConverter() { - HttpMessageConverter converter = mock(HttpMessageConverter.class); - HttpMessageConverters converters = new HttpMessageConverters(converter); - assertTrue(converters.getConverters().contains(converter)); - assertEquals(converter, converters.getConverters().get(0)); + public void addNewConverters() { + HttpMessageConverter converter1 = mock(HttpMessageConverter.class); + HttpMessageConverter converter2 = mock(HttpMessageConverter.class); + HttpMessageConverters converters = new HttpMessageConverters(converter1, + converter2); + assertTrue(converters.getConverters().contains(converter1)); + assertEquals(converter1, converters.getConverters().get(0)); + assertEquals(converter2, converters.getConverters().get(1)); } } From f8bf0e203182ecb969d6efb2d63df37ab63bcfbc Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 28 Jul 2014 13:31:22 -0700 Subject: [PATCH 2/2] Polish --- .../endpoint/mvc/HealthMvcEndpoint.java | 2 +- .../actuate/health/MongoHealthIndicator.java | 2 +- .../MessageSourceAutoConfiguration.java | 34 +++---- .../autoconfigure/amqp/RabbitProperties.java | 3 +- .../web/HttpMessageConverters.java | 6 +- ...ttpMessageConvertersAutoConfiguration.java | 5 +- spring-boot-cli/samples/http.groovy | 1 + .../main/asciidoc/spring-boot-features.adoc | 1 - .../bind/PropertySourcesPropertyValues.java | 93 +++++++++++-------- .../jetty/JettyEmbeddedServletContainer.java | 16 ++-- .../TomcatEmbeddedServletContainer.java | 15 +-- .../boot/context/web/ErrorPageFilter.java | 15 ++- ...ropertiesConfigurationFactoryMapTests.java | 2 +- .../context/web/ErrorPageFilterTests.java | 12 +-- 14 files changed, 114 insertions(+), 93 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HealthMvcEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HealthMvcEndpoint.java index 532f9729201..210c9b20680 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HealthMvcEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HealthMvcEndpoint.java @@ -31,7 +31,7 @@ import org.springframework.web.bind.annotation.ResponseBody; /** * Adapter to expose {@link HealthEndpoint} as an {@link MvcEndpoint}. - * + * * @author Christian Dupuis * @since 1.1.0 */ diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/MongoHealthIndicator.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/MongoHealthIndicator.java index c28293937a5..f841e4d820b 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/MongoHealthIndicator.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/MongoHealthIndicator.java @@ -24,7 +24,7 @@ import com.mongodb.CommandResult; /** * Simple implementation of a {@link HealthIndicator} returning status information for * Mongo data stores. - * + * * @author Christian Dupuis * @since 1.1.0 */ diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/MessageSourceAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/MessageSourceAutoConfiguration.java index 2aa72899af5..6163d590e4e 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/MessageSourceAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/MessageSourceAutoConfiguration.java @@ -53,6 +53,8 @@ import static org.springframework.util.StringUtils.trimAllWhitespace; @ConfigurationProperties(prefix = "spring.messages") public class MessageSourceAutoConfiguration { + private static final Resource[] NO_RESOURCES = {}; + private String basename = "messages"; private String encoding = "utf-8"; @@ -103,27 +105,27 @@ public class MessageSourceAutoConfiguration { String basename = context.getEnvironment().getProperty( "spring.messages.basename", "messages"); for (String name : commaDelimitedListToStringArray(trimAllWhitespace(basename))) { - Resource[] resources; - try { - resources = new PathMatchingResourcePatternResolver( - context.getClassLoader()).getResources("classpath*:" + name - + "*.properties"); - } - catch (IOException e) { - continue; - } - for (Resource resource : resources) { - + for (Resource resource : getResources(context.getClassLoader(), name)) { if (resource.exists()) { - return ConditionOutcome - .match("Bundle found for spring.messages.basename: " - + name); + return ConditionOutcome.match("Bundle found for " + + "spring.messages.basename: " + name); } } } - return ConditionOutcome - .noMatch("No bundle found for spring.messages.basename: " + basename); + return ConditionOutcome.noMatch("No bundle found for " + + "spring.messages.basename: " + basename); } + + private Resource[] getResources(ClassLoader classLoader, String name) { + try { + return new PathMatchingResourcePatternResolver(classLoader) + .getResources("classpath*:" + name + "*.properties"); + } + catch (IOException ex) { + return NO_RESOURCES; + } + } + } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java index 60647c8e63b..19582f56484 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java @@ -107,7 +107,8 @@ public class RabbitProperties { } result.add(address); } - return result.isEmpty() ? null : StringUtils.collectionToCommaDelimitedString(result); + return (result.isEmpty() ? null : StringUtils + .collectionToCommaDelimitedString(result)); } public void setPort(int port) { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpMessageConverters.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpMessageConverters.java index f779ffff6b7..bb2eb8633f5 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpMessageConverters.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpMessageConverters.java @@ -93,10 +93,8 @@ public class HttpMessageConverters implements Iterable> private List> getDefaultConverters() { List> converters = new ArrayList>(); - if (ClassUtils - .isPresent( - "org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport", - null)) { + if (ClassUtils.isPresent("org.springframework.web.servlet.config.annotation." + + "WebMvcConfigurationSupport", null)) { converters.addAll(new WebMvcConfigurationSupport() { public List> defaultMessageConverters() { return super.getMessageConverters(); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpMessageConvertersAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpMessageConvertersAutoConfiguration.java index 00d8ae30d40..a065abb8f5a 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpMessageConvertersAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpMessageConvertersAutoConfiguration.java @@ -16,7 +16,6 @@ package org.springframework.boot.autoconfigure.web; -import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -53,9 +52,7 @@ public class HttpMessageConvertersAutoConfiguration { @Bean @ConditionalOnMissingBean public HttpMessageConverters messageConverters() { - List> converters = new ArrayList>( - this.converters); - return new HttpMessageConverters(converters); + return new HttpMessageConverters(this.converters); } @Configuration diff --git a/spring-boot-cli/samples/http.groovy b/spring-boot-cli/samples/http.groovy index 71d771b101c..564f2290253 100644 --- a/spring-boot-cli/samples/http.groovy +++ b/spring-boot-cli/samples/http.groovy @@ -20,4 +20,5 @@ class Example implements CommandLineRunner { def world = new RESTClient("http://localhost:" + port).get(path:"/").data.text print "Hello " + world } + } diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index c6c69bddb78..2cf4df88d2d 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -2004,7 +2004,6 @@ the actual port that was allocated for the duration of the tests. [[boot-features-testing-spring-boot-applications-with-spock]] ==== Using Spock to test Spring Boot applications - If you wish to use Spock to test a Spring Boot application you should add a dependency on Spock's `spock-spring` module to your application's build. `spock-spring` integrates Spring's test framework into Spock. diff --git a/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java b/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java index 29c63d06280..eee990238c9 100644 --- a/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java +++ b/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java @@ -72,65 +72,67 @@ public class PropertySourcesPropertyValues implements PropertyValues { this.propertySources = propertySources; PropertySourcesPropertyResolver resolver = new PropertySourcesPropertyResolver( propertySources); - String[] includes = patterns == null ? new String[0] : patterns - .toArray(new String[0]); - String[] exacts = names == null ? new String[0] : names.toArray(new String[0]); + String[] includes = toArray(patterns); + String[] exacts = toArray(names); for (PropertySource source : propertySources) { processPropertySource(source, resolver, includes, exacts); } } + private String[] toArray(Collection strings) { + if (strings == null) { + return new String[0]; + } + return strings.toArray(new String[strings.size()]); + } + private void processPropertySource(PropertySource source, PropertySourcesPropertyResolver resolver, String[] includes, String[] exacts) { if (source instanceof EnumerablePropertySource) { - EnumerablePropertySource enumerable = (EnumerablePropertySource) source; - if (enumerable.getPropertyNames().length > 0) { - for (String propertyName : enumerable.getPropertyNames()) { - if (this.NON_ENUMERABLE_ENUMERABLES.contains(source.getName()) - && !PatternMatchUtils.simpleMatch(includes, propertyName)) { - continue; - } - Object value = source.getProperty(propertyName); - try { - value = resolver.getProperty(propertyName); - } - catch (RuntimeException ex) { - // Probably could not resolve placeholders, ignore it here - } - if (!this.propertyValues.containsKey(propertyName)) { - this.propertyValues.put(propertyName, new PropertyValue( - propertyName, value)); - } - } - } + processEnumerablePropertySource((EnumerablePropertySource) source, + resolver, includes, exacts); } else if (source instanceof CompositePropertySource) { - CompositePropertySource composite = (CompositePropertySource) source; - for (PropertySource nested : extractSources(composite)) { - processPropertySource(nested, resolver, includes, exacts); - } + processCompositePropertySource((CompositePropertySource) source, resolver, + includes, exacts); } else { // We can only do exact matches for non-enumerable property names, but // that's better than nothing... - for (String propertyName : exacts) { - Object value; - value = resolver.getProperty(propertyName); - if (value != null && !this.propertyValues.containsKey(propertyName)) { - this.propertyValues.put(propertyName, new PropertyValue(propertyName, - value)); + processDefaultPropertySource(source, resolver, includes, exacts); + } + } + + private void processEnumerablePropertySource(EnumerablePropertySource source, + PropertySourcesPropertyResolver resolver, String[] includes, String[] exacts) { + if (source.getPropertyNames().length > 0) { + for (String propertyName : source.getPropertyNames()) { + if (this.NON_ENUMERABLE_ENUMERABLES.contains(source.getName()) + && !PatternMatchUtils.simpleMatch(includes, propertyName)) { continue; } - value = source.getProperty(propertyName.toUpperCase()); - if (value != null && !this.propertyValues.containsKey(propertyName)) { + Object value = source.getProperty(propertyName); + try { + value = resolver.getProperty(propertyName); + } + catch (RuntimeException ex) { + // Probably could not resolve placeholders, ignore it here + } + if (!this.propertyValues.containsKey(propertyName)) { this.propertyValues.put(propertyName, new PropertyValue(propertyName, value)); - continue; } } } } + private void processCompositePropertySource(CompositePropertySource source, + PropertySourcesPropertyResolver resolver, String[] includes, String[] exacts) { + for (PropertySource nested : extractSources(source)) { + processPropertySource(nested, resolver, includes, exacts); + } + } + private Collection> extractSources(CompositePropertySource composite) { Field field = ReflectionUtils.findField(CompositePropertySource.class, "propertySources"); @@ -141,9 +143,24 @@ public class PropertySourcesPropertyValues implements PropertyValues { .get(composite); return collection; } - catch (Exception e) { + catch (Exception ex) { throw new IllegalStateException( - "Cannot extract property sources from composite", e); + "Cannot extract property sources from composite", ex); + } + } + + private void processDefaultPropertySource(PropertySource source, + PropertySourcesPropertyResolver resolver, String[] includes, String[] exacts) { + for (String propertyName : exacts) { + Object value = resolver.getProperty(propertyName); + if (value == null) { + value = source.getProperty(propertyName.toUpperCase()); + } + if (value != null && !this.propertyValues.containsKey(propertyName)) { + this.propertyValues.put(propertyName, new PropertyValue(propertyName, + value)); + continue; + } } } diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainer.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainer.java index 2e4df38e457..806ce235d07 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainer.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainer.java @@ -76,17 +76,21 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer { this.server.start(); } catch (Exception ex) { - try { - // Ensure process isn't left running - this.server.stop(); - } - catch (Exception e) { - } + // Ensure process isn't left running + stopSilently(); throw new EmbeddedServletContainerException( "Unable to start embedded Jetty servlet container", ex); } } + private void stopSilently() { + try { + this.server.stop(); + } + catch (Exception ex) { + } + } + @Override public void start() throws EmbeddedServletContainerException { this.server.setConnectors(this.connectors); diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainer.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainer.java index 4a9a93ebf50..0965e9e9d62 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainer.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainer.java @@ -95,7 +95,6 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer this.tomcat.stop(); throw new IllegalStateException("Tomcat connector in failed state"); } - } catch (Exception ex) { throw new EmbeddedServletContainerException( @@ -154,15 +153,19 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer } // Ensure process isn't left running if it actually failed to start if (LifecycleState.FAILED.equals(this.tomcat.getConnector().getState())) { - try { - this.tomcat.stop(); - } - catch (LifecycleException e) { - } + stopSilently(); throw new IllegalStateException("Tomcat connector in failed state"); } } + private void stopSilently() { + try { + this.tomcat.stop(); + } + catch (LifecycleException ex) { + } + } + private void addPreviouslyRemovedConnectors() { Service[] services = this.tomcat.getServer().findServices(); for (Service service : services) { diff --git a/spring-boot/src/main/java/org/springframework/boot/context/web/ErrorPageFilter.java b/spring-boot/src/main/java/org/springframework/boot/context/web/ErrorPageFilter.java index 3a794b33612..0deda7d67b5 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/web/ErrorPageFilter.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/web/ErrorPageFilter.java @@ -77,14 +77,13 @@ class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContainer imple private final Map, String> exceptions = new HashMap, String>(); private final Map, Class> subtypes = new HashMap, Class>(); - - private final OncePerRequestFilter delegate = new OncePerRequestFilter( - ) { - + + private final OncePerRequestFilter delegate = new OncePerRequestFilter() { + @Override protected void doFilterInternal(HttpServletRequest request, - HttpServletResponse response, FilterChain chain) - throws ServletException, IOException { + HttpServletResponse response, FilterChain chain) throws ServletException, + IOException { ErrorPageFilter.this.doFilter(request, response, chain); } @@ -92,13 +91,13 @@ class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContainer imple @Override public void init(FilterConfig filterConfig) throws ServletException { - delegate.init(filterConfig); + this.delegate.init(filterConfig); } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { - delegate.doFilter(request, response, chain); + this.delegate.doFilter(request, response, chain); } private void doFilter(HttpServletRequest request, HttpServletResponse response, diff --git a/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryMapTests.java b/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryMapTests.java index 200092cce3e..530c969d0a5 100644 --- a/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryMapTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryMapTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. diff --git a/spring-boot/src/test/java/org/springframework/boot/context/web/ErrorPageFilterTests.java b/spring-boot/src/test/java/org/springframework/boot/context/web/ErrorPageFilterTests.java index 07419ccb714..4660a90f878 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/web/ErrorPageFilterTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/web/ErrorPageFilterTests.java @@ -16,11 +16,6 @@ package org.springframework.boot.context.web; -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import javax.servlet.RequestDispatcher; @@ -38,6 +33,11 @@ import org.springframework.mock.web.MockFilterConfig; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + /** * Tests for {@link ErrorPageFilter}. * @@ -110,7 +110,7 @@ public class ErrorPageFilterTests { super.doFilter(request, response); } }; - filter.init(new MockFilterConfig("FILTER")); + this.filter.init(new MockFilterConfig("FILTER")); this.filter.doFilter(this.request, this.response, this.chain); }