Update configuration properties to use Duration

Update appropriate configuration properties to use the `Duration`
type, rather than an ad-hoc mix of milliseconds or seconds.

Configuration properties can now be defined in a consistent and readable
way. For example `server.session.timeout=5m`.

Properties that were previously declared using seconds are annotated
with `@DurationUnit` to ensure a smooth upgrade experience. For example
`server.session.timeout=20` continues to mean 20 seconds.

Fixes gh-11080
This commit is contained in:
Phillip Webb 2017-11-19 21:03:26 -08:00
parent cbaf0fa686
commit 8f4bf233b4
69 changed files with 714 additions and 519 deletions

View File

@ -16,6 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.elasticsearch;
import java.time.Duration;
import java.util.Map;
import io.searchbox.client.JestClient;
@ -77,8 +78,10 @@ public class ElasticsearchHealthIndicatorAutoConfiguration {
@Override
protected ElasticsearchHealthIndicator createHealthIndicator(Client client) {
Duration responseTimeout = this.properties.getResponseTimeout();
return new ElasticsearchHealthIndicator(client,
this.properties.getResponseTimeout(), this.properties.getIndices());
responseTimeout == null ? 100 : responseTimeout.toMillis(),
this.properties.getIndices());
}
}

View File

@ -16,6 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.elasticsearch;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
@ -38,9 +39,9 @@ public class ElasticsearchHealthIndicatorProperties {
private List<String> indices = new ArrayList<>();
/**
* Time, in milliseconds, to wait for a response from the cluster.
* Time to wait for a response from the cluster.
*/
private long responseTimeout = 100L;
private Duration responseTimeout = Duration.ofMillis(100);
public List<String> getIndices() {
return this.indices;
@ -50,11 +51,11 @@ public class ElasticsearchHealthIndicatorProperties {
this.indices = indices;
}
public long getResponseTimeout() {
public Duration getResponseTimeout() {
return this.responseTimeout;
}
public void setResponseTimeout(long responseTimeout) {
public void setResponseTimeout(Duration responseTimeout) {
this.responseTimeout = responseTimeout;
}

View File

@ -16,9 +16,14 @@
package org.springframework.boot.actuate.autoconfigure.endpoint;
import java.time.Duration;
import java.util.function.Function;
import org.springframework.boot.actuate.endpoint.cache.CachingOperationInvokerAdvisor;
import org.springframework.boot.context.properties.bind.BindResult;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.core.env.Environment;
import org.springframework.core.env.PropertyResolver;
/**
@ -30,20 +35,24 @@ import org.springframework.core.env.PropertyResolver;
*/
class EndpointIdTimeToLivePropertyFunction implements Function<String, Long> {
private final PropertyResolver propertyResolver;
private static final Bindable<Duration> DURATION = Bindable.of(Duration.class);
private final Environment environment;
/**
* Create a new instance with the {@link PropertyResolver} to use.
* @param propertyResolver the environment
* @param environment the environment
*/
EndpointIdTimeToLivePropertyFunction(PropertyResolver propertyResolver) {
this.propertyResolver = propertyResolver;
EndpointIdTimeToLivePropertyFunction(Environment environment) {
this.environment = environment;
}
@Override
public Long apply(String endpointId) {
String key = String.format("management.endpoint.%s.cache.time-to-live",
String name = String.format("management.endpoint.%s.cache.time-to-live",
endpointId);
return this.propertyResolver.getProperty(key, Long.class);
BindResult<Duration> duration = Binder.get(this.environment).bind(name, DURATION);
return duration.map(Duration::toMillis).orElse(null);
}
}

View File

@ -16,10 +16,13 @@
package org.springframework.boot.actuate.autoconfigure.endpoint.web.servlet;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.bind.convert.DurationUnit;
/**
* Configuration properties for MVC endpoints' CORS support.
@ -58,10 +61,11 @@ public class CorsEndpointProperties {
private Boolean allowCredentials;
/**
* How long, in seconds, the response from a pre-flight request can be cached by
* clients.
* 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.
*/
private Long maxAge = 1800L;
@DurationUnit(ChronoUnit.SECONDS)
private Duration maxAge = Duration.ofSeconds(1800);
public List<String> getAllowedOrigins() {
return this.allowedOrigins;
@ -103,11 +107,11 @@ public class CorsEndpointProperties {
this.allowCredentials = allowCredentials;
}
public Long getMaxAge() {
public Duration getMaxAge() {
return this.maxAge;
}
public void setMaxAge(Long maxAge) {
public void setMaxAge(Duration maxAge) {
this.maxAge = maxAge;
}

View File

@ -78,7 +78,7 @@ public class WebMvcEndpointManagementContextConfiguration {
configuration.setExposedHeaders(properties.getExposedHeaders());
}
if (properties.getMaxAge() != null) {
configuration.setMaxAge(properties.getMaxAge());
configuration.setMaxAge(properties.getMaxAge().getSeconds());
}
if (properties.getAllowCredentials() != null) {
configuration.setAllowCredentials(properties.getAllowCredentials());

View File

@ -100,7 +100,7 @@ public abstract class AbstractRabbitListenerContainerFactoryConfigurer<T extends
factory.setDefaultRequeueRejected(configuration.getDefaultRequeueRejected());
}
if (configuration.getIdleEventInterval() != null) {
factory.setIdleEventInterval(configuration.getIdleEventInterval());
factory.setIdleEventInterval(configuration.getIdleEventInterval().toMillis());
}
ListenerRetry retryConfig = configuration.getRetry();
if (retryConfig.isEnabled()) {

View File

@ -105,7 +105,8 @@ public class RabbitAutoConfiguration {
factory.setVirtualHost(config.determineVirtualHost());
}
if (config.getRequestedHeartbeat() != null) {
factory.setRequestedHeartbeat(config.getRequestedHeartbeat());
factory.setRequestedHeartbeat(
(int) config.getRequestedHeartbeat().getSeconds());
}
RabbitProperties.Ssl ssl = config.getSsl();
if (ssl.isEnabled()) {
@ -121,7 +122,8 @@ public class RabbitAutoConfiguration {
factory.setTrustStorePassphrase(ssl.getTrustStorePassword());
}
if (config.getConnectionTimeout() != null) {
factory.setConnectionTimeout(config.getConnectionTimeout());
factory.setConnectionTimeout(
(int) config.getConnectionTimeout().toMillis());
}
factory.afterPropertiesSet();
CachingConnectionFactory connectionFactory = new CachingConnectionFactory(

View File

@ -16,12 +16,15 @@
package org.springframework.boot.autoconfigure.amqp;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
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.util.CollectionUtils;
import org.springframework.util.StringUtils;
@ -74,9 +77,11 @@ public class RabbitProperties {
private String addresses;
/**
* Requested heartbeat timeout, in seconds; zero for none.
* Requested heartbeat timeout; zero for none. If a duration suffix is not specified,
* seconds will be used.
*/
private Integer requestedHeartbeat;
@DurationUnit(ChronoUnit.SECONDS)
private Duration requestedHeartbeat;
/**
* Enable publisher confirms.
@ -89,9 +94,9 @@ public class RabbitProperties {
private boolean publisherReturns;
/**
* Connection timeout, in milliseconds; zero for infinite.
* Connection timeout; zero for infinite.
*/
private Integer connectionTimeout;
private Duration connectionTimeout;
/**
* Cache configuration.
@ -258,11 +263,11 @@ public class RabbitProperties {
this.virtualHost = ("".equals(virtualHost) ? "/" : virtualHost);
}
public Integer getRequestedHeartbeat() {
public Duration getRequestedHeartbeat() {
return this.requestedHeartbeat;
}
public void setRequestedHeartbeat(Integer requestedHeartbeat) {
public void setRequestedHeartbeat(Duration requestedHeartbeat) {
this.requestedHeartbeat = requestedHeartbeat;
}
@ -282,11 +287,11 @@ public class RabbitProperties {
this.publisherReturns = publisherReturns;
}
public Integer getConnectionTimeout() {
public Duration getConnectionTimeout() {
return this.connectionTimeout;
}
public void setConnectionTimeout(Integer connectionTimeout) {
public void setConnectionTimeout(Duration connectionTimeout) {
this.connectionTimeout = connectionTimeout;
}
@ -557,9 +562,9 @@ public class RabbitProperties {
private Boolean defaultRequeueRejected;
/**
* How often idle container events should be published in milliseconds.
* How often idle container events should be published.
*/
private Long idleEventInterval;
private Duration idleEventInterval;
/**
* Optional properties for a retry interceptor.
@ -598,11 +603,11 @@ public class RabbitProperties {
this.defaultRequeueRejected = defaultRequeueRejected;
}
public Long getIdleEventInterval() {
public Duration getIdleEventInterval() {
return this.idleEventInterval;
}
public void setIdleEventInterval(Long idleEventInterval) {
public void setIdleEventInterval(Duration idleEventInterval) {
this.idleEventInterval = idleEventInterval;
}

View File

@ -16,9 +16,9 @@
package org.springframework.boot.autoconfigure.cache;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.core.io.Resource;
@ -141,24 +141,16 @@ public class CacheProperties {
public static class Couchbase {
/**
* Entry expiration in milliseconds. By default the entries never expire. Note
* that this value is ultimately converted to seconds.
* Entry expiration. By default the entries never expire. Note that this value is
* ultimately converted to seconds.
*/
private int expiration;
private Duration expiration;
public int getExpiration() {
public Duration getExpiration() {
return this.expiration;
}
/**
* Return the expiration in seconds.
* @return the expiration in seconds
*/
public int getExpirationSeconds() {
return (int) TimeUnit.MILLISECONDS.toSeconds(this.expiration);
}
public void setExpiration(int expiration) {
public void setExpiration(Duration expiration) {
this.expiration = expiration;
}
@ -246,9 +238,9 @@ public class CacheProperties {
public static class Redis {
/**
* Entry expiration in milliseconds. By default the entries never expire.
* Entry expiration. By default the entries never expire.
*/
private long timeToLive = 0;
private Duration timeToLive;
/**
* Allow caching null values.
@ -265,11 +257,11 @@ public class CacheProperties {
*/
private boolean useKeyPrefix = true;
public long getTimeToLive() {
public Duration getTimeToLive() {
return this.timeToLive;
}
public void setTimeToLive(long timeToLive) {
public void setTimeToLive(Duration timeToLive) {
this.timeToLive = timeToLive;
}

View File

@ -16,6 +16,7 @@
package org.springframework.boot.autoconfigure.cache;
import java.time.Duration;
import java.util.List;
import com.couchbase.client.java.Bucket;
@ -59,11 +60,13 @@ public class CouchbaseCacheConfiguration {
@Bean
public CouchbaseCacheManager cacheManager() {
List<String> cacheNames = this.cacheProperties.getCacheNames();
CouchbaseCacheManager cacheManager = new CouchbaseCacheManager(
CacheBuilder.newInstance(this.bucket)
.withExpiration(this.cacheProperties.getCouchbase()
.getExpirationSeconds()),
cacheNames.toArray(new String[cacheNames.size()]));
CacheBuilder builder = CacheBuilder.newInstance(this.bucket);
Duration expiration = this.cacheProperties.getCouchbase().getExpiration();
if (expiration != null) {
builder = builder.withExpiration((int) expiration.getSeconds());
}
String[] names = cacheNames.toArray(new String[cacheNames.size()]);
CouchbaseCacheManager cacheManager = new CouchbaseCacheManager(builder, names);
return this.customizers.customize(cacheManager);
}

View File

@ -16,7 +16,6 @@
package org.springframework.boot.autoconfigure.cache;
import java.time.Duration;
import java.util.LinkedHashSet;
import java.util.List;
@ -73,7 +72,9 @@ class RedisCacheConfiguration {
Redis redisProperties = this.cacheProperties.getRedis();
org.springframework.data.redis.cache.RedisCacheConfiguration config = org.springframework.data.redis.cache.RedisCacheConfiguration
.defaultCacheConfig();
config = config.entryTtl(Duration.ofMillis(redisProperties.getTimeToLive()));
if (redisProperties.getTimeToLive() != null) {
config = config.entryTtl(redisProperties.getTimeToLive());
}
if (redisProperties.getKeyPrefix() != null) {
config = config.prefixKeysWith(redisProperties.getKeyPrefix());
}

View File

@ -125,17 +125,30 @@ public class CassandraAutoConfiguration {
private SocketOptions getSocketOptions() {
SocketOptions options = new SocketOptions();
options.setConnectTimeoutMillis(this.properties.getConnectTimeoutMillis());
options.setReadTimeoutMillis(this.properties.getReadTimeoutMillis());
if (this.properties.getConnectTimeout() != null) {
options.setConnectTimeoutMillis(
(int) this.properties.getConnectTimeout().toMillis());
}
if (this.properties.getReadTimeout() != null) {
options.setReadTimeoutMillis(
(int) this.properties.getReadTimeout().toMillis());
}
return options;
}
private PoolingOptions getPoolingOptions() {
CassandraProperties.Pool pool = this.properties.getPool();
PoolingOptions options = new PoolingOptions();
options.setIdleTimeoutSeconds(pool.getIdleTimeout());
options.setPoolTimeoutMillis(pool.getPoolTimeout());
options.setHeartbeatIntervalSeconds(pool.getHeartbeatInterval());
if (pool.getIdleTimeout() != null) {
options.setIdleTimeoutSeconds((int) pool.getIdleTimeout().getSeconds());
}
if (pool.getPoolTimeout() != null) {
options.setPoolTimeoutMillis((int) pool.getPoolTimeout().toMillis());
}
if (pool.getHeartbeatInterval() != null) {
options.setHeartbeatIntervalSeconds(
(int) pool.getHeartbeatInterval().getSeconds());
}
options.setMaxQueueSize(pool.getMaxQueueSize());
return options;
}

View File

@ -16,16 +16,19 @@
package org.springframework.boot.autoconfigure.cassandra;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import com.datastax.driver.core.ConsistencyLevel;
import com.datastax.driver.core.ProtocolOptions;
import com.datastax.driver.core.ProtocolOptions.Compression;
import com.datastax.driver.core.QueryOptions;
import com.datastax.driver.core.SocketOptions;
import com.datastax.driver.core.policies.LoadBalancingPolicy;
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;
/**
* Configuration properties for Cassandra.
@ -107,12 +110,12 @@ public class CassandraProperties {
/**
* Socket option: connection time out.
*/
private int connectTimeoutMillis = SocketOptions.DEFAULT_CONNECT_TIMEOUT_MILLIS;
private Duration connectTimeout;
/**
* Socket option: read time out.
*/
private int readTimeoutMillis = SocketOptions.DEFAULT_READ_TIMEOUT_MILLIS;
private Duration readTimeout;
/**
* Schema action to take at startup.
@ -235,20 +238,20 @@ public class CassandraProperties {
this.retryPolicy = retryPolicy;
}
public int getConnectTimeoutMillis() {
return this.connectTimeoutMillis;
public Duration getConnectTimeout() {
return this.connectTimeout;
}
public void setConnectTimeoutMillis(int connectTimeoutMillis) {
this.connectTimeoutMillis = connectTimeoutMillis;
public void setConnectTimeout(Duration connectTimeout) {
this.connectTimeout = connectTimeout;
}
public int getReadTimeoutMillis() {
return this.readTimeoutMillis;
public Duration getReadTimeout() {
return this.readTimeout;
}
public void setReadTimeoutMillis(int readTimeoutMillis) {
this.readTimeoutMillis = readTimeoutMillis;
public void setReadTimeout(Duration readTimeout) {
this.readTimeout = readTimeout;
}
public boolean isSsl() {
@ -277,48 +280,51 @@ public class CassandraProperties {
public static class Pool {
/**
* Idle timeout (in seconds) before an idle connection is removed.
* Idle timeout before an idle connection is removed. If a duration suffix is not
* specified, seconds will be used.
*/
private int idleTimeout = 120;
@DurationUnit(ChronoUnit.SECONDS)
private Duration idleTimeout = Duration.ofSeconds(120);
/**
* Pool timeout (in milliseconds) when trying to acquire a connection from a
* host's pool.
* Pool timeout when trying to acquire a connection from a host's pool.
*/
private int poolTimeout = 5000;
private Duration poolTimeout = Duration.ofMillis(5000);
/**
* Heartbeat interval (in seconds) after which a message is sent on an idle
* connection to make sure it's still alive.
* Heartbeat interval after which a message is sent on an idle connection to make
* sure it's still alive. If a duration suffix is not specified, seconds will be
* used.
*/
private int heartbeatInterval = 30;
@DurationUnit(ChronoUnit.SECONDS)
private Duration heartbeatInterval = Duration.ofSeconds(30);
/**
* Maximum number of requests that get enqueued if no connection is available.
*/
private int maxQueueSize = 256;
public int getIdleTimeout() {
public Duration getIdleTimeout() {
return this.idleTimeout;
}
public void setIdleTimeout(int idleTimeout) {
public void setIdleTimeout(Duration idleTimeout) {
this.idleTimeout = idleTimeout;
}
public int getPoolTimeout() {
public Duration getPoolTimeout() {
return this.poolTimeout;
}
public void setPoolTimeout(int poolTimeout) {
public void setPoolTimeout(Duration poolTimeout) {
this.poolTimeout = poolTimeout;
}
public int getHeartbeatInterval() {
public Duration getHeartbeatInterval() {
return this.heartbeatInterval;
}
public void setHeartbeatInterval(int heartbeatInterval) {
public void setHeartbeatInterval(Duration heartbeatInterval) {
this.heartbeatInterval = heartbeatInterval;
}

View File

@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.context;
import java.time.Duration;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
@ -73,7 +75,9 @@ public class MessageSourceAutoConfiguration {
messageSource.setDefaultEncoding(properties.getEncoding().name());
}
messageSource.setFallbackToSystemLocale(properties.isFallbackToSystemLocale());
messageSource.setCacheSeconds(properties.getCacheSeconds());
Duration cacheDuration = properties.getCacheDuration();
messageSource.setCacheSeconds(
cacheDuration == null ? -1 : (int) cacheDuration.getSeconds());
messageSource.setAlwaysUseMessageFormat(properties.isAlwaysUseMessageFormat());
messageSource.setUseCodeAsDefaultMessage(properties.isUseCodeAsDefaultMessage());
return messageSource;

View File

@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.context;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
/**
* Configuration properties for Message Source.
@ -41,10 +42,10 @@ public class MessageSourceProperties {
private Charset encoding = StandardCharsets.UTF_8;
/**
* Loaded resource bundle files cache expiration, in seconds. When set to -1, bundles
* Loaded resource bundle files cache expiration, in seconds. When not set, bundles
* are cached forever.
*/
private int cacheSeconds = -1;
private Duration cacheDuration;
/**
* Set whether to fall back to the system Locale if no files for a specific Locale
@ -81,12 +82,12 @@ public class MessageSourceProperties {
this.encoding = encoding;
}
public int getCacheSeconds() {
return this.cacheSeconds;
public Duration getCacheDuration() {
return this.cacheDuration;
}
public void setCacheSeconds(int cacheSeconds) {
this.cacheSeconds = cacheSeconds;
public void setCacheDuration(Duration cacheDuration) {
this.cacheDuration = cacheDuration;
}
public boolean isFallbackToSystemLocale() {

View File

@ -98,13 +98,26 @@ public class CouchbaseAutoConfiguration {
CouchbaseProperties.Endpoints endpoints = properties.getEnv().getEndpoints();
CouchbaseProperties.Timeouts timeouts = properties.getEnv().getTimeouts();
DefaultCouchbaseEnvironment.Builder builder = DefaultCouchbaseEnvironment
.builder().connectTimeout(timeouts.getConnect())
.kvEndpoints(endpoints.getKeyValue())
.kvTimeout(timeouts.getKeyValue())
.queryEndpoints(endpoints.getQuery())
.queryTimeout(timeouts.getQuery()).viewEndpoints(endpoints.getView())
.socketConnectTimeout(timeouts.getSocketConnect())
.viewTimeout(timeouts.getView());
.builder();
if (timeouts.getConnect() != null) {
builder = builder.connectTimeout(timeouts.getConnect().toMillis());
}
builder = builder.kvEndpoints(endpoints.getKeyValue());
if (timeouts.getKeyValue() != null) {
builder = builder.kvTimeout(timeouts.getKeyValue().toMillis());
}
builder = builder.queryEndpoints(endpoints.getQuery());
if (timeouts.getQuery() != null) {
builder = builder.queryTimeout(timeouts.getQuery().toMillis())
.viewEndpoints(endpoints.getView());
}
if (timeouts.getSocketConnect() != null) {
builder = builder.socketConnectTimeout(
(int) timeouts.getSocketConnect().toMillis());
}
if (timeouts.getView() != null) {
builder = builder.viewTimeout(timeouts.getView().toMillis());
}
CouchbaseProperties.Ssl ssl = properties.getEnv().getSsl();
if (ssl.getEnabled()) {
builder.sslEnabled(true);

View File

@ -16,6 +16,7 @@
package org.springframework.boot.autoconfigure.couchbase;
import java.time.Duration;
import java.util.List;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ -199,67 +200,67 @@ public class CouchbaseProperties {
public static class Timeouts {
/**
* Bucket connections timeout in milliseconds.
* Bucket connections timeout.
*/
private long connect = 5000;
private Duration connect = Duration.ofMillis(5000);
/**
* Blocking operations performed on a specific key timeout in milliseconds.
* Blocking operations performed on a specific key timeout.
*/
private long keyValue = 2500;
private Duration keyValue = Duration.ofMillis(2500);
/**
* N1QL query operations timeout in milliseconds.
* N1QL query operations timeout.
*/
private long query = 7500;
private Duration query = Duration.ofMillis(7500);
/**
* Socket connect connections timeout in milliseconds.
* Socket connect connections timeout.
*/
private int socketConnect = 1000;
private Duration socketConnect = Duration.ofMillis(1000);
/**
* Regular and geospatial view operations timeout in milliseconds.
* Regular and geospatial view operations timeout.
*/
private long view = 7500;
private Duration view = Duration.ofMillis(7500);
public long getConnect() {
public Duration getConnect() {
return this.connect;
}
public void setConnect(long connect) {
public void setConnect(Duration connect) {
this.connect = connect;
}
public long getKeyValue() {
public Duration getKeyValue() {
return this.keyValue;
}
public void setKeyValue(long keyValue) {
public void setKeyValue(Duration keyValue) {
this.keyValue = keyValue;
}
public long getQuery() {
public Duration getQuery() {
return this.query;
}
public void setQuery(long query) {
public void setQuery(Duration query) {
this.query = query;
}
public int getSocketConnect() {
public Duration getSocketConnect() {
return this.socketConnect;
}
public void setSocketConnect(int socketConnect) {
public void setSocketConnect(Duration socketConnect) {
this.socketConnect = socketConnect;
}
public long getView() {
public Duration getView() {
return this.view;
}
public void setView(long view) {
public void setView(Duration view) {
this.view = view;
}

View File

@ -100,8 +100,8 @@ class JedisConnectionConfiguration extends RedisConnectionConfiguration {
if (this.properties.isSsl()) {
builder.useSsl();
}
if (this.properties.getTimeout() != 0) {
Duration timeout = Duration.ofMillis(this.properties.getTimeout());
if (this.properties.getTimeout() != null) {
Duration timeout = this.properties.getTimeout();
builder.readTimeout(timeout).connectTimeout(timeout);
}
return builder;
@ -117,7 +117,9 @@ class JedisConnectionConfiguration extends RedisConnectionConfiguration {
config.setMaxTotal(pool.getMaxActive());
config.setMaxIdle(pool.getMaxIdle());
config.setMinIdle(pool.getMinIdle());
config.setMaxWaitMillis(pool.getMaxWait());
if (pool.getMaxWait() != null) {
config.setMaxWaitMillis(pool.getMaxWait().toMillis());
}
return config;
}

View File

@ -17,7 +17,6 @@
package org.springframework.boot.autoconfigure.data.redis;
import java.net.UnknownHostException;
import java.time.Duration;
import java.util.Collections;
import java.util.List;
@ -116,14 +115,15 @@ class LettuceConnectionConfiguration extends RedisConnectionConfiguration {
if (this.properties.isSsl()) {
builder.useSsl();
}
if (this.properties.getTimeout() != 0) {
builder.commandTimeout(Duration.ofMillis(this.properties.getTimeout()));
if (this.properties.getTimeout() != null) {
builder.commandTimeout(this.properties.getTimeout());
}
if (this.properties.getLettuce() != null) {
RedisProperties.Lettuce lettuce = this.properties.getLettuce();
if (lettuce.getShutdownTimeout() >= 0) {
builder.shutdownTimeout(Duration
.ofMillis(this.properties.getLettuce().getShutdownTimeout()));
if (lettuce.getShutdownTimeout() != null
&& !lettuce.getShutdownTimeout().isZero()) {
builder.shutdownTimeout(
this.properties.getLettuce().getShutdownTimeout());
}
}
return builder;
@ -159,7 +159,9 @@ class LettuceConnectionConfiguration extends RedisConnectionConfiguration {
config.setMaxTotal(properties.getMaxActive());
config.setMaxIdle(properties.getMaxIdle());
config.setMinIdle(properties.getMinIdle());
config.setMaxWaitMillis(properties.getMaxWait());
if (properties.getMaxWait() != null) {
config.setMaxWaitMillis(properties.getMaxWait().toMillis());
}
return config;
}

View File

@ -16,6 +16,7 @@
package org.springframework.boot.autoconfigure.data.redis;
import java.time.Duration;
import java.util.List;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ -64,9 +65,9 @@ public class RedisProperties {
private boolean ssl;
/**
* Connection timeout in milliseconds.
* Connection timeout.
*/
private int timeout;
private Duration timeout;
private Sentinel sentinel;
@ -124,11 +125,11 @@ public class RedisProperties {
this.ssl = ssl;
}
public void setTimeout(int timeout) {
public void setTimeout(Duration timeout) {
this.timeout = timeout;
}
public int getTimeout() {
public Duration getTimeout() {
return this.timeout;
}
@ -180,11 +181,11 @@ public class RedisProperties {
private int maxActive = 8;
/**
* Maximum amount of time (in milliseconds) a connection allocation should block
* before throwing an exception when the pool is exhausted. Use a negative value
* to block indefinitely.
* Maximum amount of time a connection allocation should block before throwing an
* exception when the pool is exhausted. Use a negative value to block
* indefinitely.
*/
private int maxWait = -1;
private Duration maxWait = Duration.ofMillis(-1);
public int getMaxIdle() {
return this.maxIdle;
@ -210,11 +211,11 @@ public class RedisProperties {
this.maxActive = maxActive;
}
public int getMaxWait() {
public Duration getMaxWait() {
return this.maxWait;
}
public void setMaxWait(int maxWait) {
public void setMaxWait(Duration maxWait) {
this.maxWait = maxWait;
}
@ -314,20 +315,20 @@ public class RedisProperties {
public static class Lettuce {
/**
* Shutdown timeout in milliseconds.
* Shutdown timeout.
*/
private int shutdownTimeout = 100;
private Duration shutdownTimeout = Duration.ofMillis(100);
/**
* Lettuce pool configuration.
*/
private Pool pool;
public int getShutdownTimeout() {
public Duration getShutdownTimeout() {
return this.shutdownTimeout;
}
public void setShutdownTimeout(int shutdownTimeout) {
public void setShutdownTimeout(Duration shutdownTimeout) {
this.shutdownTimeout = shutdownTimeout;
}

View File

@ -87,8 +87,12 @@ public class JestAutoConfiguration {
builder.gson(gson);
}
builder.multiThreaded(this.properties.isMultiThreaded());
builder.connTimeout(this.properties.getConnectionTimeout())
.readTimeout(this.properties.getReadTimeout());
if (this.properties.getConnectionTimeout() != null) {
builder.connTimeout((int) this.properties.getConnectionTimeout().toMillis());
}
if (this.properties.getReadTimeout() != null) {
builder.readTimeout((int) this.properties.getReadTimeout().toMillis());
}
customize(builder);
return builder.build();
}

View File

@ -16,6 +16,7 @@
package org.springframework.boot.autoconfigure.elasticsearch.jest;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -53,14 +54,14 @@ public class JestProperties {
private boolean multiThreaded = true;
/**
* Connection timeout in milliseconds.
* Connection timeout.
*/
private int connectionTimeout = 3000;
private Duration connectionTimeout = Duration.ofSeconds(3);
/**
* Read timeout in milliseconds.
* Read timeout.
*/
private int readTimeout = 3000;
private Duration readTimeout = Duration.ofSeconds(3);
/**
* Proxy settings.
@ -99,19 +100,19 @@ public class JestProperties {
this.multiThreaded = multiThreaded;
}
public int getConnectionTimeout() {
public Duration getConnectionTimeout() {
return this.connectionTimeout;
}
public void setConnectionTimeout(int connectionTimeout) {
public void setConnectionTimeout(Duration connectionTimeout) {
this.connectionTimeout = connectionTimeout;
}
public int getReadTimeout() {
public Duration getReadTimeout() {
return this.readTimeout;
}
public void setReadTimeout(int readTimeout) {
public void setReadTimeout(Duration readTimeout) {
this.readTimeout = readTimeout;
}

View File

@ -16,7 +16,11 @@
package org.springframework.boot.autoconfigure.jdbc;
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;
/**
* Configuration properties for JDBC.
@ -51,10 +55,11 @@ public class JdbcProperties {
private int maxRows = -1;
/**
* Query timeout in seconds. Use -1 to use the JDBC driver's default
* configuration.
* Query timeout. Default is to use the JDBC driver's default configuration. If a
* duration suffix is not specified, seconds will be used.
*/
private int queryTimeout = -1;
@DurationUnit(ChronoUnit.SECONDS)
private Duration queryTimeout;
public int getFetchSize() {
return this.fetchSize;
@ -72,11 +77,11 @@ public class JdbcProperties {
this.maxRows = maxRows;
}
public int getQueryTimeout() {
public Duration getQueryTimeout() {
return this.queryTimeout;
}
public void setQueryTimeout(int queryTimeout) {
public void setQueryTimeout(Duration queryTimeout) {
this.queryTimeout = queryTimeout;
}

View File

@ -70,7 +70,10 @@ public class JdbcTemplateAutoConfiguration {
JdbcProperties.Template template = this.properties.getTemplate();
jdbcTemplate.setFetchSize(template.getFetchSize());
jdbcTemplate.setMaxRows(template.getMaxRows());
jdbcTemplate.setQueryTimeout(template.getQueryTimeout());
if (template.getQueryTimeout() != null) {
jdbcTemplate
.setQueryTimeout((int) template.getQueryTimeout().getSeconds());
}
return jdbcTemplate;
}

View File

@ -84,7 +84,7 @@ public class JmsAutoConfiguration {
jmsTemplate.setDefaultDestinationName(template.getDefaultDestination());
}
if (template.getDeliveryDelay() != null) {
jmsTemplate.setDeliveryDelay(template.getDeliveryDelay());
jmsTemplate.setDeliveryDelay(template.getDeliveryDelay().toMillis());
}
jmsTemplate.setExplicitQosEnabled(template.determineQosEnabled());
if (template.getDeliveryMode() != null) {
@ -94,10 +94,10 @@ public class JmsAutoConfiguration {
jmsTemplate.setPriority(template.getPriority());
}
if (template.getTimeToLive() != null) {
jmsTemplate.setTimeToLive(template.getTimeToLive());
jmsTemplate.setTimeToLive(template.getTimeToLive().toMillis());
}
if (template.getReceiveTimeout() != null) {
jmsTemplate.setReceiveTimeout(template.getReceiveTimeout());
jmsTemplate.setReceiveTimeout(template.getReceiveTimeout().toMillis());
}
return jmsTemplate;
}

View File

@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.jms;
import java.time.Duration;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
@ -142,9 +144,9 @@ public class JmsProperties {
private String defaultDestination;
/**
* Delivery delay to use for send calls in milliseconds.
* Delivery delay to use for send calls.
*/
private Long deliveryDelay;
private Duration deliveryDelay;
/**
* Delivery mode. Enable QoS when set.
@ -157,9 +159,9 @@ public class JmsProperties {
private Integer priority;
/**
* Time-to-live of a message when sending in milliseconds. Enable QoS when set.
* Time-to-live of a message when sending. Enable QoS when set.
*/
private Long timeToLive;
private Duration timeToLive;
/**
* Enable explicit QoS when sending a message. When enabled, the delivery mode,
@ -169,9 +171,9 @@ public class JmsProperties {
private Boolean qosEnabled;
/**
* Timeout to use for receive calls in milliseconds.
* Timeout to use for receive calls.
*/
private Long receiveTimeout;
private Duration receiveTimeout;
public String getDefaultDestination() {
return this.defaultDestination;
@ -181,11 +183,11 @@ public class JmsProperties {
this.defaultDestination = defaultDestination;
}
public Long getDeliveryDelay() {
public Duration getDeliveryDelay() {
return this.deliveryDelay;
}
public void setDeliveryDelay(Long deliveryDelay) {
public void setDeliveryDelay(Duration deliveryDelay) {
this.deliveryDelay = deliveryDelay;
}
@ -205,11 +207,11 @@ public class JmsProperties {
this.priority = priority;
}
public Long getTimeToLive() {
public Duration getTimeToLive() {
return this.timeToLive;
}
public void setTimeToLive(Long timeToLive) {
public void setTimeToLive(Duration timeToLive) {
this.timeToLive = timeToLive;
}
@ -229,11 +231,11 @@ public class JmsProperties {
this.qosEnabled = qosEnabled;
}
public Long getReceiveTimeout() {
public Duration getReceiveTimeout() {
return this.receiveTimeout;
}
public void setReceiveTimeout(Long receiveTimeout) {
public void setReceiveTimeout(Duration receiveTimeout) {
this.receiveTimeout = receiveTimeout;
}

View File

@ -67,19 +67,29 @@ class ActiveMQConnectionFactoryConfiguration {
ActiveMQConnectionFactory.class));
ActiveMQProperties.Pool pool = properties.getPool();
pooledConnectionFactory.setBlockIfSessionPoolIsFull(pool.isBlockIfFull());
pooledConnectionFactory
.setBlockIfSessionPoolIsFullTimeout(pool.getBlockIfFullTimeout());
if (pool.getBlockIfFullTimeout() != null) {
pooledConnectionFactory.setBlockIfSessionPoolIsFullTimeout(
pool.getBlockIfFullTimeout().toMillis());
}
pooledConnectionFactory
.setCreateConnectionOnStartup(pool.isCreateConnectionOnStartup());
pooledConnectionFactory.setExpiryTimeout(pool.getExpiryTimeout());
pooledConnectionFactory.setIdleTimeout(pool.getIdleTimeout());
if (pool.getExpiryTimeout() != null) {
pooledConnectionFactory
.setExpiryTimeout(pool.getExpiryTimeout().toMillis());
}
if (pool.getIdleTimeout() != null) {
pooledConnectionFactory
.setIdleTimeout((int) pool.getIdleTimeout().toMillis());
}
pooledConnectionFactory.setMaxConnections(pool.getMaxConnections());
pooledConnectionFactory.setMaximumActiveSessionPerConnection(
pool.getMaximumActiveSessionPerConnection());
pooledConnectionFactory
.setReconnectOnException(pool.isReconnectOnException());
pooledConnectionFactory.setTimeBetweenExpirationCheckMillis(
pool.getTimeBetweenExpirationCheck());
if (pool.getTimeBetweenExpirationCheck() != null) {
pooledConnectionFactory.setTimeBetweenExpirationCheckMillis(
pool.getTimeBetweenExpirationCheck().toMillis());
}
pooledConnectionFactory
.setUseAnonymousProducers(pool.isUseAnonymousProducers());
return pooledConnectionFactory;

View File

@ -66,9 +66,13 @@ class ActiveMQConnectionFactoryFactory {
private <T extends ActiveMQConnectionFactory> T doCreateConnectionFactory(
Class<T> factoryClass) throws Exception {
T factory = createConnectionFactoryInstance(factoryClass);
factory.setCloseTimeout(this.properties.getCloseTimeout());
if (this.properties.getCloseTimeout() != null) {
factory.setCloseTimeout((int) this.properties.getCloseTimeout().toMillis());
}
factory.setNonBlockingRedelivery(this.properties.isNonBlockingRedelivery());
factory.setSendTimeout(this.properties.getSendTimeout());
if (this.properties.getSendTimeout() != null) {
factory.setSendTimeout((int) this.properties.getSendTimeout().toMillis());
}
Packages packages = this.properties.getPackages();
if (packages.getTrustAll() != null) {
factory.setTrustAllPackages(packages.getTrustAll());

View File

@ -16,6 +16,7 @@
package org.springframework.boot.autoconfigure.jms.activemq;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
@ -54,9 +55,9 @@ public class ActiveMQProperties {
private String password;
/**
* Time to wait, in milliseconds, before considering a close complete.
* Time to wait before considering a close complete.
*/
private int closeTimeout = 15000;
private Duration closeTimeout = Duration.ofSeconds(15);
/**
* Do not stop message delivery before re-delivering messages from a rolled back
@ -66,10 +67,10 @@ public class ActiveMQProperties {
private boolean nonBlockingRedelivery = false;
/**
* Time to wait, in milliseconds, on Message sends for a response. Set it to 0 to
* indicate to wait forever.
* Time to wait on Message sends for a response. Set it to 0 to indicate to wait
* forever.
*/
private int sendTimeout = 0;
private Duration sendTimeout = Duration.ofMillis(0);
private Pool pool = new Pool();
@ -107,11 +108,11 @@ public class ActiveMQProperties {
this.password = password;
}
public int getCloseTimeout() {
public Duration getCloseTimeout() {
return this.closeTimeout;
}
public void setCloseTimeout(int closeTimeout) {
public void setCloseTimeout(Duration closeTimeout) {
this.closeTimeout = closeTimeout;
}
@ -123,11 +124,11 @@ public class ActiveMQProperties {
this.nonBlockingRedelivery = nonBlockingRedelivery;
}
public int getSendTimeout() {
public Duration getSendTimeout() {
return this.sendTimeout;
}
public void setSendTimeout(int sendTimeout) {
public void setSendTimeout(Duration sendTimeout) {
this.sendTimeout = sendTimeout;
}
@ -158,10 +159,9 @@ public class ActiveMQProperties {
private boolean blockIfFull = true;
/**
* Blocking period, in milliseconds, before throwing an exception if the pool is
* still full.
* Blocking period, before throwing an exception if the pool is still full.
*/
private long blockIfFullTimeout = -1;
private Duration blockIfFullTimeout = Duration.ofMillis(-1);
/**
* Create a connection on startup. Can be used to warm-up the pool on startup.
@ -169,14 +169,14 @@ public class ActiveMQProperties {
private boolean createConnectionOnStartup = true;
/**
* Connection expiration timeout in milliseconds.
* Connection expiration timeout.
*/
private long expiryTimeout = 0;
private Duration expiryTimeout = Duration.ofMillis(0);
/**
* Connection idle timeout in milliseconds.
* Connection idle timeout.
*/
private int idleTimeout = 30000;
private Duration idleTimeout = Duration.ofSeconds(30);
/**
* Maximum number of pooled connections.
@ -194,10 +194,10 @@ public class ActiveMQProperties {
private boolean reconnectOnException = true;
/**
* Time to sleep, in milliseconds, between runs of the idle connection eviction
* thread. When negative, no idle connection eviction thread runs.
* Time to sleep between runs of the idle connection eviction thread. When
* negative, no idle connection eviction thread runs.
*/
private long timeBetweenExpirationCheck = -1;
private Duration timeBetweenExpirationCheck = Duration.ofMillis(-1);
/**
* Use only one anonymous "MessageProducer" instance. Set it to false to create
@ -221,11 +221,11 @@ public class ActiveMQProperties {
this.blockIfFull = blockIfFull;
}
public long getBlockIfFullTimeout() {
public Duration getBlockIfFullTimeout() {
return this.blockIfFullTimeout;
}
public void setBlockIfFullTimeout(long blockIfFullTimeout) {
public void setBlockIfFullTimeout(Duration blockIfFullTimeout) {
this.blockIfFullTimeout = blockIfFullTimeout;
}
@ -237,19 +237,19 @@ public class ActiveMQProperties {
this.createConnectionOnStartup = createConnectionOnStartup;
}
public long getExpiryTimeout() {
public Duration getExpiryTimeout() {
return this.expiryTimeout;
}
public void setExpiryTimeout(long expiryTimeout) {
public void setExpiryTimeout(Duration expiryTimeout) {
this.expiryTimeout = expiryTimeout;
}
public int getIdleTimeout() {
public Duration getIdleTimeout() {
return this.idleTimeout;
}
public void setIdleTimeout(int idleTimeout) {
public void setIdleTimeout(Duration idleTimeout) {
this.idleTimeout = idleTimeout;
}
@ -278,11 +278,11 @@ public class ActiveMQProperties {
this.reconnectOnException = reconnectOnException;
}
public long getTimeBetweenExpirationCheck() {
public Duration getTimeBetweenExpirationCheck() {
return this.timeBetweenExpirationCheck;
}
public void setTimeBetweenExpirationCheck(long timeBetweenExpirationCheck) {
public void setTimeBetweenExpirationCheck(Duration timeBetweenExpirationCheck) {
this.timeBetweenExpirationCheck = timeBetweenExpirationCheck;
}

View File

@ -89,10 +89,10 @@ public class ConcurrentKafkaListenerContainerFactoryConfigurer {
containerProperties.setAckCount(container.getAckCount());
}
if (container.getAckTime() != null) {
containerProperties.setAckTime(container.getAckTime());
containerProperties.setAckTime(container.getAckTime().toMillis());
}
if (container.getPollTimeout() != null) {
containerProperties.setPollTimeout(container.getPollTimeout());
containerProperties.setPollTimeout(container.getPollTimeout().toMillis());
}
if (container.getConcurrency() != null) {
listenerContainerFactory.setConcurrency(container.getConcurrency());

View File

@ -17,6 +17,7 @@
package org.springframework.boot.autoconfigure.kafka;
import java.io.IOException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@ -222,10 +223,10 @@ public class KafkaProperties {
private final Ssl ssl = new Ssl();
/**
* Frequency in milliseconds that the consumer offsets are auto-committed to Kafka
* if 'enable.auto.commit' true.
* Frequency that the consumer offsets are auto-committed to Kafka if
* 'enable.auto.commit' true.
*/
private Integer autoCommitInterval;
private Duration autoCommitInterval;
/**
* What to do when there is no initial offset in Kafka or if the current offset
@ -250,11 +251,11 @@ public class KafkaProperties {
private Boolean enableAutoCommit;
/**
* Maximum amount of time in milliseconds the server will block before answering
* the fetch request if there isn't sufficient data to immediately satisfy the
* requirement given by "fetch.min.bytes".
* Maximum amount of time the server will block before answering the fetch request
* if there isn't sufficient data to immediately satisfy the requirement given by
* "fetch.min.bytes".
*/
private Integer fetchMaxWait;
private Duration fetchMaxWait;
/**
* Minimum amount of data the server should return for a fetch request in bytes.
@ -267,9 +268,9 @@ public class KafkaProperties {
private String groupId;
/**
* Expected time in milliseconds between heartbeats to the consumer coordinator.
* Expected time between heartbeats to the consumer coordinator.
*/
private Integer heartbeatInterval;
private Duration heartbeatInterval;
/**
* Deserializer class for keys.
@ -295,11 +296,11 @@ public class KafkaProperties {
return this.ssl;
}
public Integer getAutoCommitInterval() {
public Duration getAutoCommitInterval() {
return this.autoCommitInterval;
}
public void setAutoCommitInterval(Integer autoCommitInterval) {
public void setAutoCommitInterval(Duration autoCommitInterval) {
this.autoCommitInterval = autoCommitInterval;
}
@ -335,11 +336,11 @@ public class KafkaProperties {
this.enableAutoCommit = enableAutoCommit;
}
public Integer getFetchMaxWait() {
public Duration getFetchMaxWait() {
return this.fetchMaxWait;
}
public void setFetchMaxWait(Integer fetchMaxWait) {
public void setFetchMaxWait(Duration fetchMaxWait) {
this.fetchMaxWait = fetchMaxWait;
}
@ -359,11 +360,11 @@ public class KafkaProperties {
this.groupId = groupId;
}
public Integer getHeartbeatInterval() {
public Duration getHeartbeatInterval() {
return this.heartbeatInterval;
}
public void setHeartbeatInterval(Integer heartbeatInterval) {
public void setHeartbeatInterval(Duration heartbeatInterval) {
this.heartbeatInterval = heartbeatInterval;
}
@ -399,7 +400,7 @@ public class KafkaProperties {
Map<String, Object> properties = new HashMap<>();
if (this.autoCommitInterval != null) {
properties.put(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG,
this.autoCommitInterval);
(int) this.autoCommitInterval.toMillis());
}
if (this.autoOffsetReset != null) {
properties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG,
@ -418,7 +419,7 @@ public class KafkaProperties {
}
if (this.fetchMaxWait != null) {
properties.put(ConsumerConfig.FETCH_MAX_WAIT_MS_CONFIG,
this.fetchMaxWait);
(int) this.fetchMaxWait.toMillis());
}
if (this.fetchMinSize != null) {
properties.put(ConsumerConfig.FETCH_MIN_BYTES_CONFIG, this.fetchMinSize);
@ -428,7 +429,7 @@ public class KafkaProperties {
}
if (this.heartbeatInterval != null) {
properties.put(ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG,
this.heartbeatInterval);
(int) this.heartbeatInterval.toMillis());
}
if (this.keyDeserializer != null) {
properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG,
@ -800,9 +801,9 @@ public class KafkaProperties {
private Integer concurrency;
/**
* Timeout in milliseconds to use when polling the consumer.
* Timeout to use when polling the consumer.
*/
private Long pollTimeout;
private Duration pollTimeout;
/**
* Number of records between offset commits when ackMode is "COUNT" or
@ -811,10 +812,9 @@ public class KafkaProperties {
private Integer ackCount;
/**
* Time in milliseconds between offset commits when ackMode is "TIME" or
* "COUNT_TIME".
* Time between offset commits when ackMode is "TIME" or "COUNT_TIME".
*/
private Long ackTime;
private Duration ackTime;
public Type getType() {
return this.type;
@ -840,11 +840,11 @@ public class KafkaProperties {
this.concurrency = concurrency;
}
public Long getPollTimeout() {
public Duration getPollTimeout() {
return this.pollTimeout;
}
public void setPollTimeout(Long pollTimeout) {
public void setPollTimeout(Duration pollTimeout) {
this.pollTimeout = pollTimeout;
}
@ -856,11 +856,11 @@ public class KafkaProperties {
this.ackCount = ackCount;
}
public Long getAckTime() {
public Duration getAckTime() {
return this.ackTime;
}
public void setAckTime(Long ackTime) {
public void setAckTime(Duration ackTime) {
this.ackTime = ackTime;
}

View File

@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.session;
import java.time.Duration;
import com.hazelcast.core.HazelcastInstance;
import org.springframework.beans.factory.annotation.Autowired;
@ -52,9 +54,9 @@ class HazelcastSessionConfiguration {
@Autowired
public void customize(SessionProperties sessionProperties,
HazelcastSessionProperties hazelcastSessionProperties) {
Integer timeout = sessionProperties.getTimeout();
Duration timeout = sessionProperties.getTimeout();
if (timeout != null) {
setMaxInactiveIntervalInSeconds(timeout);
setMaxInactiveIntervalInSeconds((int) timeout.getSeconds());
}
setSessionMapName(hazelcastSessionProperties.getMapName());
setHazelcastFlushMode(hazelcastSessionProperties.getFlushMode());

View File

@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.session;
import java.time.Duration;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
@ -63,9 +65,9 @@ class JdbcSessionConfiguration {
@Autowired
public void customize(SessionProperties sessionProperties,
JdbcSessionProperties jdbcSessionProperties) {
Integer timeout = sessionProperties.getTimeout();
Duration timeout = sessionProperties.getTimeout();
if (timeout != null) {
setMaxInactiveIntervalInSeconds(timeout);
setMaxInactiveIntervalInSeconds((int) timeout.getSeconds());
}
setTableName(jdbcSessionProperties.getTableName());
setCleanupCron(jdbcSessionProperties.getCleanupCron());

View File

@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.session;
import java.time.Duration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@ -47,9 +49,9 @@ class MongoReactiveSessionConfiguration {
@Autowired
public void customize(SessionProperties sessionProperties,
MongoSessionProperties mongoSessionProperties) {
Integer timeout = sessionProperties.getTimeout();
Duration timeout = sessionProperties.getTimeout();
if (timeout != null) {
setMaxInactiveIntervalInSeconds(timeout);
setMaxInactiveIntervalInSeconds((int) timeout.getSeconds());
}
setCollectionName(mongoSessionProperties.getCollectionName());
}

View File

@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.session;
import java.time.Duration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@ -48,9 +50,9 @@ class MongoSessionConfiguration {
@Autowired
public void customize(SessionProperties sessionProperties,
MongoSessionProperties mongoSessionProperties) {
Integer timeout = sessionProperties.getTimeout();
Duration timeout = sessionProperties.getTimeout();
if (timeout != null) {
setMaxInactiveIntervalInSeconds(timeout);
setMaxInactiveIntervalInSeconds((int) timeout.getSeconds());
}
setCollectionName(mongoSessionProperties.getCollectionName());
}

View File

@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.session;
import java.time.Duration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@ -52,9 +54,9 @@ class RedisReactiveSessionConfiguration {
public void customize(SessionProperties sessionProperties,
RedisSessionProperties redisSessionProperties) {
this.sessionProperties = sessionProperties;
Integer timeout = this.sessionProperties.getTimeout();
Duration timeout = this.sessionProperties.getTimeout();
if (timeout != null) {
setMaxInactiveIntervalInSeconds(timeout);
setMaxInactiveIntervalInSeconds((int) timeout.getSeconds());
}
setRedisNamespace(redisSessionProperties.getNamespace());
setRedisFlushMode(redisSessionProperties.getFlushMode());

View File

@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.session;
import java.time.Duration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@ -56,9 +58,9 @@ class RedisSessionConfiguration {
public void customize(SessionProperties sessionProperties,
RedisSessionProperties redisSessionProperties) {
this.sessionProperties = sessionProperties;
Integer timeout = this.sessionProperties.getTimeout();
Duration timeout = this.sessionProperties.getTimeout();
if (timeout != null) {
setMaxInactiveIntervalInSeconds(timeout);
setMaxInactiveIntervalInSeconds((int) timeout.getSeconds());
}
setRedisNamespace(redisSessionProperties.getNamespace());
setRedisFlushMode(redisSessionProperties.getFlushMode());

View File

@ -16,12 +16,14 @@
package org.springframework.boot.autoconfigure.session;
import java.time.Duration;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.ServerProperties.Session;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.DispatcherType;
import org.springframework.session.web.http.SessionRepositoryFilter;
@ -42,13 +44,17 @@ public class SessionProperties {
*/
private StoreType storeType;
private final Integer timeout;
/**
* Session timeout.
*/
private final Duration timeout;
private Servlet servlet = new Servlet();
public SessionProperties(ObjectProvider<ServerProperties> serverProperties) {
ServerProperties properties = serverProperties.getIfUnique();
this.timeout = (properties != null ? properties.getSession().getTimeout() : null);
Session session = (properties == null ? null : properties.getSession());
this.timeout = (session == null ? null : session.getTimeout());
}
public StoreType getStoreType() {
@ -60,11 +66,11 @@ public class SessionProperties {
}
/**
* Return the session timeout in seconds.
* @return the session timeout in seconds
* Return the session timeout.
* @return the session timeout
* @see ServerProperties#getSession()
*/
public Integer getTimeout() {
public Duration getTimeout() {
return this.timeout;
}

View File

@ -16,7 +16,11 @@
package org.springframework.boot.autoconfigure.transaction;
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.transaction.support.AbstractPlatformTransactionManager;
/**
@ -32,20 +36,22 @@ public class TransactionProperties implements
PlatformTransactionManagerCustomizer<AbstractPlatformTransactionManager> {
/**
* Default transaction timeout in seconds.
* Default transaction timeout. If a duration suffix is not specified, seconds will be
* used.
*/
private Integer defaultTimeout;
@DurationUnit(ChronoUnit.SECONDS)
private Duration defaultTimeout;
/**
* Perform the rollback on commit failures.
*/
private Boolean rollbackOnCommitFailure;
public Integer getDefaultTimeout() {
public Duration getDefaultTimeout() {
return this.defaultTimeout;
}
public void setDefaultTimeout(Integer defaultTimeout) {
public void setDefaultTimeout(Duration defaultTimeout) {
this.defaultTimeout = defaultTimeout;
}
@ -60,7 +66,7 @@ public class TransactionProperties implements
@Override
public void customize(AbstractPlatformTransactionManager transactionManager) {
if (this.defaultTimeout != null) {
transactionManager.setDefaultTimeout(this.defaultTimeout);
transactionManager.setDefaultTimeout((int) this.defaultTimeout.getSeconds());
}
if (this.rollbackOnCommitFailure != null) {
transactionManager.setRollbackOnCommitFailure(this.rollbackOnCommitFailure);

View File

@ -16,7 +16,11 @@
package org.springframework.boot.autoconfigure.web;
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;
/**
* Properties used to configure resource handling.
@ -41,9 +45,11 @@ public class ResourceProperties {
private String[] staticLocations = CLASSPATH_RESOURCE_LOCATIONS;
/**
* Cache period for the resources served by the resource handler, in seconds.
* Cache period for the resources served by the resource handler. If a duration suffix
* is not specified, seconds will be used.
*/
private Integer cachePeriod;
@DurationUnit(ChronoUnit.SECONDS)
private Duration cachePeriod;
/**
* Enable default resource handling.
@ -69,11 +75,11 @@ public class ResourceProperties {
return normalized;
}
public Integer getCachePeriod() {
public Duration getCachePeriod() {
return this.cachePeriod;
}
public void setCachePeriod(Integer cachePeriod) {
public void setCachePeriod(Duration cachePeriod) {
this.cachePeriod = cachePeriod;
}

View File

@ -19,6 +19,8 @@ package org.springframework.boot.autoconfigure.web;
import java.io.File;
import java.net.InetAddress;
import java.nio.charset.Charset;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@ -30,6 +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.web.server.Compression;
import org.springframework.boot.web.server.Http2;
import org.springframework.boot.web.server.Ssl;
@ -89,11 +92,11 @@ public class ServerProperties {
private int maxHttpHeaderSize = 0; // bytes
/**
* Time in milliseconds that connectors will wait for another HTTP request before
* closing the connection. When not set, the connector's server-specific default will
* be used. Use a value of -1 to indicate no (i.e. infinite) timeout.
* Time that connectors will wait for another HTTP request before closing the
* connection. When not set, the connector's server-specific default will be used. Use
* a value of -1 to indicate no (i.e. infinite) timeout.
*/
private Integer connectionTimeout;
private Duration connectionTimeout;
private Session session = new Session();
@ -162,11 +165,11 @@ public class ServerProperties {
this.maxHttpHeaderSize = maxHttpHeaderSize;
}
public Integer getConnectionTimeout() {
public Duration getConnectionTimeout() {
return this.connectionTimeout;
}
public void setConnectionTimeout(Integer connectionTimeout) {
public void setConnectionTimeout(Duration connectionTimeout) {
this.connectionTimeout = connectionTimeout;
}
@ -335,9 +338,10 @@ public class ServerProperties {
public static class Session {
/**
* Session timeout in seconds.
* Session timeout. If a duration suffix is not specified, seconds will be used.
*/
private Integer timeout;
@DurationUnit(ChronoUnit.SECONDS)
private Duration timeout;
/**
* Session tracking modes (one or more of the following: "cookie", "url", "ssl").
@ -360,12 +364,12 @@ public class ServerProperties {
return this.cookie;
}
public Integer getTimeout() {
public Duration getTimeout() {
return this.timeout;
}
public void setTimeout(Integer sessionTimeout) {
this.timeout = sessionTimeout;
public void setTimeout(Duration timeout) {
this.timeout = timeout;
}
public Set<SessionTrackingMode> getTrackingModes() {
@ -428,9 +432,10 @@ public class ServerProperties {
private Boolean secure;
/**
* Maximum age of the session cookie in seconds.
* Maximum age of the session cookie.
*/
private Integer maxAge;
@DurationUnit(ChronoUnit.SECONDS)
private Duration maxAge;
public String getName() {
return this.name;
@ -480,11 +485,11 @@ public class ServerProperties {
this.secure = secure;
}
public Integer getMaxAge() {
public Duration getMaxAge() {
return this.maxAge;
}
public void setMaxAge(Integer maxAge) {
public void setMaxAge(Duration maxAge) {
this.maxAge = maxAge;
}
@ -562,29 +567,31 @@ public class ServerProperties {
private File basedir;
/**
* Delay in seconds between the invocation of backgroundProcess methods.
* Delay between the invocation of backgroundProcess methods. If a duration suffix
* is not specified, seconds will be used.
*/
private int backgroundProcessorDelay = 30; // seconds
@DurationUnit(ChronoUnit.SECONDS)
private Duration backgroundProcessorDelay = Duration.ofSeconds(30);
/**
* Maximum amount of worker threads.
*/
private int maxThreads = 0; // Number of threads in protocol handler
private int maxThreads = 0;
/**
* Minimum amount of worker threads.
*/
private int minSpareThreads = 0; // Minimum spare threads in protocol handler
private int minSpareThreads = 0;
/**
* Maximum size in bytes of the HTTP post content.
*/
private int maxHttpPostSize = 0; // bytes
private int maxHttpPostSize = 0;
/**
* Maximum size in bytes of the HTTP message header.
*/
private int maxHttpHeaderSize = 0; // bytes
private int maxHttpHeaderSize = 0;
/**
* Whether requests to the context root should be redirected by appending a / to
@ -650,11 +657,11 @@ public class ServerProperties {
return this.accesslog;
}
public int getBackgroundProcessorDelay() {
public Duration getBackgroundProcessorDelay() {
return this.backgroundProcessorDelay;
}
public void setBackgroundProcessorDelay(int backgroundProcessorDelay) {
public void setBackgroundProcessorDelay(Duration backgroundProcessorDelay) {
this.backgroundProcessorDelay = backgroundProcessorDelay;
}
@ -903,15 +910,15 @@ public class ServerProperties {
public static class Resource {
/**
* Time-to-live in milliseconds of the static resource cache.
* Time-to-live of the static resource cache.
*/
private Long cacheTtl;
private Duration cacheTtl;
public Long getCacheTtl() {
public Duration getCacheTtl() {
return this.cacheTtl;
}
public void setCacheTtl(Long cacheTtl) {
public void setCacheTtl(Duration cacheTtl) {
this.cacheTtl = cacheTtl;
}

View File

@ -16,6 +16,7 @@
package org.springframework.boot.autoconfigure.web.reactive;
import java.time.Duration;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -145,14 +146,14 @@ public class WebFluxAutoConfiguration {
logger.debug("Default resource handling disabled");
return;
}
Integer cachePeriod = this.resourceProperties.getCachePeriod();
Duration cachePeriod = this.resourceProperties.getCachePeriod();
if (!registry.hasMappingForPattern("/webjars/**")) {
ResourceHandlerRegistration registration = registry
.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
if (cachePeriod != null) {
registration.setCacheControl(
CacheControl.maxAge(cachePeriod, TimeUnit.SECONDS));
registration.setCacheControl(CacheControl
.maxAge(cachePeriod.toMillis(), TimeUnit.MILLISECONDS));
}
customizeResourceHandlerRegistration(registration);
}
@ -162,8 +163,8 @@ public class WebFluxAutoConfiguration {
.addResourceHandler(staticPathPattern).addResourceLocations(
this.resourceProperties.getStaticLocations());
if (cachePeriod != null) {
registration.setCacheControl(
CacheControl.maxAge(cachePeriod, TimeUnit.SECONDS));
registration.setCacheControl(CacheControl
.maxAge(cachePeriod.toMillis(), TimeUnit.MILLISECONDS));
}
customizeResourceHandlerRegistration(registration);
}

View File

@ -16,6 +16,7 @@
package org.springframework.boot.autoconfigure.web.servlet;
import java.time.Duration;
import java.util.LinkedHashSet;
import java.util.Set;
@ -195,7 +196,7 @@ public class DefaultServletWebServerFactoryCustomizer
config.setSecure(cookie.getSecure());
}
if (cookie.getMaxAge() != null) {
config.setMaxAge(cookie.getMaxAge());
config.setMaxAge((int) cookie.getMaxAge().getSeconds());
}
}
@ -217,13 +218,14 @@ public class DefaultServletWebServerFactoryCustomizer
public static void customizeTomcat(ServerProperties serverProperties,
Environment environment, TomcatServletWebServerFactory factory) {
ServerProperties.Tomcat tomcatProperties = serverProperties.getTomcat();
if (tomcatProperties.getBasedir() != null) {
factory.setBaseDirectory(tomcatProperties.getBasedir());
}
factory.setBackgroundProcessorDelay(
tomcatProperties.getBackgroundProcessorDelay());
if (tomcatProperties.getBackgroundProcessorDelay() != null) {
factory.setBackgroundProcessorDelay((int) tomcatProperties
.getBackgroundProcessorDelay().getSeconds());
}
customizeRemoteIpValve(serverProperties, environment, factory);
if (tomcatProperties.getMaxThreads() > 0) {
customizeMaxThreads(factory, tomcatProperties.getMaxThreads());
@ -290,12 +292,12 @@ public class DefaultServletWebServerFactoryCustomizer
}
private static void customizeConnectionTimeout(
TomcatServletWebServerFactory factory, final int connectionTimeout) {
TomcatServletWebServerFactory factory, Duration connectionTimeout) {
factory.addConnectorCustomizers((connector) -> {
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof AbstractProtocol) {
AbstractProtocol<?> protocol = (AbstractProtocol<?>) handler;
protocol.setConnectionTimeout(connectionTimeout);
protocol.setConnectionTimeout((int) connectionTimeout.toMillis());
}
});
}
@ -398,7 +400,8 @@ public class DefaultServletWebServerFactoryCustomizer
factory.addContextCustomizers((context) -> {
context.addLifecycleListener((event) -> {
if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) {
context.getResources().setCacheTtl(resource.getCacheTtl());
long ttl = resource.getCacheTtl().toMillis();
context.getResources().setCacheTtl(ttl);
}
});
});
@ -453,9 +456,10 @@ public class DefaultServletWebServerFactoryCustomizer
}
private static void customizeConnectionTimeout(
UndertowServletWebServerFactory factory, final int connectionTimeout) {
UndertowServletWebServerFactory factory, Duration connectionTimeout) {
factory.addBuilderCustomizers((builder) -> builder.setSocketOption(
UndertowOptions.NO_REQUEST_TIMEOUT, connectionTimeout));
UndertowOptions.NO_REQUEST_TIMEOUT,
(int) connectionTimeout.toMillis()));
}
private static void customizeMaxHttpHeaderSize(
@ -503,12 +507,13 @@ public class DefaultServletWebServerFactoryCustomizer
}
private static void customizeConnectionTimeout(
JettyServletWebServerFactory factory, final int connectionTimeout) {
JettyServletWebServerFactory factory, Duration connectionTimeout) {
factory.addServerCustomizers((server) -> {
for (org.eclipse.jetty.server.Connector connector : server
.getConnectors()) {
if (connector instanceof AbstractConnector) {
((AbstractConnector) connector).setIdleTimeout(connectionTimeout);
((AbstractConnector) connector)
.setIdleTimeout(connectionTimeout.toMillis());
}
}
});

View File

@ -16,6 +16,7 @@
package org.springframework.boot.autoconfigure.web.servlet;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -207,9 +208,9 @@ public class WebMvcAutoConfiguration {
@Override
public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
Long timeout = this.mvcProperties.getAsync().getRequestTimeout();
Duration timeout = this.mvcProperties.getAsync().getRequestTimeout();
if (timeout != null) {
configurer.setDefaultTimeout(timeout);
configurer.setDefaultTimeout(timeout.toMillis());
}
}
@ -305,13 +306,13 @@ public class WebMvcAutoConfiguration {
logger.debug("Default resource handling disabled");
return;
}
Integer cachePeriod = this.resourceProperties.getCachePeriod();
Duration cachePeriod = this.resourceProperties.getCachePeriod();
if (!registry.hasMappingForPattern("/webjars/**")) {
customizeResourceHandlerRegistration(
registry.addResourceHandler("/webjars/**")
.addResourceLocations(
"classpath:/META-INF/resources/webjars/")
.setCachePeriod(cachePeriod));
.setCachePeriod(getSeconds(cachePeriod)));
}
String staticPathPattern = this.mvcProperties.getStaticPathPattern();
if (!registry.hasMappingForPattern(staticPathPattern)) {
@ -319,10 +320,14 @@ public class WebMvcAutoConfiguration {
registry.addResourceHandler(staticPathPattern)
.addResourceLocations(getResourceLocations(
this.resourceProperties.getStaticLocations()))
.setCachePeriod(cachePeriod));
.setCachePeriod(getSeconds(cachePeriod)));
}
}
private Integer getSeconds(Duration cachePeriod) {
return (cachePeriod == null ? null : (int) cachePeriod.getSeconds());
}
@Bean
public WelcomePageHandlerMapping welcomePageHandlerMapping() {
return new WelcomePageHandlerMapping(getWelcomePage(),

View File

@ -16,6 +16,7 @@
package org.springframework.boot.autoconfigure.web.servlet;
import java.time.Duration;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
@ -204,17 +205,17 @@ public class WebMvcProperties {
public static class Async {
/**
* Amount of time (in milliseconds) before asynchronous request handling times
* out. If this value is not set, the default timeout of the underlying
* implementation is used, e.g. 10 seconds on Tomcat with Servlet 3.
* Amount of time before asynchronous request handling times out. If this value is
* not set, the default timeout of the underlying implementation is used, e.g. 10
* seconds on Tomcat with Servlet 3.
*/
private Long requestTimeout;
private Duration requestTimeout;
public Long getRequestTimeout() {
public Duration getRequestTimeout() {
return this.requestTimeout;
}
public void setRequestTimeout(Long requestTimeout) {
public void setRequestTimeout(Duration requestTimeout) {
this.requestTimeout = requestTimeout;
}

View File

@ -1036,6 +1036,24 @@
"level": "error"
}
},
{
"name": "spring.data.cassandra.connect-timeout-millis",
"type": "java.lang.Integer",
"description": "Socket option: connection time out.",
"deprecation": {
"replacement": "spring.data.cassandra.connect-timeout",
"level": "error"
}
},
{
"name": "spring.data.cassandra.read-timeout-millis",
"type": "java.lang.Integer",
"description": "Socket option: read time out.",
"deprecation": {
"replacement": "spring.data.cassandra.read-timeout",
"level": "error"
}
},
{
"name": "spring.data.neo4j.compiler",
"type": "java.lang.String",
@ -1130,6 +1148,15 @@
"level": "error"
}
},
{
"name": "spring.messages.cache-seconds",
"type": "java.lang.Integer",
"description": "Loaded resource bundle files cache expiration, in seconds. When set to -1, bundles are cached forever",
"deprecation": {
"replacement": "spring.messages.cache-duration",
"level": "error"
}
},
{
"name": "spring.redis.pool.max-active",
"type": "java.lang.Integer",

View File

@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.jms;
import java.time.Duration;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
@ -72,7 +74,7 @@ public class JmsPropertiesTests {
@Test
public void setTimeToLiveEnablesQoS() {
JmsProperties properties = new JmsProperties();
properties.getTemplate().setTimeToLive(5000L);
properties.getTemplate().setTimeToLive(Duration.ofSeconds(5));
assertThat(properties.getTemplate().determineQosEnabled()).isTrue();
}

View File

@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.web;
import java.net.InetAddress;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@ -72,8 +73,9 @@ public class ServerPropertiesTests {
@Test
public void testConnectionTimeout() throws Exception {
bind("server.connection-timeout", "60000");
assertThat(this.properties.getConnectionTimeout()).isEqualTo(60000);
bind("server.connection-timeout", "60s");
assertThat(this.properties.getConnectionTimeout())
.isEqualTo(Duration.ofMillis(60000));
}
@Test
@ -115,7 +117,8 @@ public class ServerPropertiesTests {
assertThat(tomcat.getProtocolHeader()).isEqualTo("X-Forwarded-Protocol");
assertThat(tomcat.getInternalProxies())
.isEqualTo("10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}");
assertThat(tomcat.getBackgroundProcessorDelay()).isEqualTo(10);
assertThat(tomcat.getBackgroundProcessorDelay())
.isEqualTo(Duration.ofSeconds(10));
}
@Test

View File

@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.web.servlet;
import java.io.File;
import java.io.IOException;
import java.time.Duration;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Locale;
@ -212,7 +213,7 @@ public class DefaultServletWebServerFactoryCustomizerTests {
given(servletContext.getSessionCookieConfig()).willReturn(sessionCookieConfig);
this.customizer.customize(factory);
triggerInitializers(factory, servletContext);
verify(factory).setSessionTimeout(123);
verify(factory).setSessionTimeout(Duration.ofSeconds(123));
verify(servletContext).setSessionTrackingModes(
EnumSet.of(SessionTrackingMode.COOKIE, SessionTrackingMode.URL));
verify(sessionCookieConfig).setName("testname");

View File

@ -17,6 +17,7 @@
package org.springframework.boot.devtools.autoconfigure;
import java.io.File;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
@ -62,10 +63,6 @@ public class DevToolsProperties {
+ "META-INF/resources/**,resources/**,static/**,public/**,templates/**,"
+ "**/*Test.class,**/*Tests.class,git.properties,META-INF/build-info.properties";
private static final long DEFAULT_RESTART_POLL_INTERVAL = 1000;
private static final long DEFAULT_RESTART_QUIET_PERIOD = 400;
/**
* Enable automatic restart.
*/
@ -82,15 +79,15 @@ public class DevToolsProperties {
private String additionalExclude;
/**
* Amount of time (in milliseconds) to wait between polling for classpath changes.
* Amount of time to wait between polling for classpath changes.
*/
private long pollInterval = DEFAULT_RESTART_POLL_INTERVAL;
private Duration pollInterval = Duration.ofSeconds(1);
/**
* Amount of quiet time (in milliseconds) required without any classpath changes
* before a restart is triggered.
* Amount of quiet time required without any classpath changes before a restart is
* triggered.
*/
private long quietPeriod = DEFAULT_RESTART_QUIET_PERIOD;
private Duration quietPeriod = Duration.ofMillis(400);
/**
* Name of a specific file that when changed will trigger the restart check. If
@ -139,19 +136,19 @@ public class DevToolsProperties {
this.additionalExclude = additionalExclude;
}
public long getPollInterval() {
public Duration getPollInterval() {
return this.pollInterval;
}
public void setPollInterval(long pollInterval) {
public void setPollInterval(Duration pollInterval) {
this.pollInterval = pollInterval;
}
public long getQuietPeriod() {
public Duration getQuietPeriod() {
return this.quietPeriod;
}
public void setQuietPeriod(long quietPeriod) {
public void setQuietPeriod(Duration quietPeriod) {
this.quietPeriod = quietPeriod;
}

View File

@ -18,6 +18,7 @@ package org.springframework.boot.devtools.filewatch;
import java.io.File;
import java.io.FileFilter;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -41,9 +42,9 @@ import org.springframework.util.Assert;
*/
public class FileSystemWatcher {
private static final long DEFAULT_POLL_INTERVAL = 1000;
private static final Duration DEFAULT_POLL_INTERVAL = Duration.ofMillis(1000);
private static final long DEFAULT_QUIET_PERIOD = 400;
private static final Duration DEFAULT_QUIET_PERIOD = Duration.ofMillis(400);
private final List<FileChangeListener> listeners = new ArrayList<>();
@ -77,14 +78,17 @@ public class FileSystemWatcher {
* @param quietPeriod the amount of time required after a change has been detected to
* ensure that updates have completed
*/
public FileSystemWatcher(boolean daemon, long pollInterval, long quietPeriod) {
Assert.isTrue(pollInterval > 0, "PollInterval must be positive");
Assert.isTrue(quietPeriod > 0, "QuietPeriod must be positive");
Assert.isTrue(pollInterval > quietPeriod,
public FileSystemWatcher(boolean daemon, Duration pollInterval,
Duration quietPeriod) {
Assert.notNull(pollInterval, "PollInterval must not be null");
Assert.notNull(quietPeriod, "QuietPeriod must not be null");
Assert.isTrue(pollInterval.toMillis() > 0, "PollInterval must be positive");
Assert.isTrue(quietPeriod.toMillis() > 0, "QuietPeriod must be positive");
Assert.isTrue(pollInterval.toMillis() > quietPeriod.toMillis(),
"PollInterval must be greater than QuietPeriod");
this.daemon = daemon;
this.pollInterval = pollInterval;
this.quietPeriod = quietPeriod;
this.pollInterval = pollInterval.toMillis();
this.quietPeriod = quietPeriod.toMillis();
}
/**

View File

@ -17,6 +17,7 @@
package org.springframework.boot.devtools.autoconfigure;
import java.io.File;
import java.time.Duration;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@ -120,7 +121,7 @@ public class LocalDevToolsAutoConfigurationTests {
public void resourceCachePeriodIsZero() throws Exception {
this.context = initializeAndRun(WebResourcesConfig.class);
ResourceProperties properties = this.context.getBean(ResourceProperties.class);
assertThat(properties.getCachePeriod()).isEqualTo(0);
assertThat(properties.getCachePeriod()).isEqualTo(Duration.ZERO);
}
@Test

View File

@ -18,6 +18,7 @@ package org.springframework.boot.devtools.classpath;
import java.io.File;
import java.net.URL;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -104,7 +105,8 @@ public class ClassPathFileSystemWatcherTests {
@Bean
public ClassPathFileSystemWatcher watcher() {
FileSystemWatcher watcher = new FileSystemWatcher(false, 100, 10);
FileSystemWatcher watcher = new FileSystemWatcher(false,
Duration.ofMillis(100), Duration.ofMillis(10));
URL[] urls = this.environment.getProperty("urls", URL[].class);
return new ClassPathFileSystemWatcher(
new MockFileSystemWatcherFactory(watcher), restartStrategy(), urls);

View File

@ -20,6 +20,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@ -66,21 +67,21 @@ public class FileSystemWatcherTests {
public void pollIntervalMustBePositive() throws Exception {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("PollInterval must be positive");
new FileSystemWatcher(true, 0, 1);
new FileSystemWatcher(true, Duration.ofMillis(0), Duration.ofMillis(1));
}
@Test
public void quietPeriodMustBePositive() throws Exception {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("QuietPeriod must be positive");
new FileSystemWatcher(true, 1, 0);
new FileSystemWatcher(true, Duration.ofMillis(1), Duration.ofMillis(0));
}
@Test
public void pollIntervalMustBeGreaterThanQuietPeriod() throws Exception {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("PollInterval must be greater than QuietPeriod");
new FileSystemWatcher(true, 1, 1);
new FileSystemWatcher(true, Duration.ofMillis(1), Duration.ofMillis(1));
}
@Test
@ -272,7 +273,8 @@ public class FileSystemWatcherTests {
}
private void setupWatcher(long pollingInterval, long quietPeriod) {
this.watcher = new FileSystemWatcher(false, pollingInterval, quietPeriod);
this.watcher = new FileSystemWatcher(false, Duration.ofMillis(pollingInterval),
Duration.ofMillis(quietPeriod));
this.watcher.addListener(
(changeSet) -> FileSystemWatcherTests.this.changes.add(changeSet));
}

View File

@ -72,14 +72,14 @@ content into your application; rather pick only the properties that you need.
# SPRING CACHE ({sc-spring-boot-autoconfigure}/cache/CacheProperties.{sc-ext}[CacheProperties])
spring.cache.cache-names= # Comma-separated list of cache names to create if supported by the underlying cache manager.
spring.cache.caffeine.spec= # The spec to use to create caches. Check CaffeineSpec for more details on the spec format.
spring.cache.couchbase.expiration=0 # Entry expiration in milliseconds. By default the entries never expire.
spring.cache.couchbase.expiration=0ms # Entry expiration. By default the entries never expire.
spring.cache.ehcache.config= # The location of the configuration file to use to initialize EhCache.
spring.cache.infinispan.config= # The location of the configuration file to use to initialize Infinispan.
spring.cache.jcache.config= # The location of the configuration file to use to initialize the cache manager.
spring.cache.jcache.provider= # Fully qualified name of the CachingProvider implementation to use to retrieve the JSR-107 compliant cache manager. Only needed if more than one JSR-107 implementation is available on the classpath.
spring.cache.redis.cache-null-values=true # Allow caching null values.
spring.cache.redis.key-prefix= # Key prefix.
spring.cache.redis.time-to-live=0 # Entry expiration in milliseconds. By default the entries never expire.
spring.cache.redis.time-to-live=0ms # Entry expiration. By default the entries never expire.
spring.cache.redis.use-key-prefix=true # Whether to use the key prefix when writing to Redis.
spring.cache.type= # Cache type, auto-detected according to the environment by default.
@ -121,7 +121,7 @@ content into your application; rather pick only the properties that you need.
# INTERNATIONALIZATION ({sc-spring-boot-autoconfigure}/context/MessageSourceAutoConfiguration.{sc-ext}[MessageSourceAutoConfiguration])
spring.messages.always-use-message-format=false # Set whether to always apply the MessageFormat rules, parsing even messages without arguments.
spring.messages.basename=messages # Comma-separated list of basenames, each following the ResourceBundle convention.
spring.messages.cache-seconds=-1 # Loaded resource bundle files cache expiration, in seconds. When set to -1, bundles are cached forever.
spring.messages.cache-duration=-1 # Loaded resource bundle files cache duration. When not set, bundles are cached forever.
spring.messages.encoding=UTF-8 # Message bundles encoding.
spring.messages.fallback-to-system-locale=true # Set whether to fall back to the system Locale if no files for a specific Locale have been found.
spring.messages.use-code-as-default-message=false # Set whether to use the message code as default message instead of throwing a "NoSuchMessageException". Recommended during development only.
@ -162,7 +162,7 @@ content into your application; rather pick only the properties that you need.
server.compression.excluded-user-agents= # List of user-agents to exclude from compression.
server.compression.mime-types=text/html,text/xml,text/plain,text/css,text/javascript,application/javascript # Comma-separated list of MIME types that should be compressed.
server.compression.min-response-size=2048 # Minimum response size that is required for compression to be performed.
server.connection-timeout= # Time in milliseconds that connectors will wait for another HTTP request before closing the connection. When not set, the connector's container-specific default will be used. Use a value of -1 to indicate no (i.e. infinite) timeout.
server.connection-timeout= # Time that connectors will wait for another HTTP request before closing the connection. When not set, the connector's container-specific default will be used. Use a value of -1ms to indicate no (i.e. infinite) timeout.
server.display-name=application # Display name of the application.
server.max-http-header-size=0 # Maximum size in bytes of the HTTP message header.
server.error.include-exception=false # Include the "exception" attribute.
@ -197,13 +197,13 @@ content into your application; rather pick only the properties that you need.
server.session.cookie.comment= # Comment for the session cookie.
server.session.cookie.domain= # Domain for the session cookie.
server.session.cookie.http-only= # "HttpOnly" flag for the session cookie.
server.session.cookie.max-age= # Maximum age of the session cookie in seconds.
server.session.cookie.max-age= # Maximum age of the session cookie. If a duration suffix is not specified, seconds will be used.
server.session.cookie.name= # Session cookie name.
server.session.cookie.path= # Path of the session cookie.
server.session.cookie.secure= # "Secure" flag for the session cookie.
server.session.persistent=false # Persist session data between restarts.
server.session.store-dir= # Directory used to store session data.
server.session.timeout= # Session timeout in seconds.
server.session.timeout= # Session timeout. If a duration suffix is not specified, seconds will be used.
server.session.tracking-modes= # Session tracking modes (one or more of the following: "cookie", "url", "ssl").
server.ssl.ciphers= # Supported SSL ciphers.
server.ssl.client-auth= # Whether client authentication is wanted ("want") or needed ("need"). Requires a trust store.
@ -232,7 +232,7 @@ content into your application; rather pick only the properties that you need.
server.tomcat.accesslog.rotate=true # Enable access log rotation.
server.tomcat.accesslog.suffix=.log # Log file name suffix.
server.tomcat.additional-tld-skip-patterns= # Comma-separated list of additional patterns that match jars to ignore for TLD scanning.
server.tomcat.background-processor-delay=30 # Delay in seconds between the invocation of backgroundProcess methods.
server.tomcat.background-processor-delay=30s # Delay between the invocation of backgroundProcess methods. If a duration suffix is not specified, seconds will be used.
server.tomcat.basedir= # Tomcat base directory. If not specified a temporary directory will be used.
server.tomcat.internal-proxies=10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\
192\\.168\\.\\d{1,3}\\.\\d{1,3}|\\
@ -251,7 +251,7 @@ content into your application; rather pick only the properties that you need.
server.tomcat.protocol-header-https-value=https # Value of the protocol header that indicates that the incoming request uses SSL.
server.tomcat.redirect-context-root= # Whether requests to the context root should be redirected by appending a / to the path.
server.tomcat.remote-ip-header= # Name of the http header from which the remote ip is extracted. For instance `X-FORWARDED-FOR`
spring.tomcat.resource.cache-ttl=5000 # Time-to-live in milliseconds of the static resource cache.
spring.tomcat.resource.cache-ttl= # Time-to-live of the static resource cache.
server.tomcat.uri-encoding=UTF-8 # Character encoding to use to decode the URI.
server.undertow.accesslog.dir= # Undertow access log directory.
server.undertow.accesslog.enabled=false # Enable access log.
@ -378,7 +378,7 @@ content into your application; rather pick only the properties that you need.
spring.mustache.view-names= # White list of view names that can be resolved.
# SPRING MVC ({sc-spring-boot-autoconfigure}/web/servlet/WebMvcProperties.{sc-ext}[WebMvcProperties])
spring.mvc.async.request-timeout= # Amount of time (in milliseconds) before asynchronous request handling times out.
spring.mvc.async.request-timeout= # Amount of time before asynchronous request handling times out.
spring.mvc.date-format= # Date format to use. For instance `dd/MM/yyyy`.
spring.mvc.dispatch-trace-request=false # Dispatch TRACE requests to the FrameworkServlet doService method.
spring.mvc.dispatch-options-request=true # Dispatch OPTIONS requests to the FrameworkServlet doService method.
@ -398,7 +398,7 @@ content into your application; rather pick only the properties that you need.
# SPRING RESOURCES HANDLING ({sc-spring-boot-autoconfigure}/web/ResourceProperties.{sc-ext}[ResourceProperties])
spring.resources.add-mappings=true # Enable default resource handling.
spring.resources.cache-period= # Cache period for the resources served by the resource handler, in seconds.
spring.resources.cache-period= # Cache period for the resources served by the resource handler. If a duration suffix is not specified, seconds will be used.
spring.resources.chain.cache=true # Enable caching in the Resource chain.
spring.resources.chain.enabled= # Enable the Spring Resource Handling chain. Disabled by default unless at least one strategy has been enabled.
spring.resources.chain.gzipped=false # Enable resolution of already gzipped resources.
@ -552,11 +552,11 @@ content into your application; rather pick only the properties that you need.
spring.couchbase.env.ssl.enabled= # Enable SSL support. Enabled automatically if a "keyStore" is provided unless specified otherwise.
spring.couchbase.env.ssl.key-store= # Path to the JVM key store that holds the certificates.
spring.couchbase.env.ssl.key-store-password= # Password used to access the key store.
spring.couchbase.env.timeouts.connect=5000 # Bucket connections timeout in milliseconds.
spring.couchbase.env.timeouts.key-value=2500 # Blocking operations performed on a specific key timeout in milliseconds.
spring.couchbase.env.timeouts.query=7500 # N1QL query operations timeout in milliseconds.
spring.couchbase.env.timeouts.socket-connect=1000 # Socket connect connections timeout in milliseconds.
spring.couchbase.env.timeouts.view=7500 # Regular and geospatial view operations timeout in milliseconds.
spring.couchbase.env.timeouts.connect=5000ms # Bucket connections timeout .
spring.couchbase.env.timeouts.key-value=2500ms # Blocking operations performed on a specific key timeout.
spring.couchbase.env.timeouts.query=7500ms # N1QL query operations timeout.
spring.couchbase.env.timeouts.socket-connect=1000ms # Socket connect connections timeout.
spring.couchbase.env.timeouts.view=7500ms # Regular and geospatial view operations timeout.
# DAO ({sc-spring-boot-autoconfigure}/dao/PersistenceExceptionTranslationAutoConfiguration.{sc-ext}[PersistenceExceptionTranslationAutoConfiguration])
spring.dao.exceptiontranslation.enabled=true # Enable the PersistenceExceptionTranslationPostProcessor.
@ -564,7 +564,7 @@ content into your application; rather pick only the properties that you need.
# CASSANDRA ({sc-spring-boot-autoconfigure}/cassandra/CassandraProperties.{sc-ext}[CassandraProperties])
spring.data.cassandra.cluster-name= # Name of the Cassandra cluster.
spring.data.cassandra.compression=none # Compression supported by the Cassandra binary protocol.
spring.data.cassandra.connect-timeout-millis= # Socket option: connection time out.
spring.data.cassandra.connect-timeout= # Socket option: connection time out.
spring.data.cassandra.consistency-level= # Queries consistency level.
spring.data.cassandra.contact-points=localhost # Comma-separated list of cluster node addresses.
spring.data.cassandra.fetch-size= # Queries default fetch size.
@ -572,12 +572,12 @@ content into your application; rather pick only the properties that you need.
spring.data.cassandra.load-balancing-policy= # Class name of the load balancing policy.
spring.data.cassandra.port= # Port of the Cassandra server.
spring.data.cassandra.password= # Login password of the server.
spring.data.cassandra.pool.heartbeat-interval=30 # Heartbeat interval (in seconds) after which a message is sent on an idle connection to make sure it's still alive.
spring.data.cassandra.pool.idle-timeout=120 # Idle timeout (in seconds) before an idle connection is removed.
spring.data.cassandra.pool.heartbeat-interval=30 # Heartbeat interval after which a message is sent on an idle connection to make sure it's still alive. If a duration suffix is not specified, seconds will be used.
spring.data.cassandra.pool.idle-timeout=120 # Idle timeout before an idle connection is removed. If a duration suffix is not specified, seconds will be used.
spring.data.cassandra.pool.max-queue-size=256 # Maximum number of requests that get enqueued if no connection is available.
spring.data.cassandra.pool.pool-timeout=5000 # Pool timeout (in milliseconds) when trying to acquire a connection from a host's pool.
spring.data.cassandra.pool.pool-timeout=5000ms # Pool timeout when trying to acquire a connection from a host's pool.
spring.data.cassandra.reactive-repositories.enabled=true # Enable Cassandra reactive repositories.
spring.data.cassandra.read-timeout-millis= # Socket option: read time out.
spring.data.cassandra.read-timeout= # Socket option: read time out.
spring.data.cassandra.reconnection-policy= # Reconnection policy class.
spring.data.cassandra.repositories.enabled= # Enable Cassandra repositories.
spring.data.cassandra.retry-policy= # Class name of the retry policy.
@ -677,12 +677,12 @@ content into your application; rather pick only the properties that you need.
spring.datasource.xa.properties= # Properties to pass to the XA data source.
# JEST (Elasticsearch HTTP client) ({sc-spring-boot-autoconfigure}/elasticsearch/jest/JestProperties.{sc-ext}[JestProperties])
spring.elasticsearch.jest.connection-timeout=3000 # Connection timeout in milliseconds.
spring.elasticsearch.jest.connection-timeout=3s # Connection timeout.
spring.elasticsearch.jest.multi-threaded=true # Enable connection requests from multiple execution threads.
spring.elasticsearch.jest.password= # Login password.
spring.elasticsearch.jest.proxy.host= # Proxy host the HTTP client should use.
spring.elasticsearch.jest.proxy.port= # Proxy port the HTTP client should use.
spring.elasticsearch.jest.read-timeout=3000 # Read timeout in milliseconds.
spring.elasticsearch.jest.read-timeout=3s # Read timeout.
spring.elasticsearch.jest.uris=http://localhost:9200 # Comma-separated list of the Elasticsearch instances to use.
spring.elasticsearch.jest.username= # Login user.
@ -703,7 +703,7 @@ content into your application; rather pick only the properties that you need.
# JDBC ({sc-spring-boot-autoconfigure}/jdbc/JdbcProperties.{sc-ext}[JdbcProperties])
spring.jdbc.template.fetch-size=-1 # Number of rows that should be fetched from the database when more rows are needed.
spring.jdbc.template.max-rows=-1 # Maximum number of rows.
spring.jdbc.template.query-timeout=-1 # Query timeout in seconds.
spring.jdbc.template.query-timeout= # Query timeout. If a duration suffix is not specified, seconds will be used.
# JPA ({sc-spring-boot-autoconfigure}/orm/jpa/JpaBaseConfiguration.{sc-ext}[JpaBaseConfiguration], {sc-spring-boot-autoconfigure}/orm/jpa/HibernateJpaAutoConfiguration.{sc-ext}[HibernateJpaAutoConfiguration])
spring.data.jpa.repositories.enabled=true # Enable JPA repositories.
@ -754,11 +754,11 @@ content into your application; rather pick only the properties that you need.
spring.jta.atomikos.properties.log-base-dir= # Directory in which the log files should be stored.
spring.jta.atomikos.properties.log-base-name=tmlog # Transactions log file base name.
spring.jta.atomikos.properties.max-actives=50 # Maximum number of active transactions.
spring.jta.atomikos.properties.max-timeout=300000 # Maximum timeout (in milliseconds) that can be allowed for transactions.
spring.jta.atomikos.properties.recovery.delay=10000 # Delay between two recovery scans.
spring.jta.atomikos.properties.max-timeout=30m # Maximum timeout that can be allowed for transactions.
spring.jta.atomikos.properties.recovery.delay=10000ms # Delay between two recovery scans.
spring.jta.atomikos.properties.recovery.forget-orphaned-log-entries-delay=86400000 # Delay after which recovery can cleanup pending ('orphaned') log entries.
spring.jta.atomikos.properties.recovery.max-retries=5 # Number of retry attempts to commit the transaction before throwing an exception.
spring.jta.atomikos.properties.recovery.retry-interval=10000 # Delay between retry attempts.
spring.jta.atomikos.properties.recovery.retry-interval=10000ms # Delay between retry attempts.
spring.jta.atomikos.properties.serial-jta-transactions=true # Specify if sub-transactions should be joined when possible.
spring.jta.atomikos.properties.service= # Transaction manager implementation that should be started.
spring.jta.atomikos.properties.threaded-two-phase-commit=false # Use different (and concurrent) threads for two-phase commit on the participating resources.
@ -830,12 +830,12 @@ content into your application; rather pick only the properties that you need.
spring.jta.bitronix.properties.warn-about-zero-resource-transaction=true # Log a warning for transactions executed without a single enlisted resource.
# NARAYANA ({sc-spring-boot}/jta/narayana/NarayanaProperties.{sc-ext}[NarayanaProperties])
spring.jta.narayana.default-timeout=60 # Transaction timeout in seconds.
spring.jta.narayana.default-timeout=60s # Transaction timeout. If a duration suffix is not specified, seconds will be used.
spring.jta.narayana.expiry-scanners=com.arjuna.ats.internal.arjuna.recovery.ExpiredTransactionStatusManagerScanner # Comma-separated list of expiry scanners.
spring.jta.narayana.log-dir= # Transaction object store directory.
spring.jta.narayana.one-phase-commit=true # Enable one phase commit optimisation.
spring.jta.narayana.periodic-recovery-period=120 # Interval in which periodic recovery scans are performed in seconds.
spring.jta.narayana.recovery-backoff-period=10 # Back off period between first and second phases of the recovery scan in seconds.
spring.jta.narayana.periodic-recovery-period=120s # Interval in which periodic recovery scans are performed. If a duration suffix is not specified, seconds will be used.
spring.jta.narayana.recovery-backoff-period=10s # Back off period between first and second phases of the recovery scan. If a duration suffix is not specified, seconds will be used.
spring.jta.narayana.recovery-db-pass= # Database password to be used by recovery manager.
spring.jta.narayana.recovery-db-user= # Database username to be used by recovery manager.
spring.jta.narayana.recovery-jms-pass= # JMS password to be used by recovery manager.
@ -859,22 +859,22 @@ content into your application; rather pick only the properties that you need.
spring.redis.host=localhost # Redis server host.
spring.redis.jedis.pool.max-active=8 # Max number of connections that can be allocated by the pool at a given time. Use a negative value for no limit.
spring.redis.jedis.pool.max-idle=8 # Max number of "idle" connections in the pool. Use a negative value to indicate an unlimited number of idle connections.
spring.redis.jedis.pool.max-wait=-1 # Maximum amount of time (in milliseconds) a connection allocation should block before throwing an exception when the pool is exhausted. Use a negative value to block indefinitely.
spring.redis.jedis.pool.max-wait=-1ms # Maximum amount of time a connection allocation should block before throwing an exception when the pool is exhausted. Use a negative value to block indefinitely.
spring.redis.jedis.pool.min-idle=0 # Target for the minimum number of idle connections to maintain in the pool. This setting only has an effect if it is positive.
spring.redis.lettuce.pool.max-active=8 # Max number of connections that can be allocated by the pool at a given time. Use a negative value for no limit.
spring.redis.lettuce.pool.max-idle=8 # Max number of "idle" connections in the pool. Use a negative value to indicate an unlimited number of idle connections.
spring.redis.lettuce.pool.max-wait=-1 # Maximum amount of time (in milliseconds) a connection allocation should block before throwing an exception when the pool is exhausted. Use a negative value to block indefinitely.
spring.redis.lettuce.pool.max-wait=-1ms # Maximum amount of time a connection allocation should block before throwing an exception when the pool is exhausted. Use a negative value to block indefinitely.
spring.redis.lettuce.pool.min-idle=0 # Target for the minimum number of idle connections to maintain in the pool. This setting only has an effect if it is positive.
spring.redis.lettuce.shutdown-timeout=100 # Shutdown timeout in milliseconds.
spring.redis.lettuce.shutdown-timeout=100ms # Shutdown timeout.
spring.redis.password= # Login password of the redis server.
spring.redis.port=6379 # Redis server port.
spring.redis.sentinel.master= # Name of Redis server.
spring.redis.sentinel.nodes= # Comma-separated list of "host:port" pairs.
spring.redis.ssl=false # Enable SSL support.
spring.redis.timeout=0 # Connection timeout in milliseconds.
spring.redis.timeout=0 # Connection timeout.
# TRANSACTION ({sc-spring-boot-autoconfigure}/transaction/TransactionProperties.{sc-ext}[TransactionProperties])
spring.transaction.default-timeout= # Default transaction timeout in seconds.
spring.transaction.default-timeout= # Default transaction timeout. If a duration suffix is not specified, seconds will be used.
spring.transaction.rollback-on-commit-failure= # Perform the rollback on commit failures.
@ -885,24 +885,24 @@ content into your application; rather pick only the properties that you need.
# ACTIVEMQ ({sc-spring-boot-autoconfigure}/jms/activemq/ActiveMQProperties.{sc-ext}[ActiveMQProperties])
spring.activemq.broker-url= # URL of the ActiveMQ broker. Auto-generated by default.
spring.activemq.close-timeout=15000 # Time to wait, in milliseconds, before considering a close complete.
spring.activemq.close-timeout=15s # Time to wait before considering a close complete.
spring.activemq.in-memory=true # Specify if the default broker URL should be in memory. Ignored if an explicit broker has been specified.
spring.activemq.non-blocking-redelivery=false # Do not stop message delivery before re-delivering messages from a rolled back transaction. This implies that message order will not be preserved when this is enabled.
spring.activemq.password= # Login password of the broker.
spring.activemq.send-timeout=0 # Time to wait, in milliseconds, on Message sends for a response. Set it to 0 to indicate to wait forever.
spring.activemq.send-timeout=0 # Time to wait on Message sends for a response. Set it to 0 to indicate to wait forever.
spring.activemq.user= # Login user of the broker.
spring.activemq.packages.trust-all= # Trust all packages.
spring.activemq.packages.trusted= # Comma-separated list of specific packages to trust (when not trusting all packages).
spring.activemq.pool.block-if-full=true # Block when a connection is requested and the pool is full. Set it to false to throw a "JMSException" instead.
spring.activemq.pool.block-if-full-timeout=-1 # Blocking period, in milliseconds, before throwing an exception if the pool is still full.
spring.activemq.pool.block-if-full-timeout=-1ms # Blocking period before throwing an exception if the pool is still full.
spring.activemq.pool.create-connection-on-startup=true # Create a connection on startup. Can be used to warm-up the pool on startup.
spring.activemq.pool.enabled=false # Whether a PooledConnectionFactory should be created instead of a regular ConnectionFactory.
spring.activemq.pool.expiry-timeout=0 # Connection expiration timeout in milliseconds.
spring.activemq.pool.idle-timeout=30000 # Connection idle timeout in milliseconds.
spring.activemq.pool.expiry-timeout=0ms # Connection expiration timeout.
spring.activemq.pool.idle-timeout=30s # Connection idle timeout.
spring.activemq.pool.max-connections=1 # Maximum number of pooled connections.
spring.activemq.pool.maximum-active-session-per-connection=500 # Maximum number of active sessions per connection.
spring.activemq.pool.reconnect-on-exception=true # Reset the connection when a "JMSException" occurs.
spring.activemq.pool.time-between-expiration-check=-1 # Time to sleep, in milliseconds, between runs of the idle connection eviction thread. When negative, no idle connection eviction thread runs.
spring.activemq.pool.time-between-expiration-check=-1ms # Time to sleep between runs of the idle connection eviction thread. When negative, no idle connection eviction thread runs.
spring.activemq.pool.use-anonymous-producers=true # Use only one anonymous "MessageProducer" instance. Set it to false to create one "MessageProducer" every time one is required.
# ARTEMIS ({sc-spring-boot-autoconfigure}/jms/artemis/ArtemisProperties.{sc-ext}[ArtemisProperties])
@ -938,12 +938,12 @@ content into your application; rather pick only the properties that you need.
spring.jms.listener.max-concurrency= # Maximum number of concurrent consumers.
spring.jms.pub-sub-domain=false # Specify if the default destination type is topic.
spring.jms.template.default-destination= # Default destination to use on send/receive operations that do not have a destination parameter.
spring.jms.template.delivery-delay= # Delivery delay to use for send calls in milliseconds.
spring.jms.template.delivery-delay= # Delivery delay to use for send calls.
spring.jms.template.delivery-mode= # Delivery mode. Enable QoS when set.
spring.jms.template.priority= # Priority of a message when sending. Enable QoS when set.
spring.jms.template.qos-enabled= # Enable explicit QoS when sending a message.
spring.jms.template.receive-timeout= # Timeout to use for receive calls in milliseconds.
spring.jms.template.time-to-live= # Time-to-live of a message when sending in milliseconds. Enable QoS when set.
spring.jms.template.receive-timeout= # Timeout to use for receive calls.
spring.jms.template.time-to-live= # Time-to-live of a message when sending. Enable QoS when set.
# APACHE KAFKA ({sc-spring-boot-autoconfigure}/kafka/KafkaProperties.{sc-ext}[KafkaProperties])
spring.kafka.admin.client-id= # Id to pass to the server when making requests; used for server-side logging.
@ -956,15 +956,15 @@ content into your application; rather pick only the properties that you need.
spring.kafka.admin.ssl.truststore-password= # Store password for the trust store file.
spring.kafka.bootstrap-servers= # Comma-delimited list of host:port pairs to use for establishing the initial connection to the Kafka cluster.
spring.kafka.client-id= # Id to pass to the server when making requests; used for server-side logging.
spring.kafka.consumer.auto-commit-interval= # Frequency in milliseconds that the consumer offsets are auto-committed to Kafka if 'enable.auto.commit' true.
spring.kafka.consumer.auto-commit-interval= # Frequency that the consumer offsets are auto-committed to Kafka if 'enable.auto.commit' true.
spring.kafka.consumer.auto-offset-reset= # What to do when there is no initial offset in Kafka or if the current offset does not exist any more on the server.
spring.kafka.consumer.bootstrap-servers= # Comma-delimited list of host:port pairs to use for establishing the initial connection to the Kafka cluster.
spring.kafka.consumer.client-id= # Id to pass to the server when making requests; used for server-side logging.
spring.kafka.consumer.enable-auto-commit= # If true the consumer's offset will be periodically committed in the background.
spring.kafka.consumer.fetch-max-wait= # Maximum amount of time in milliseconds the server will block before answering the fetch request if there isn't sufficient data to immediately satisfy the requirement given by "fetch.min.bytes".
spring.kafka.consumer.fetch-max-wait= # Maximum amount of time the server will block before answering the fetch request if there isn't sufficient data to immediately satisfy the requirement given by "fetch.min.bytes".
spring.kafka.consumer.fetch-min-size= # Minimum amount of data the server should return for a fetch request in bytes.
spring.kafka.consumer.group-id= # Unique string that identifies the consumer group this consumer belongs to.
spring.kafka.consumer.heartbeat-interval= # Expected time in milliseconds between heartbeats to the consumer coordinator.
spring.kafka.consumer.heartbeat-interval= # Expected time between heartbeats to the consumer coordinator.
spring.kafka.consumer.key-deserializer= # Deserializer class for keys.
spring.kafka.consumer.max-poll-records= # Maximum number of records returned in a single call to poll().
spring.kafka.consumer.properties.*= # Additional consumer-specific properties used to configure the client.
@ -980,9 +980,9 @@ content into your application; rather pick only the properties that you need.
spring.kafka.jaas.options= # Additional JAAS options.
spring.kafka.listener.ack-count= # Number of records between offset commits when ackMode is "COUNT" or "COUNT_TIME".
spring.kafka.listener.ack-mode= # Listener AckMode; see the spring-kafka documentation.
spring.kafka.listener.ack-time= # Time in milliseconds between offset commits when ackMode is "TIME" or "COUNT_TIME".
spring.kafka.listener.ack-time= # Time between offset commits when ackMode is "TIME" or "COUNT_TIME".
spring.kafka.listener.concurrency= # Number of threads to run in the listener containers.
spring.kafka.listener.poll-timeout= # Timeout in milliseconds to use when polling the consumer.
spring.kafka.listener.poll-timeout= # Timeout to use when polling the consumer.
spring.kafka.listener.type=single # Listener type.
spring.kafka.producer.acks= # Number of acknowledgments the producer requires the leader to have received before considering a request complete.
spring.kafka.producer.batch-size= # Number of records to batch before sending.
@ -1010,18 +1010,18 @@ content into your application; rather pick only the properties that you need.
# RABBIT ({sc-spring-boot-autoconfigure}/amqp/RabbitProperties.{sc-ext}[RabbitProperties])
spring.rabbitmq.addresses= # Comma-separated list of addresses to which the client should connect.
spring.rabbitmq.cache.channel.checkout-timeout= # Number of milliseconds to wait to obtain a channel if the cache size has been reached.
spring.rabbitmq.cache.channel.checkout-timeout= # Duration to wait to obtain a channel if the cache size has been reached.
spring.rabbitmq.cache.channel.size= # Number of channels to retain in the cache.
spring.rabbitmq.cache.connection.mode=channel # Connection factory cache mode.
spring.rabbitmq.cache.connection.size= # Number of connections to cache.
spring.rabbitmq.connection-timeout= # Connection timeout, in milliseconds; zero for infinite.
spring.rabbitmq.connection-timeout= # Connection timeout; zero for infinite.
spring.rabbitmq.dynamic=true # Create an AmqpAdmin bean.
spring.rabbitmq.host=localhost # RabbitMQ host.
spring.rabbitmq.listener.direct.acknowledge-mode= # Acknowledge mode of container.
spring.rabbitmq.listener.direct.auto-startup=true # Start the container automatically on startup.
spring.rabbitmq.listener.direct.consumers-per-queue= # Number of consumers per queue.
spring.rabbitmq.listener.direct.default-requeue-rejected= # Whether rejected deliveries are requeued by default; default true.
spring.rabbitmq.listener.direct.idle-event-interval= # How often idle container events should be published in milliseconds.
spring.rabbitmq.listener.direct.idle-event-interval= # How often idle container events should be published.
spring.rabbitmq.listener.direct.prefetch= # Number of messages to be handled in a single request. It should be greater than or equal to the transaction size (if used).
spring.rabbitmq.listener.direct.retry.enabled=false # Whether or not publishing retries are enabled.
spring.rabbitmq.listener.direct.retry.initial-interval=1000 # Interval between the first and second attempt to publish or deliver a message.
@ -1033,7 +1033,7 @@ content into your application; rather pick only the properties that you need.
spring.rabbitmq.listener.simple.auto-startup=true # Start the container automatically on startup.
spring.rabbitmq.listener.simple.concurrency= # Minimum number of listener invoker threads.
spring.rabbitmq.listener.simple.default-requeue-rejected= # Whether or not to requeue delivery failures.
spring.rabbitmq.listener.simple.idle-event-interval= # How often idle container events should be published in milliseconds.
spring.rabbitmq.listener.simple.idle-event-interval= # How often idle container events should be published.
spring.rabbitmq.listener.simple.max-concurrency= # Maximum number of listener invoker.
spring.rabbitmq.listener.simple.prefetch= # Number of messages to be handled in a single request. It should be greater than or equal to the transaction size (if used).
spring.rabbitmq.listener.simple.retry.enabled=false # Whether or not publishing retries are enabled.
@ -1048,7 +1048,7 @@ content into your application; rather pick only the properties that you need.
spring.rabbitmq.port=5672 # RabbitMQ port.
spring.rabbitmq.publisher-confirms=false # Enable publisher confirms.
spring.rabbitmq.publisher-returns=false # Enable publisher returns.
spring.rabbitmq.requested-heartbeat= # Requested heartbeat timeout, in seconds; zero for none.
spring.rabbitmq.requested-heartbeat= # Requested heartbeat timeout; zero for none. If a duration suffix is not specified, seconds will be used.
spring.rabbitmq.ssl.enabled=false # Enable SSL support.
spring.rabbitmq.ssl.key-store= # Path to the key store that holds the SSL certificate.
spring.rabbitmq.ssl.key-store-password= # Password used to access the key store.
@ -1122,93 +1122,93 @@ content into your application; rather pick only the properties that you need.
management.endpoints.web.cors.allowed-methods= # Comma-separated list of methods to allow. '*' allows all methods. When not set, defaults to GET.
management.endpoints.web.cors.allowed-origins= # Comma-separated list of origins to allow. '*' allows all origins. When not set, CORS support is disabled.
management.endpoints.web.cors.exposed-headers= # Comma-separated list of headers to include in a response.
management.endpoints.web.cors.max-age=1800 # How long, in seconds, the response from a pre-flight request can be cached by clients.
management.endpoints.web.cors.max-age=1800 # 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.
# AUDIT EVENTS ENDPOINT ({sc-spring-boot-actuator}/audit/AuditEventsEndpoint.{sc-ext}[AuditEventsEndpoint])
management.endpoint.auditevents.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.auditevents.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.auditevents.enabled= # Enable the auditevents endpoint.
# BEANS ENDPOINT ({sc-spring-boot-actuator}/beans/BeansEndpoint.{sc-ext}[BeansEndpoint])
management.endpoint.beans.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.beans.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.beans.enabled= # Enable the beans endpoint.
# CONDITIONS REPORT ENDPOINT ({sc-spring-boot-actuator-autoconfigure}/condition/ConditionsReportEndpoint.{sc-ext}[ConditionsReportEndpoint])
management.endpoint.conditions.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.conditions.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.conditions.enabled= # Enable the conditions endpoint.
# CONFIGURATION PROPERTIES REPORT ENDPOINT ({sc-spring-boot-actuator}/context/properties/ConfigurationPropertiesReportEndpoint.{sc-ext}[ConfigurationPropertiesReportEndpoint])
management.endpoint.configprops.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.configprops.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.configprops.enabled= # Enable the configprops endpoint.
management.endpoint.configprops.keys-to-sanitize=password,secret,key,token,.*credentials.*,vcap_services # Keys that should be sanitized. Keys can be simple strings that the property ends with or regular expressions.
# ENVIRONMENT ENDPOINT ({sc-spring-boot-actuator}/env/EnvironmentEndpoint.{sc-ext}[EnvironmentEndpoint])
management.endpoint.env.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.env.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.env.enabled= # Enable the env endpoint.
management.endpoint.env.keys-to-sanitize=password,secret,key,token,.*credentials.*,vcap_services # Keys that should be sanitized. Keys can be simple strings that the property ends with or regular expressions.
# FLYWAY ENDPOINT ({sc-spring-boot-actuator}/flyway/FlywayEndpoint.{sc-ext}[FlywayEndpoint])
management.endpoint.flyway.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.flyway.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.flyway.enabled= # Enable the flyway endpoint.
# HEALTH ENDPOINT ({sc-spring-boot-actuator}/health/HealthEndpoint.{sc-ext}[HealthEndpoint])
management.endpoint.health.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.health.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.health.enabled= # Enable the health endpoint.
# HEAP DUMP ENDPOINT ({sc-spring-boot-actuator}/management/HeapDumpWebEndpoint.{sc-ext}[HeapDumpWebEndpoint])
management.endpoint.heapdump.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.heapdump.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.heapdump.enabled= # Enable the heapdump endpoint.
# INFO ENDPOINT ({sc-spring-boot-actuator}/info/InfoEndpoint.{sc-ext}[InfoEndpoint])
management.endpoint.info.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.info.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.info.enabled=true # Enable the info endpoint.
# LIQUIBASE ENDPOINT ({sc-spring-boot-actuator}/liquibase/LiquibaseEndpoint.{sc-ext}[LiquibaseEndpoint])
management.endpoint.liquibase.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.liquibase.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.liquibase.enabled= # Enable the liquibase endpoint.
# LOG FILE ENDPOINT ({sc-spring-boot-actuator}/logging/LogFileWebEndpoint.{sc-ext}[LogFileWebEndpoint])
management.endpoint.logfile.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.logfile.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.logfile.enabled= # Enable the logfile endpoint.
management.endpoint.logfile.external-file= # External Logfile to be accessed. Can be used if the logfile is written by output redirect and not by the logging system itself.
# LOGGERS ENDPOINT ({sc-spring-boot-actuator}/logging/LoggersEndpoint.{sc-ext}[LoggersEndpoint])
management.endpoint.loggers.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.loggers.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.loggers.enabled= # Enable the loggers endpoint.
# REQUEST MAPPING ENDPOINT ({sc-spring-boot-actuator-autoconfigure}/web/servlet/RequestMappingEndpoint.{sc-ext}[RequestMappingEndpoint])
management.endpoint.mappings.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.mappings.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.mappings.enabled= # Enable the mappings endpoint.
# METRICS ENDPOINT ({sc-spring-boot-actuator}/metrics/MetricsEndpoint.{sc-ext}[MetricsEndpoint])
management.endpoint.metrics.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.metrics.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.metrics.enabled= # Enable the metrics endpoint.
# PROMETHEUS ENDPOINT ({sc-spring-boot-actuator}/metrics/export/prometheus/PrometheusScrapeEndpoint.{sc-ext}[PrometheusScrapeEndpoint])
management.endpoint.prometheus.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.prometheus.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.prometheus.enabled= # Enable the metrics endpoint.
# SCHEDULED TASKS ENDPOINT ({sc-spring-boot-actuator}/scheduling/ScheduledTasksEndpoint.{sc-ext}[ScheduledTasksEndpoint])
management.endpoint.scheduledtasks.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.scheduledtasks.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.scheduledtasks.enabled= # Enable the scheduled tasks endpoint.
# SESSIONS ENDPOINT ({sc-spring-boot-actuator}/session/SessionsEndpoint.{sc-ext}[SessionsEndpoint])
management.endpoint.sessions.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.sessions.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.sessions.enabled= # Enable the sessions endpoint.
# SHUTDOWN ENDPOINT ({sc-spring-boot-actuator}/context/ShutdownEndpoint.{sc-ext}[ShutdownEndpoint])
management.endpoint.shutdown.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.shutdown.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.shutdown.enabled=false # Enable the shutdown endpoint.
# STATUS ENDPOINT ({sc-spring-boot-actuator}/health/StatusEndpoint.{sc-ext}[StatusEndpoint])
management.endpoint.status.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.status.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.status.enabled=true # Enable the status endpoint.
# THREAD DUMP ENDPOINT ({sc-spring-boot-actuator}/management/ThreadDumpEndpoint.{sc-ext}[ThreadDumpEndpoint])
management.endpoint.threaddump.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.threaddump.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.threaddump.enabled= # Enable the threaddump endpoint.
# TRACE ENDPOINT ({sc-spring-boot-actuator}/trace/TraceEndpoint.{sc-ext}[TraceEndpoint])
management.endpoint.trace.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
management.endpoint.trace.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.trace.enabled= # Enable the trace endpoint.
# HEALTH INDICATORS
@ -1221,7 +1221,7 @@ content into your application; rather pick only the properties that you need.
management.health.diskspace.threshold=0 # Minimum disk space that should be available, in bytes.
management.health.elasticsearch.enabled=true # Enable elasticsearch health check.
management.health.elasticsearch.indices= # Comma-separated index names.
management.health.elasticsearch.response-timeout=100 # The time, in milliseconds, to wait for a response from the cluster.
management.health.elasticsearch.response-timeout=100ms # The time to wait for a response from the cluster.
management.health.jms.enabled=true # Enable JMS health check.
management.health.ldap.enabled=true # Enable LDAP health check.
management.health.mail.enabled=true # Enable Mail health check.
@ -1334,8 +1334,8 @@ content into your application; rather pick only the properties that you need.
spring.devtools.restart.additional-paths= # Additional paths to watch for changes.
spring.devtools.restart.enabled=true # Enable automatic restart.
spring.devtools.restart.exclude=META-INF/maven/**,META-INF/resources/**,resources/**,static/**,public/**,templates/**,**/*Test.class,**/*Tests.class,git.properties # Patterns that should be excluded from triggering a full restart.
spring.devtools.restart.poll-interval=1000 # Amount of time (in milliseconds) to wait between polling for classpath changes.
spring.devtools.restart.quiet-period=400 # Amount of quiet time (in milliseconds) required without any classpath changes before a restart is triggered.
spring.devtools.restart.poll-interval=1s # Amount of time to wait between polling for classpath changes.
spring.devtools.restart.quiet-period=400ms # Amount of quiet time required without any classpath changes before a restart is triggered.
spring.devtools.restart.trigger-file= # Name of a specific file that when changed will trigger the restart check. If not specified any classpath file change will trigger the restart.
# REMOTE DEVTOOLS ({sc-spring-boot-devtools}/autoconfigure/RemoteDevToolsProperties.{sc-ext}[RemoteDevToolsProperties])

View File

@ -107,7 +107,7 @@ public class BinderConversionService implements ConversionService {
service.addConverter(new StringToInetAddressConverter());
service.addConverter(new InetAddressToStringConverter());
service.addConverter(new PropertyEditorConverter());
service.addConverter(new StringToDurationConverter());
service.addConverter(new DurationConverter());
DateFormatterRegistrar registrar = new DateFormatterRegistrar();
DateFormatter formatter = new DateFormatter();
formatter.setIso(DateTimeFormat.ISO.DATE_TIME);

View File

@ -16,6 +16,7 @@
package org.springframework.boot.jta.atomikos;
import java.time.Duration;
import java.util.Properties;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ -40,14 +41,14 @@ public class AtomikosProperties {
private String service;
/**
* Maximum timeout (in milliseconds) that can be allowed for transactions.
* Maximum timeout that can be allowed for transactions.
*/
private long maxTimeout = 300000;
private Duration maxTimeout = Duration.ofMillis(300000);
/**
* Default timeout for JTA transactions.
*/
private long defaultJtaTimeout = 10000;
private Duration defaultJtaTimeout = Duration.ofMillis(10000);
/**
* Maximum number of active transactions.
@ -122,17 +123,16 @@ public class AtomikosProperties {
}
/**
* Specifies the maximum timeout (in milliseconds) that can be allowed for
* transactions. Defaults to {@literal 300000}. This means that calls to
* UserTransaction.setTransactionTimeout() with a value higher than configured here
* will be max'ed to this value.
* Specifies the maximum timeout that can be allowed for transactions. Defaults to
* {@literal 300000}. This means that calls to UserTransaction.setTransactionTimeout()
* with a value higher than configured here will be max'ed to this value.
* @param maxTimeout the max timeout
*/
public void setMaxTimeout(long maxTimeout) {
public void setMaxTimeout(Duration maxTimeout) {
this.maxTimeout = maxTimeout;
}
public long getMaxTimeout() {
public Duration getMaxTimeout() {
return this.maxTimeout;
}
@ -141,11 +141,11 @@ public class AtomikosProperties {
* ms).
* @param defaultJtaTimeout the default JTA timeout
*/
public void setDefaultJtaTimeout(long defaultJtaTimeout) {
public void setDefaultJtaTimeout(Duration defaultJtaTimeout) {
this.defaultJtaTimeout = defaultJtaTimeout;
}
public long getDefaultJtaTimeout() {
public Duration getDefaultJtaTimeout() {
return this.defaultJtaTimeout;
}
@ -332,10 +332,17 @@ public class AtomikosProperties {
private void set(Properties properties, String key, Object value) {
String id = "com.atomikos.icatch." + key;
if (value != null && !properties.containsKey(id)) {
properties.setProperty(id, value.toString());
properties.setProperty(id, asString(value));
}
}
private String asString(Object value) {
if (value instanceof Duration) {
return String.valueOf(((Duration) value).toMillis());
}
return value.toString();
}
/**
* Recovery specific settings.
*/
@ -344,12 +351,12 @@ public class AtomikosProperties {
/**
* Delay after which recovery can cleanup pending ('orphaned') log entries.
*/
private long forgetOrphanedLogEntriesDelay = 86400000;
private Duration forgetOrphanedLogEntriesDelay = Duration.ofMillis(86400000);
/**
* Delay between two recovery scans.
*/
private long delay = 10000;
private Duration delay = Duration.ofMillis(10000);
/**
* Number of retry attempts to commit the transaction before throwing an
@ -360,21 +367,22 @@ public class AtomikosProperties {
/**
* Delay between retry attempts.
*/
private long retryInterval = 10000;
private Duration retryInterval = Duration.ofMillis(10000);
public long getForgetOrphanedLogEntriesDelay() {
public Duration getForgetOrphanedLogEntriesDelay() {
return this.forgetOrphanedLogEntriesDelay;
}
public void setForgetOrphanedLogEntriesDelay(long forgetOrphanedLogEntriesDelay) {
public void setForgetOrphanedLogEntriesDelay(
Duration forgetOrphanedLogEntriesDelay) {
this.forgetOrphanedLogEntriesDelay = forgetOrphanedLogEntriesDelay;
}
public long getDelay() {
public Duration getDelay() {
return this.delay;
}
public void setDelay(long delay) {
public void setDelay(Duration delay) {
this.delay = delay;
}
@ -386,11 +394,11 @@ public class AtomikosProperties {
this.maxRetries = maxRetries;
}
public long getRetryInterval() {
public Duration getRetryInterval() {
return this.retryInterval;
}
public void setRetryInterval(long retryInterval) {
public void setRetryInterval(Duration retryInterval) {
this.retryInterval = retryInterval;
}

View File

@ -52,9 +52,17 @@ public class NarayanaConfigurationBean implements InitializingBean {
setNodeIdentifier(this.properties.getTransactionManagerId());
setObjectStoreDir(this.properties.getLogDir());
setCommitOnePhase(this.properties.isOnePhaseCommit());
setDefaultTimeout(this.properties.getDefaultTimeout());
setPeriodicRecoveryPeriod(this.properties.getPeriodicRecoveryPeriod());
setRecoveryBackoffPeriod(this.properties.getRecoveryBackoffPeriod());
if (this.properties.getDefaultTimeout() != null) {
setDefaultTimeout((int) this.properties.getDefaultTimeout().getSeconds());
}
if (this.properties.getPeriodicRecoveryPeriod() != null) {
setPeriodicRecoveryPeriod(
(int) this.properties.getPeriodicRecoveryPeriod().getSeconds());
}
if (this.properties.getRecoveryBackoffPeriod() != null) {
setRecoveryBackoffPeriod(
(int) this.properties.getRecoveryBackoffPeriod().getSeconds());
}
setXaResourceOrphanFilters(this.properties.getXaResourceOrphanFilters());
setRecoveryModules(this.properties.getRecoveryModules());
setExpiryScanners(this.properties.getExpiryScanners());

View File

@ -16,12 +16,15 @@
package org.springframework.boot.jta.narayana;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.bind.convert.DurationUnit;
/**
* Subset of Narayana properties which can be configured via Spring configuration. Use
@ -54,19 +57,24 @@ public class NarayanaProperties {
private boolean onePhaseCommit = true;
/**
* Transaction timeout in seconds.
* Transaction timeout. If a duration suffix is not specified, seconds will be used.
*/
private int defaultTimeout = 60;
@DurationUnit(ChronoUnit.SECONDS)
private Duration defaultTimeout = Duration.ofSeconds(60);
/**
* Interval in which periodic recovery scans are performed in seconds.
* Interval in which periodic recovery scans are performed. If a duration suffix is
* not specified, seconds will be used.
*/
private int periodicRecoveryPeriod = 120;
@DurationUnit(ChronoUnit.SECONDS)
private Duration periodicRecoveryPeriod = Duration.ofSeconds(120);
/**
* Back off period between first and second phases of the recovery scan in seconds.
* Back off period between first and second phases of the recovery scan. If a duration
* suffix is not specified, seconds will be used.
*/
private int recoveryBackoffPeriod = 10;
@DurationUnit(ChronoUnit.SECONDS)
private Duration recoveryBackoffPeriod = Duration.ofSeconds(10);
/**
* Database username to be used by recovery manager.
@ -132,30 +140,30 @@ public class NarayanaProperties {
this.onePhaseCommit = onePhaseCommit;
}
public int getDefaultTimeout() {
public Duration getDefaultTimeout() {
return this.defaultTimeout;
}
public int getPeriodicRecoveryPeriod() {
public void setDefaultTimeout(Duration defaultTimeout) {
this.defaultTimeout = defaultTimeout;
}
public Duration getPeriodicRecoveryPeriod() {
return this.periodicRecoveryPeriod;
}
public void setPeriodicRecoveryPeriod(int periodicRecoveryPeriod) {
public void setPeriodicRecoveryPeriod(Duration periodicRecoveryPeriod) {
this.periodicRecoveryPeriod = periodicRecoveryPeriod;
}
public int getRecoveryBackoffPeriod() {
public Duration getRecoveryBackoffPeriod() {
return this.recoveryBackoffPeriod;
}
public void setRecoveryBackoffPeriod(int recoveryBackoffPeriod) {
public void setRecoveryBackoffPeriod(Duration recoveryBackoffPeriod) {
this.recoveryBackoffPeriod = recoveryBackoffPeriod;
}
public void setDefaultTimeout(int defaultTimeout) {
this.defaultTimeout = defaultTimeout;
}
public List<String> getXaResourceOrphanFilters() {
return this.xaResourceOrphanFilters;
}

View File

@ -246,7 +246,8 @@ public class JettyServletWebServerFactory extends AbstractServletWebServerFactor
private void configureSession(WebAppContext context) {
SessionHandler handler = context.getSessionHandler();
handler.setMaxInactiveInterval(
getSessionTimeout() > 0 ? getSessionTimeout() : -1);
(getSessionTimeout() == null || getSessionTimeout().isNegative()) ? -1
: (int) getSessionTimeout().getSeconds());
if (isPersistSession()) {
DefaultSessionCache cache = new DefaultSessionCache(handler);
FileSessionDataStore store = new FileSessionDataStore();

View File

@ -22,6 +22,7 @@ import java.lang.reflect.Method;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -32,7 +33,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.servlet.ServletContainerInitializer;
@ -385,11 +385,12 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
}
private long getSessionTimeoutInMinutes() {
long sessionTimeout = getSessionTimeout();
if (sessionTimeout > 0) {
sessionTimeout = Math.max(TimeUnit.SECONDS.toMinutes(sessionTimeout), 1L);
Duration sessionTimeout = getSessionTimeout();
if (sessionTimeout == null || sessionTimeout.isNegative()
|| sessionTimeout.isZero()) {
return 0;
}
return sessionTimeout;
return Math.max(sessionTimeout.toMinutes(), 1);
}
/**

View File

@ -290,7 +290,9 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac
DeploymentManager manager = Servlets.newContainer().addDeployment(deployment);
manager.deploy();
SessionManager sessionManager = manager.getDeployment().getSessionManager();
int sessionTimeout = (getSessionTimeout() > 0 ? getSessionTimeout() : -1);
int sessionTimeout = (getSessionTimeout() == null || getSessionTimeout().isZero()
|| getSessionTimeout().isNegative() ? -1
: (int) getSessionTimeout().toMinutes());
sessionManager.setDefaultSessionTimeout(sessionTimeout);
return manager;
}

View File

@ -19,13 +19,13 @@ package org.springframework.boot.web.servlet.server;
import java.io.File;
import java.net.URL;
import java.nio.charset.Charset;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -52,16 +52,13 @@ public abstract class AbstractServletWebServerFactory
extends AbstractConfigurableWebServerFactory
implements ConfigurableServletWebServerFactory {
private static final int DEFAULT_SESSION_TIMEOUT = (int) TimeUnit.MINUTES
.toSeconds(30);
protected final Log logger = LogFactory.getLog(getClass());
private String contextPath = "";
private String displayName;
private int sessionTimeout = DEFAULT_SESSION_TIMEOUT;
private Duration sessionTimeout = Duration.ofMinutes(30);
private boolean persistSession;
@ -147,24 +144,18 @@ public abstract class AbstractServletWebServerFactory
}
/**
* Return the session timeout in seconds.
* @return the timeout in seconds
* Return the session timeout or {@code null}.
* @return the session timeout
*/
public int getSessionTimeout() {
public Duration getSessionTimeout() {
return this.sessionTimeout;
}
@Override
public void setSessionTimeout(int sessionTimeout) {
public void setSessionTimeout(Duration sessionTimeout) {
this.sessionTimeout = sessionTimeout;
}
@Override
public void setSessionTimeout(int sessionTimeout, TimeUnit timeUnit) {
Assert.notNull(timeUnit, "TimeUnit must not be null");
this.sessionTimeout = (int) timeUnit.toSeconds(sessionTimeout);
}
public boolean isPersistSession() {
return this.persistSession;
}

View File

@ -18,10 +18,10 @@ package org.springframework.boot.web.servlet.server;
import java.io.File;
import java.nio.charset.Charset;
import java.time.Duration;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.MimeMappings;
@ -59,19 +59,11 @@ public interface ConfigurableServletWebServerFactory
void setDisplayName(String displayName);
/**
* The session timeout in seconds (default 30 minutes). If 0 or negative then sessions
* The session timeout in seconds (default 30 minutes). If {@code null} then sessions
* never expire.
* @param sessionTimeout the session timeout
*/
void setSessionTimeout(int sessionTimeout);
/**
* The session timeout in the specified {@link TimeUnit} (default 30 minutes). If 0 or
* negative then sessions never expire.
* @param sessionTimeout the session timeout
* @param timeUnit the time unit
*/
void setSessionTimeout(int sessionTimeout, TimeUnit timeUnit);
void setSessionTimeout(Duration sessionTimeout);
/**
* Sets if session data should be persisted between restarts.

View File

@ -16,6 +16,7 @@
package org.springframework.boot.jta.atomikos;
import java.time.Duration;
import java.util.Properties;
import org.assertj.core.data.MapEntry;
@ -40,8 +41,8 @@ public class AtomikosPropertiesTests {
@Test
public void testProperties() {
this.properties.setService("service");
this.properties.setMaxTimeout(1L);
this.properties.setDefaultJtaTimeout(2L);
this.properties.setMaxTimeout(Duration.ofMillis(1));
this.properties.setDefaultJtaTimeout(Duration.ofMillis(2));
this.properties.setMaxActives(3);
this.properties.setEnableLogging(true);
this.properties.setTransactionManagerUniqueName("uniqueName");
@ -52,10 +53,11 @@ public class AtomikosPropertiesTests {
this.properties.setLogBaseDir("logBaseDir");
this.properties.setCheckpointInterval(4);
this.properties.setThreadedTwoPhaseCommit(true);
this.properties.getRecovery().setForgetOrphanedLogEntriesDelay(2000);
this.properties.getRecovery().setDelay(3000);
this.properties.getRecovery()
.setForgetOrphanedLogEntriesDelay(Duration.ofMillis(2000));
this.properties.getRecovery().setDelay(Duration.ofMillis(3000));
this.properties.getRecovery().setMaxRetries(10);
this.properties.getRecovery().setRetryInterval(4000);
this.properties.getRecovery().setRetryInterval(Duration.ofMillis(4000));
assertThat(this.properties.asProperties().size()).isEqualTo(17);
assertProperty("com.atomikos.icatch.service", "service");
assertProperty("com.atomikos.icatch.max_timeout", "1");

View File

@ -16,6 +16,7 @@
package org.springframework.boot.jta.narayana;
import java.time.Duration;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@ -100,9 +101,9 @@ public class NarayanaConfigurationBeanTests {
NarayanaProperties narayanaProperties = new NarayanaProperties();
narayanaProperties.setTransactionManagerId("test-id");
narayanaProperties.setLogDir("test-dir");
narayanaProperties.setDefaultTimeout(1);
narayanaProperties.setPeriodicRecoveryPeriod(2);
narayanaProperties.setRecoveryBackoffPeriod(3);
narayanaProperties.setDefaultTimeout(Duration.ofSeconds(1));
narayanaProperties.setPeriodicRecoveryPeriod(Duration.ofSeconds(2));
narayanaProperties.setRecoveryBackoffPeriod(Duration.ofSeconds(3));
narayanaProperties.setOnePhaseCommit(false);
narayanaProperties.setXaResourceOrphanFilters(
Arrays.asList("test-filter-1", "test-filter-2"));

View File

@ -17,10 +17,10 @@
package org.springframework.boot.web.embedded.jetty;
import java.nio.charset.Charset;
import java.time.Duration;
import java.util.Arrays;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.apache.jasper.servlet.JspServlet;
import org.eclipse.jetty.server.Handler;
@ -99,14 +99,14 @@ public class JettyServletWebServerFactoryTests
@Test
public void sessionTimeout() throws Exception {
JettyServletWebServerFactory factory = getFactory();
factory.setSessionTimeout(10);
factory.setSessionTimeout(Duration.ofSeconds(10));
assertTimeout(factory, 10);
}
@Test
public void sessionTimeoutInMins() throws Exception {
JettyServletWebServerFactory factory = getFactory();
factory.setSessionTimeout(1, TimeUnit.MINUTES);
factory.setSessionTimeout(Duration.ofMinutes(1));
assertTimeout(factory, 60);
}

View File

@ -20,11 +20,11 @@ import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.Arrays;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.naming.InitialContext;
import javax.naming.NamingException;
@ -187,21 +187,21 @@ public class TomcatServletWebServerFactoryTests
@Test
public void sessionTimeout() throws Exception {
TomcatServletWebServerFactory factory = getFactory();
factory.setSessionTimeout(10);
factory.setSessionTimeout(Duration.ofSeconds(10));
assertTimeout(factory, 1);
}
@Test
public void sessionTimeoutInMins() throws Exception {
TomcatServletWebServerFactory factory = getFactory();
factory.setSessionTimeout(1, TimeUnit.MINUTES);
factory.setSessionTimeout(Duration.ofMinutes(1));
assertTimeout(factory, 1);
}
@Test
public void noSessionTimeout() throws Exception {
TomcatServletWebServerFactory factory = getFactory();
factory.setSessionTimeout(0);
factory.setSessionTimeout(null);
assertTimeout(factory, -1);
}

View File

@ -35,6 +35,7 @@ import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@ -712,7 +713,7 @@ public abstract class AbstractServletWebServerFactoryTests {
@Test
public void defaultSessionTimeout() throws Exception {
assertThat(getFactory().getSessionTimeout()).isEqualTo(30 * 60);
assertThat(getFactory().getSessionTimeout()).isEqualTo(Duration.ofMinutes(30));
}
@Test