diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java index 7f2591f33f..7f916334fa 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java @@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.PropertyMapper; import org.springframework.boot.context.properties.bind.convert.DefaultDurationUnit; +import org.springframework.http.CacheControl; /** * Properties used to configure resource handling. @@ -458,9 +459,9 @@ public class ResourceProperties { this.sMaxAge = sMaxAge; } - public org.springframework.http.CacheControl toHttpCacheControl() { + public CacheControl toHttpCacheControl() { PropertyMapper map = PropertyMapper.get(); - org.springframework.http.CacheControl control = createCacheControl(); + CacheControl control = createCacheControl(); map.from(this::getMustRevalidate).whenTrue() .toCall(control::mustRevalidate); map.from(this::getNoTransform).whenTrue().toCall(control::noTransform); @@ -478,18 +479,18 @@ public class ResourceProperties { return control; } - private org.springframework.http.CacheControl createCacheControl() { + private CacheControl createCacheControl() { if (Boolean.TRUE.equals(this.noStore)) { - return org.springframework.http.CacheControl.noStore(); + return CacheControl.noStore(); } if (Boolean.TRUE.equals(this.noCache)) { - return org.springframework.http.CacheControl.noCache(); + return CacheControl.noCache(); } if (this.maxAge != null) { - return org.springframework.http.CacheControl + return CacheControl .maxAge(this.maxAge.getSeconds(), TimeUnit.SECONDS); } - return org.springframework.http.CacheControl.empty(); + return CacheControl.empty(); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfigurationTests.java index c1579079ff..0299e944ba 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfigurationTests.java @@ -22,7 +22,6 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashSet; import java.util.Set; -import java.util.TimeZone; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator.Mode; @@ -457,7 +456,7 @@ public class JacksonAutoConfigurationTests { ObjectMapper mapper = this.context.getBean(ObjectMapper.class); DateTime dateTime = new DateTime(1988, 6, 25, 20, 30, DateTimeZone.UTC); String expected = FormatConfig.DEFAULT_DATETIME_PRINTER.rawFormatter() - .withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("UTC"))) + .withZone(DateTimeZone.UTC) .print(dateTime); assertThat(mapper.writeValueAsString(dateTime)).isEqualTo("\"" + expected + "\""); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTests.java index 6e490c06a0..83c117ad76 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTests.java @@ -22,6 +22,7 @@ import org.junit.Test; import org.springframework.boot.autoconfigure.web.ResourceProperties.Cache; import org.springframework.boot.testsupport.assertj.Matched; +import org.springframework.http.CacheControl; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.endsWith; @@ -73,7 +74,7 @@ public class ResourcePropertiesTests { @Test public void emptyCacheControl() { - org.springframework.http.CacheControl cacheControl = this.properties.getCache() + CacheControl cacheControl = this.properties.getCache() .getCachecontrol().toHttpCacheControl(); assertThat(cacheControl.getHeaderValue()).isNull(); } @@ -90,8 +91,7 @@ public class ResourcePropertiesTests { properties.setSMaxAge(Duration.ofSeconds(5)); properties.setStaleIfError(Duration.ofSeconds(6)); properties.setStaleWhileRevalidate(Duration.ofSeconds(7)); - org.springframework.http.CacheControl cacheControl = properties - .toHttpCacheControl(); + CacheControl cacheControl = properties.toHttpCacheControl(); assertThat(cacheControl.getHeaderValue()).isEqualTo( "max-age=4, must-revalidate, no-transform, public, private, proxy-revalidate," + " s-maxage=5, stale-if-error=6, stale-while-revalidate=7"); @@ -102,8 +102,7 @@ public class ResourcePropertiesTests { Cache.Cachecontrol properties = this.properties.getCache().getCachecontrol(); properties.setMaxAge(Duration.ofSeconds(4)); properties.setNoStore(true); - org.springframework.http.CacheControl cacheControl = properties - .toHttpCacheControl(); + CacheControl cacheControl = properties.toHttpCacheControl(); assertThat(cacheControl.getHeaderValue()).isEqualTo("no-store"); } diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/FilteredClassLoaderTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/FilteredClassLoaderTests.java index 17ea64233a..dcbc3a298b 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/FilteredClassLoaderTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/FilteredClassLoaderTests.java @@ -46,9 +46,13 @@ public class FilteredClassLoaderTests { public void loadClassWhenFilteredOnClassShouldThrowClassNotFound() throws Exception { FilteredClassLoader classLoader = new FilteredClassLoader( FilteredClassLoaderTests.class); - this.thrown.expect(ClassNotFoundException.class); - classLoader.loadClass(getClass().getName()); - classLoader.close(); + try { + this.thrown.expect(ClassNotFoundException.class); + classLoader.loadClass(getClass().getName()); + } + finally { + classLoader.close(); + } } @Test diff --git a/spring-boot-project/spring-boot-test/src/test/kotlin/org/springframework/boot/test/web/client/TestRestTemplateExtensionsTests.kt b/spring-boot-project/spring-boot-test/src/test/kotlin/org/springframework/boot/test/web/client/TestRestTemplateExtensionsTests.kt index d9ae59c7fb..8239f05d10 100644 --- a/spring-boot-project/spring-boot-test/src/test/kotlin/org/springframework/boot/test/web/client/TestRestTemplateExtensionsTests.kt +++ b/spring-boot-project/spring-boot-test/src/test/kotlin/org/springframework/boot/test/web/client/TestRestTemplateExtensionsTests.kt @@ -72,7 +72,7 @@ class TestRestTemplateExtensionsTests { } @Test - fun `getForEntity with reified type parameters, String and URI`() { + fun `getForEntity with reified type parameters and URI`() { val url = URI("https://spring.io") template.getForEntity(url) verify(template, times(1)).getForEntity(url, Foo::class.java) @@ -88,7 +88,7 @@ class TestRestTemplateExtensionsTests { } @Test - fun `getForEntity with reified type parameters and Map`() { + fun `getForEntity with reified type parameters, String and Map`() { val url = "https://spring.io" val vars = mapOf(Pair("key1", "value1"), Pair("key2", "value2")) template.getForEntity(url, vars) @@ -96,7 +96,7 @@ class TestRestTemplateExtensionsTests { } @Test - fun `patchForObject with reified type parameters, String and varargs`() { + fun `patchForObject with reified type parameters, String, Any and varargs`() { val url = "https://spring.io" val body: Any = "body" val var1 = "var1" @@ -106,7 +106,7 @@ class TestRestTemplateExtensionsTests { } @Test - fun `patchForObject with reified type parameters, String and Map`() { + fun `patchForObject with reified type parameters, String, Any and Map`() { val url = "https://spring.io" val body: Any = "body" val vars = mapOf(Pair("key1", "value1"), Pair("key2", "value2")) @@ -115,7 +115,7 @@ class TestRestTemplateExtensionsTests { } @Test - fun `patchForObject with reified type parameters`() { + fun `patchForObject with reified type parameters, String and Any`() { val url = "https://spring.io" val body: Any = "body" template.patchForObject(url, body) @@ -123,7 +123,7 @@ class TestRestTemplateExtensionsTests { } @Test - fun `postForObject with reified type parameters, String and varargs`() { + fun `postForObject with reified type parameters, String, Any and varargs`() { val url = "https://spring.io" val body: Any = "body" val var1 = "var1" @@ -133,7 +133,7 @@ class TestRestTemplateExtensionsTests { } @Test - fun `postForObject with reified type parameters, String and Map`() { + fun `postForObject with reified type parameters, String, Any and Map`() { val url = "https://spring.io" val body: Any = "body" val vars = mapOf(Pair("key1", "value1"), Pair("key2", "value2")) @@ -142,7 +142,7 @@ class TestRestTemplateExtensionsTests { } @Test - fun `postForObject with reified type parameters`() { + fun `postForObject with reified type parameters, String and Any`() { val url = "https://spring.io" val body: Any = "body" template.postForObject(url, body) @@ -150,7 +150,7 @@ class TestRestTemplateExtensionsTests { } @Test - fun `postForEntity with reified type parameters, String and varargs`() { + fun `postForEntity with reified type parameters, String, Any and varargs`() { val url = "https://spring.io" val body: Any = "body" val var1 = "var1" @@ -160,7 +160,7 @@ class TestRestTemplateExtensionsTests { } @Test - fun `postForEntity with reified type parameters, String and Map`() { + fun `postForEntity with reified type parameters, String, Any and Map`() { val url = "https://spring.io" val body: Any = "body" val vars = mapOf(Pair("key1", "value1"), Pair("key2", "value2")) @@ -169,7 +169,7 @@ class TestRestTemplateExtensionsTests { } @Test - fun `postForEntity with reified type parameters`() { + fun `postForEntity with reified type parameters, String and Any`() { val url = "https://spring.io" val body: Any = "body" template.postForEntity(url, body) @@ -210,7 +210,7 @@ class TestRestTemplateExtensionsTests { } @Test - fun `exchange with reified type parameters, String, HttpEntity`() { + fun `exchange with reified type parameters and HttpEntity`() { val entity = mock>() template.exchange>(entity) verify(template, times(1)).exchange(entity, diff --git a/spring-boot-project/spring-boot/pom.xml b/spring-boot-project/spring-boot/pom.xml index 6a106b9e21..8654c69ba2 100644 --- a/spring-boot-project/spring-boot/pom.xml +++ b/spring-boot-project/spring-boot/pom.xml @@ -267,12 +267,12 @@ org.jetbrains.kotlin - kotlin-stdlib + kotlin-reflect true org.jetbrains.kotlin - kotlin-reflect + kotlin-stdlib true diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/PropertyMapper.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/PropertyMapper.java index 511fff9f22..7d05a2c4ef 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/PropertyMapper.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/PropertyMapper.java @@ -29,7 +29,7 @@ import org.springframework.util.StringUtils; /** * Utility that can be used to map values from a supplied source to a destination. * Primarily intended to be help when mapping from - * {@link ConfigurationProperties @ConfigrationProperties} to third-party classes. + * {@link ConfigurationProperties @ConfigurationProperties} to third-party classes. *

* Can filter values based on predicates and adapt values if needed. For example: *

@@ -176,7 +176,7 @@ public final class PropertyMapper {
 		private final Predicate predicate;
 
 		private Source(Supplier supplier, Predicate predicate) {
-			Assert.notNull(predicate, "Arse");
+			Assert.notNull(predicate, "Predicate must not be null");
 			this.supplier = supplier;
 			this.predicate = predicate;
 		}
diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/convert/DurationConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/convert/DurationConverter.java
index 1084a1fd67..916fd3dede 100644
--- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/convert/DurationConverter.java
+++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/convert/DurationConverter.java
@@ -49,9 +49,9 @@ class DurationConverter implements GenericConverter {
 		TYPES = Collections.unmodifiableSet(types);
 	}
 
-	private static Pattern ISO8601 = Pattern.compile("^[\\+\\-]?P.*$");
+	private static final Pattern ISO8601 = Pattern.compile("^[\\+\\-]?P.*$");
 
-	private static Pattern SIMPLE = Pattern.compile("^([\\+\\-]?\\d+)([a-zA-Z]{0,2})$");
+	private static final Pattern SIMPLE = Pattern.compile("^([\\+\\-]?\\d+)([a-zA-Z]{0,2})$");
 
 	private static final Map UNITS;
 
diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/convert/DurationConverterTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/convert/DurationConverterTests.java
index 7742fea0d7..ccfc89ffb9 100644
--- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/convert/DurationConverterTests.java
+++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/convert/DurationConverterTests.java
@@ -51,7 +51,6 @@ public class DurationConverterTests {
 		assertThat(convert("PT10H")).isEqualTo(Duration.parse("PT10H"));
 		assertThat(convert("P2D")).isEqualTo(Duration.parse("P2D"));
 		assertThat(convert("P2DT3H4M")).isEqualTo(Duration.parse("P2DT3H4M"));
-		assertThat(convert("P2DT3H4M")).isEqualTo(Duration.parse("P2DT3H4M"));
 		assertThat(convert("-PT6H3M")).isEqualTo(Duration.parse("-PT6H3M"));
 		assertThat(convert("-PT-6H+3M")).isEqualTo(Duration.parse("-PT-6H+3M"));
 	}