diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/servlet/CorsEndpointProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/servlet/CorsEndpointProperties.java index 035d330fcc6..88b8aaf9c51 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/servlet/CorsEndpointProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/servlet/CorsEndpointProperties.java @@ -22,7 +22,7 @@ import java.util.ArrayList; import java.util.List; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.bind.convert.DurationUnit; +import org.springframework.boot.context.properties.bind.convert.DefaultDurationUnit; /** * Configuration properties for MVC endpoints' CORS support. @@ -64,7 +64,7 @@ public class CorsEndpointProperties { * How long the response from a pre-flight request can be cached by clients. If a * duration suffix is not specified, seconds will be used. */ - @DurationUnit(ChronoUnit.SECONDS) + @DefaultDurationUnit(ChronoUnit.SECONDS) private Duration maxAge = Duration.ofSeconds(1800); public List getAllowedOrigins() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java index 267db94664d..6a38bd3fd6d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java @@ -24,7 +24,7 @@ import java.util.List; import org.springframework.amqp.core.AcknowledgeMode; import org.springframework.amqp.rabbit.connection.CachingConnectionFactory.CacheMode; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.bind.convert.DurationUnit; +import org.springframework.boot.context.properties.bind.convert.DefaultDurationUnit; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; @@ -80,7 +80,7 @@ public class RabbitProperties { * Requested heartbeat timeout; zero for none. If a duration suffix is not specified, * seconds will be used. */ - @DurationUnit(ChronoUnit.SECONDS) + @DefaultDurationUnit(ChronoUnit.SECONDS) private Duration requestedHeartbeat; /** diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java index 00f66de3006..141047f02b1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java @@ -28,7 +28,7 @@ import com.datastax.driver.core.policies.ReconnectionPolicy; import com.datastax.driver.core.policies.RetryPolicy; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.bind.convert.DurationUnit; +import org.springframework.boot.context.properties.bind.convert.DefaultDurationUnit; /** * Configuration properties for Cassandra. @@ -283,7 +283,7 @@ public class CassandraProperties { * Idle timeout before an idle connection is removed. If a duration suffix is not * specified, seconds will be used. */ - @DurationUnit(ChronoUnit.SECONDS) + @DefaultDurationUnit(ChronoUnit.SECONDS) private Duration idleTimeout = Duration.ofSeconds(120); /** @@ -296,7 +296,7 @@ public class CassandraProperties { * sure it's still alive. If a duration suffix is not specified, seconds will be * used. */ - @DurationUnit(ChronoUnit.SECONDS) + @DefaultDurationUnit(ChronoUnit.SECONDS) private Duration heartbeatInterval = Duration.ofSeconds(30); /** diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/JdbcProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/JdbcProperties.java index 3b27b101136..391084b306b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/JdbcProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/JdbcProperties.java @@ -20,7 +20,7 @@ import java.time.Duration; import java.time.temporal.ChronoUnit; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.bind.convert.DurationUnit; +import org.springframework.boot.context.properties.bind.convert.DefaultDurationUnit; /** * Configuration properties for JDBC. @@ -58,7 +58,7 @@ public class JdbcProperties { * Query timeout. Default is to use the JDBC driver's default configuration. If a * duration suffix is not specified, seconds will be used. */ - @DurationUnit(ChronoUnit.SECONDS) + @DefaultDurationUnit(ChronoUnit.SECONDS) private Duration queryTimeout; public int getFetchSize() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionProperties.java index 1e34489dcea..8d6de0e1a87 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionProperties.java @@ -20,7 +20,7 @@ import java.time.Duration; import java.time.temporal.ChronoUnit; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.bind.convert.DurationUnit; +import org.springframework.boot.context.properties.bind.convert.DefaultDurationUnit; import org.springframework.transaction.support.AbstractPlatformTransactionManager; /** @@ -39,7 +39,7 @@ public class TransactionProperties implements * Default transaction timeout. If a duration suffix is not specified, seconds will be * used. */ - @DurationUnit(ChronoUnit.SECONDS) + @DefaultDurationUnit(ChronoUnit.SECONDS) private Duration defaultTimeout; /** 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 57727a06386..e799775b5bf 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 @@ -21,7 +21,7 @@ import java.time.temporal.ChronoUnit; import java.util.concurrent.TimeUnit; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.bind.convert.DurationUnit; +import org.springframework.boot.context.properties.bind.convert.DefaultDurationUnit; import org.springframework.http.CacheControl; /** @@ -52,7 +52,7 @@ public class ResourceProperties { * If a duration suffix is not specified, seconds will be used. * Can be overridden by the {@code cache-control} property. */ - @DurationUnit(ChronoUnit.SECONDS) + @DefaultDurationUnit(ChronoUnit.SECONDS) private Duration cachePeriod; /** @@ -300,7 +300,7 @@ public class ResourceProperties { * Maximum time the response should be cached, * in seconds if no duration suffix is not specified. */ - @DurationUnit(ChronoUnit.SECONDS) + @DefaultDurationUnit(ChronoUnit.SECONDS) private Duration maxAge; /** @@ -347,21 +347,21 @@ public class ResourceProperties { * Maximum time the response can be served after it becomes stale, * in seconds if no duration suffix is not specified. */ - @DurationUnit(ChronoUnit.SECONDS) + @DefaultDurationUnit(ChronoUnit.SECONDS) private Duration staleWhileRevalidate; /** * Maximum time the response may be used when errors are encountered, * in seconds if no duration suffix is not specified. */ - @DurationUnit(ChronoUnit.SECONDS) + @DefaultDurationUnit(ChronoUnit.SECONDS) private Duration staleIfError; /** * Maximum time the response should be cached by shared caches, * in seconds if no duration suffix is not specified. */ - @DurationUnit(ChronoUnit.SECONDS) + @DefaultDurationUnit(ChronoUnit.SECONDS) private Duration sMaxAge; public Duration getMaxAge() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index aea3ece813f..3320db39a3a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -32,7 +32,7 @@ import java.util.TimeZone; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.NestedConfigurationProperty; -import org.springframework.boot.context.properties.bind.convert.DurationUnit; +import org.springframework.boot.context.properties.bind.convert.DefaultDurationUnit; import org.springframework.boot.web.server.Compression; import org.springframework.boot.web.server.Http2; import org.springframework.boot.web.server.Ssl; @@ -340,7 +340,7 @@ public class ServerProperties { /** * Session timeout. If a duration suffix is not specified, seconds will be used. */ - @DurationUnit(ChronoUnit.SECONDS) + @DefaultDurationUnit(ChronoUnit.SECONDS) private Duration timeout; /** @@ -434,7 +434,7 @@ public class ServerProperties { /** * Maximum age of the session cookie. */ - @DurationUnit(ChronoUnit.SECONDS) + @DefaultDurationUnit(ChronoUnit.SECONDS) private Duration maxAge; public String getName() { @@ -570,7 +570,7 @@ public class ServerProperties { * Delay between the invocation of backgroundProcess methods. If a duration suffix * is not specified, seconds will be used. */ - @DurationUnit(ChronoUnit.SECONDS) + @DefaultDurationUnit(ChronoUnit.SECONDS) private Duration backgroundProcessorDelay = Duration.ofSeconds(30); /** diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/convert/DurationUnit.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/convert/DefaultDurationUnit.java similarity index 97% rename from spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/convert/DurationUnit.java rename to spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/convert/DefaultDurationUnit.java index 4a46c75f2d1..04072f7933d 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/convert/DurationUnit.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/convert/DefaultDurationUnit.java @@ -34,7 +34,7 @@ import java.time.temporal.ChronoUnit; @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) @Documented -public @interface DurationUnit { +public @interface DefaultDurationUnit { /** * The duration unit to use if one is not specified. 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 b2d1d390222..4e53b99830d 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 @@ -77,10 +77,10 @@ class DurationConverter implements GenericConverter { return null; } return toDuration(source.toString(), - targetType.getAnnotation(DurationUnit.class)); + targetType.getAnnotation(DefaultDurationUnit.class)); } - private Duration toDuration(String source, DurationUnit defaultUnit) { + private Duration toDuration(String source, DefaultDurationUnit defaultUnit) { try { if (!StringUtils.hasLength(source)) { return null; @@ -100,7 +100,7 @@ class DurationConverter implements GenericConverter { } } - private ChronoUnit getUnit(String value, DurationUnit defaultUnit) { + private ChronoUnit getUnit(String value, DefaultDurationUnit defaultUnit) { if (StringUtils.isEmpty(value)) { return (defaultUnit != null ? defaultUnit.value() : ChronoUnit.MILLIS); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/narayana/NarayanaProperties.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/narayana/NarayanaProperties.java index befa5711f65..ddd6c3f89d1 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/narayana/NarayanaProperties.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/narayana/NarayanaProperties.java @@ -24,7 +24,7 @@ import java.util.Collections; import java.util.List; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.bind.convert.DurationUnit; +import org.springframework.boot.context.properties.bind.convert.DefaultDurationUnit; /** * Subset of Narayana properties which can be configured via Spring configuration. Use @@ -59,21 +59,21 @@ public class NarayanaProperties { /** * Transaction timeout. If a duration suffix is not specified, seconds will be used. */ - @DurationUnit(ChronoUnit.SECONDS) + @DefaultDurationUnit(ChronoUnit.SECONDS) private Duration defaultTimeout = Duration.ofSeconds(60); /** * Interval in which periodic recovery scans are performed. If a duration suffix is * not specified, seconds will be used. */ - @DurationUnit(ChronoUnit.SECONDS) + @DefaultDurationUnit(ChronoUnit.SECONDS) private Duration periodicRecoveryPeriod = Duration.ofSeconds(120); /** * Back off period between first and second phases of the recovery scan. If a duration * suffix is not specified, seconds will be used. */ - @DurationUnit(ChronoUnit.SECONDS) + @DefaultDurationUnit(ChronoUnit.SECONDS) private Duration recoveryBackoffPeriod = Duration.ofSeconds(10); /** 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 133ec93ced2..751ae8f2f13 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 @@ -138,9 +138,9 @@ public class DurationConverterTests { private Duration convert(String source, ChronoUnit defaultUnit) { TypeDescriptor targetType = mock(TypeDescriptor.class); - DurationUnit annotation = AnnotationUtils.synthesizeAnnotation( - Collections.singletonMap("value", defaultUnit), DurationUnit.class, null); - given(targetType.getAnnotation(DurationUnit.class)).willReturn(annotation); + DefaultDurationUnit annotation = AnnotationUtils.synthesizeAnnotation( + Collections.singletonMap("value", defaultUnit), DefaultDurationUnit.class, null); + given(targetType.getAnnotation(DefaultDurationUnit.class)).willReturn(annotation); return (Duration) this.converter.convert(source, TypeDescriptor.forObject(source), targetType); }