Harmonize configuration properties that accept a list of values

Closes gh-42478
This commit is contained in:
Andy Wilkinson
2024-10-02 10:30:56 +01:00
parent 6b216f1748
commit fae3cd1ca5
26 changed files with 171 additions and 157 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,34 +37,32 @@ import org.springframework.web.cors.CorsConfiguration;
public class CorsEndpointProperties {
/**
* Comma-separated list of origins to allow. '*' allows all origins. When credentials
* are allowed, '*' cannot be used and origin patterns should be configured instead.
* When no allowed origins or allowed origin patterns are set, CORS support is
* disabled.
* List of origins to allow. '*' allows all origins. When credentials are allowed, '*'
* cannot be used and origin patterns should be configured instead. When no allowed
* origins or allowed origin patterns are set, CORS support is disabled.
*/
private List<String> allowedOrigins = new ArrayList<>();
/**
* Comma-separated list of origin patterns to allow. Unlike allowed origins which only
* supports '*', origin patterns are more flexible (for example
* 'https://*.example.com') and can be used when credentials are allowed. When no
* allowed origin patterns or allowed origins are set, CORS support is disabled.
* List of origin patterns to allow. Unlike allowed origins which only supports '*',
* origin patterns are more flexible (for example 'https://*.example.com') and can be
* used when credentials are allowed. When no allowed origin patterns or allowed
* origins are set, CORS support is disabled.
*/
private List<String> allowedOriginPatterns = new ArrayList<>();
/**
* Comma-separated list of methods to allow. '*' allows all methods. When not set,
* defaults to GET.
* List of methods to allow. '*' allows all methods. When not set, defaults to GET.
*/
private List<String> allowedMethods = new ArrayList<>();
/**
* Comma-separated list of headers to allow in a request. '*' allows all headers.
* List of headers to allow in a request. '*' allows all headers.
*/
private List<String> allowedHeaders = new ArrayList<>();
/**
* Comma-separated list of headers to include in a response.
* List of headers to include in a response.
*/
private List<String> exposedHeaders = new ArrayList<>();

View File

@@ -78,7 +78,7 @@ public abstract class HealthProperties {
public static class Status {
/**
* Comma-separated list of health statuses in order of severity.
* List of health statuses in order of severity.
*/
private List<String> order = new ArrayList<>();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -200,7 +200,7 @@ public class MetricsProperties {
public static class Diskspace {
/**
* Comma-separated list of paths to report disk metrics for.
* List of paths to report disk metrics for.
*/
private List<File> paths = new ArrayList<>(Collections.singletonList(new File(".")));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,7 +52,7 @@ class PropertiesRabbitConnectionDetails implements RabbitConnectionDetails {
@Override
public List<Address> getAddresses() {
List<Address> addresses = new ArrayList<>();
for (String address : this.properties.determineAddresses().split(",")) {
for (String address : this.properties.determineAddresses()) {
int portSeparatorIndex = address.lastIndexOf(':');
String host = address.substring(0, portSeparatorIndex);
String port = address.substring(portSeparatorIndex + 1);

View File

@@ -92,10 +92,10 @@ public class RabbitProperties {
private String virtualHost;
/**
* Comma-separated list of addresses to which the client should connect. When set, the
* host and port are ignored.
* List of addresses to which the client should connect. When set, the host and port
* are ignored.
*/
private String addresses;
private List<String> addresses;
/**
* Mode used to shuffle configured addresses.
@@ -163,7 +163,7 @@ public class RabbitProperties {
* Returns the host from the first address, or the configured host if no addresses
* have been set.
* @return the host
* @see #setAddresses(String)
* @see #setAddresses(List)
* @see #getHost()
*/
public String determineHost() {
@@ -185,7 +185,7 @@ public class RabbitProperties {
* Returns the port from the first address, or the configured port if no addresses
* have been set.
* @return the port
* @see #setAddresses(String)
* @see #setAddresses(List)
* @see #getPort()
*/
public int determinePort() {
@@ -203,38 +203,38 @@ public class RabbitProperties {
this.port = port;
}
public String getAddresses() {
public List<String> getAddresses() {
return this.addresses;
}
/**
* Returns the comma-separated addresses or a single address ({@code host:port})
* created from the configured host and port if no addresses have been set.
* Returns the configured addresses or a single address ({@code host:port}) created
* from the configured host and port if no addresses have been set.
* @return the addresses
*/
public String determineAddresses() {
public List<String> determineAddresses() {
if (CollectionUtils.isEmpty(this.parsedAddresses)) {
if (this.host.contains(",")) {
throw new InvalidConfigurationPropertyValueException("spring.rabbitmq.host", this.host,
"Invalid character ','. Value must be a single host. For multiple hosts, use property 'spring.rabbitmq.addresses' instead.");
}
return this.host + ":" + determinePort();
return List.of(this.host + ":" + determinePort());
}
List<String> addressStrings = new ArrayList<>();
for (Address parsedAddress : this.parsedAddresses) {
addressStrings.add(parsedAddress.host + ":" + parsedAddress.port);
}
return StringUtils.collectionToCommaDelimitedString(addressStrings);
return addressStrings;
}
public void setAddresses(String addresses) {
public void setAddresses(List<String> addresses) {
this.addresses = addresses;
this.parsedAddresses = parseAddresses(addresses);
}
private List<Address> parseAddresses(String addresses) {
private List<Address> parseAddresses(List<String> addresses) {
List<Address> parsedAddresses = new ArrayList<>();
for (String address : StringUtils.commaDelimitedListToStringArray(addresses)) {
for (String address : addresses) {
parsedAddresses.add(new Address(address, Optional.ofNullable(getSsl().getEnabled()).orElse(false)));
}
return parsedAddresses;
@@ -248,7 +248,7 @@ public class RabbitProperties {
* If addresses have been set and the first address has a username it is returned.
* Otherwise returns the result of calling {@code getUsername()}.
* @return the username
* @see #setAddresses(String)
* @see #setAddresses(List)
* @see #getUsername()
*/
public String determineUsername() {
@@ -271,7 +271,7 @@ public class RabbitProperties {
* If addresses have been set and the first address has a password it is returned.
* Otherwise returns the result of calling {@code getPassword()}.
* @return the password or {@code null}
* @see #setAddresses(String)
* @see #setAddresses(List)
* @see #getPassword()
*/
public String determinePassword() {
@@ -298,7 +298,7 @@ public class RabbitProperties {
* If addresses have been set and the first address has a virtual host it is returned.
* Otherwise returns the result of calling {@code getVirtualHost()}.
* @return the virtual host or {@code null}
* @see #setAddresses(String)
* @see #setAddresses(List)
* @see #getVirtualHost()
*/
public String determineVirtualHost() {
@@ -471,7 +471,7 @@ public class RabbitProperties {
* Returns whether SSL is enabled from the first address, or the configured ssl
* enabled flag if no addresses have been set.
* @return whether ssl is enabled
* @see #setAddresses(String)
* @see #setAddresses(List)
* @see #getEnabled() ()
*/
public boolean determineEnabled() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,8 +41,8 @@ public class CacheProperties {
private CacheType type;
/**
* Comma-separated list of cache names to create if supported by the underlying cache
* manager. Usually, this disables the ability to create additional caches on-the-fly.
* List of cache names to create if supported by the underlying cache manager.
* Usually, this disables the ability to create additional caches on-the-fly.
*/
private List<String> cacheNames = new ArrayList<>();

View File

@@ -42,6 +42,7 @@ import org.springframework.core.Ordered;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ConcurrentReferenceHashMap;
import org.springframework.util.StringUtils;
@@ -67,9 +68,8 @@ public class MessageSourceAutoConfiguration {
@Bean
public MessageSource messageSource(MessageSourceProperties properties) {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
if (StringUtils.hasText(properties.getBasename())) {
messageSource.setBasenames(StringUtils
.commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(properties.getBasename())));
if (!CollectionUtils.isEmpty(properties.getBasename())) {
messageSource.setBasenames(properties.getBasename().toArray(new String[0]));
}
if (properties.getEncoding() != null) {
messageSource.setDefaultEncoding(properties.getEncoding().name());

View File

@@ -20,6 +20,8 @@ import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
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.convert.DurationUnit;
@@ -35,12 +37,12 @@ import org.springframework.boot.convert.DurationUnit;
public class MessageSourceProperties {
/**
* Comma-separated list of basenames (essentially a fully-qualified classpath
* location), each following the ResourceBundle convention with relaxed support for
* slash based locations. If it doesn't contain a package qualifier (such as
* "org.mypackage"), it will be resolved from the classpath root.
* List of basenames (essentially a fully-qualified classpath location), each
* following the ResourceBundle convention with relaxed support for slash based
* locations. If it doesn't contain a package qualifier (such as "org.mypackage"), it
* will be resolved from the classpath root.
*/
private String basename = "messages";
private List<String> basename = new ArrayList<>(List.of("messages"));
/**
* Message bundles encoding.
@@ -73,11 +75,11 @@ public class MessageSourceProperties {
*/
private boolean useCodeAsDefaultMessage = false;
public String getBasename() {
public List<String> getBasename() {
return this.basename;
}
public void setBasename(String basename) {
public void setBasename(List<String> basename) {
this.basename = basename;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -322,8 +322,8 @@ public class RedisProperties {
public static class Cluster {
/**
* Comma-separated list of "host:port" pairs to bootstrap from. This represents an
* "initial" list of cluster nodes and is required to have at least one entry.
* List of "host:port" pairs to bootstrap from. This represents an "initial" list
* of cluster nodes and is required to have at least one entry.
*/
private List<String> nodes;
@@ -362,7 +362,7 @@ public class RedisProperties {
private String master;
/**
* Comma-separated list of "host:port" pairs.
* List of "host:port" pairs.
*/
private List<String> nodes;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
public class ElasticsearchProperties {
/**
* Comma-separated list of the Elasticsearch instances to use.
* List of the Elasticsearch instances to use.
*/
private List<String> uris = new ArrayList<>(Collections.singletonList("http://localhost:9200"));

View File

@@ -319,8 +319,8 @@ public class FlywayProperties {
private Boolean skipExecutingMigrations;
/**
* Ignore migrations that match this comma-separated list of patterns when validating
* migrations. Requires Flyway Teams.
* List of patterns that identify migrations to ignore when performing validation.
* Requires Flyway Teams.
*/
private List<String> ignoreMigrationPatterns;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ public class FreeMarkerProperties extends AbstractTemplateViewResolverProperties
private Map<String, String> settings = new HashMap<>();
/**
* Comma-separated list of template paths.
* List of template paths.
*/
private String[] templateLoaderPath = new String[] { DEFAULT_TEMPLATE_LOADER_PATH };
@@ -72,6 +72,10 @@ public class FreeMarkerProperties extends AbstractTemplateViewResolverProperties
return this.templateLoaderPath;
}
public void setTemplateLoaderPath(String... templateLoaderPaths) {
this.templateLoaderPath = templateLoaderPaths;
}
public boolean isPreferFileSystemAccess() {
return this.preferFileSystemAccess;
}
@@ -80,8 +84,4 @@ public class FreeMarkerProperties extends AbstractTemplateViewResolverProperties
this.preferFileSystemAccess = preferFileSystemAccess;
}
public void setTemplateLoaderPath(String... templateLoaderPaths) {
this.templateLoaderPath = templateLoaderPaths;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,34 +38,34 @@ import org.springframework.web.cors.CorsConfiguration;
public class GraphQlCorsProperties {
/**
* Comma-separated list of origins to allow with '*' allowing all origins. When
* allow-credentials is enabled, '*' cannot be used, and setting origin patterns
* should be considered instead. When neither allowed origins nor allowed origin
* patterns are set, cross-origin requests are effectively disabled.
* List of origins to allow with '*' allowing all origins. When allow-credentials is
* enabled, '*' cannot be used, and setting origin patterns should be considered
* instead. When neither allowed origins nor allowed origin patterns are set,
* cross-origin requests are effectively disabled.
*/
private List<String> allowedOrigins = new ArrayList<>();
/**
* Comma-separated list of origin patterns to allow. Unlike allowed origins which only
* support '*', origin patterns are more flexible, e.g. 'https://*.example.com', and
* can be used with allow-credentials. When neither allowed origins nor allowed origin
* patterns are set, cross-origin requests are effectively disabled.
* List of origin patterns to allow. Unlike allowed origins which only support '*',
* origin patterns are more flexible, e.g. 'https://*.example.com', and can be used
* with allow-credentials. When neither allowed origins nor allowed origin patterns
* are set, cross-origin requests are effectively disabled.
*/
private List<String> allowedOriginPatterns = new ArrayList<>();
/**
* Comma-separated list of HTTP methods to allow. '*' allows all methods. When not
* set, defaults to GET.
* List of HTTP methods to allow. '*' allows all methods. When not set, defaults to
* GET.
*/
private List<String> allowedMethods = new ArrayList<>();
/**
* Comma-separated list of HTTP headers to allow in a request. '*' allows all headers.
* List of HTTP headers to allow in a request. '*' allows all headers.
*/
private List<String> allowedHeaders = new ArrayList<>();
/**
* Comma-separated list of headers to include in a response.
* List of headers to include in a response.
*/
private List<String> exposedHeaders = new ArrayList<>();

View File

@@ -130,14 +130,14 @@ public class IntegrationProperties {
private boolean throwExceptionOnLateReply = false;
/**
* A comma-separated list of message header names that should not be populated
* into Message instances during a header copying operation.
* List of message header names that should not be populated into Message
* instances during a header copying operation.
*/
private List<String> readOnlyHeaders = new ArrayList<>();
/**
* A comma-separated list of endpoint bean names patterns that should not be
* started automatically during application startup.
* List of endpoint bean names patterns that should not be started automatically
* during application startup.
*/
private List<String> noAutoStartup = new ArrayList<>();
@@ -430,11 +430,10 @@ public class IntegrationProperties {
private boolean defaultLoggingEnabled = true;
/**
* Comma-separated list of simple patterns to match against the names of Spring
* Integration components. When matched, observation instrumentation will be
* performed for the component. Please refer to the javadoc of the smartMatch
* method of Spring Integration's PatternMatchUtils for details of the pattern
* syntax.
* List of simple patterns to match against the names of Spring Integration
* components. When matched, observation instrumentation will be performed for the
* component. Please refer to the javadoc of the smartMatch method of Spring
* Integration's PatternMatchUtils for details of the pattern syntax.
*/
private List<String> observationPatterns = new ArrayList<>();

View File

@@ -177,8 +177,7 @@ public class ActiveMQProperties {
private Boolean trustAll;
/**
* Comma-separated list of specific packages to trust (when not trusting all
* packages).
* List of specific packages to trust (when not trusting all packages).
*/
private List<String> trusted = new ArrayList<>();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -131,12 +131,12 @@ public class ArtemisProperties {
private String dataDirectory;
/**
* Comma-separated list of queues to create on startup.
* List of queues to create on startup.
*/
private String[] queues = new String[0];
/**
* Comma-separated list of topics to create on startup.
* List of topics to create on startup.
*/
private String[] topics = new String[0];

View File

@@ -65,8 +65,8 @@ import org.springframework.util.unit.DataSize;
public class KafkaProperties {
/**
* Comma-delimited list of host:port pairs to use for establishing the initial
* connections to the Kafka cluster. Applies to all components unless overridden.
* List of host:port pairs to use for establishing the initial connections to the
* Kafka cluster. Applies to all components unless overridden.
*/
private List<String> bootstrapServers = new ArrayList<>(Collections.singletonList("localhost:9092"));
@@ -255,8 +255,8 @@ public class KafkaProperties {
private String autoOffsetReset;
/**
* Comma-delimited list of host:port pairs to use for establishing the initial
* connections to the Kafka cluster. Overrides the global property, for consumers.
* List of host:port pairs to use for establishing the initial connections to the
* Kafka cluster. Overrides the global property, for consumers.
*/
private List<String> bootstrapServers;
@@ -483,8 +483,8 @@ public class KafkaProperties {
private DataSize batchSize;
/**
* Comma-delimited list of host:port pairs to use for establishing the initial
* connections to the Kafka cluster. Overrides the global property, for producers.
* List of host:port pairs to use for establishing the initial connections to the
* Kafka cluster. Overrides the global property, for producers.
*/
private List<String> bootstrapServers;
@@ -773,8 +773,8 @@ public class KafkaProperties {
private boolean autoStartup = true;
/**
* Comma-delimited list of host:port pairs to use for establishing the initial
* connections to the Kafka cluster. Overrides the global property, for streams.
* List of host:port pairs to use for establishing the initial connections to the
* Kafka cluster. Overrides the global property, for streams.
*/
private List<String> bootstrapServers;

View File

@@ -52,6 +52,7 @@ import org.springframework.context.annotation.ImportRuntimeHints;
import org.springframework.jdbc.core.ConnectionCallback;
import org.springframework.jdbc.datasource.SimpleDriverDataSource;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
/**
@@ -105,7 +106,9 @@ public class LiquibaseAutoConfiguration {
dataSource.getIfUnique(), connectionDetails);
liquibase.setChangeLog(properties.getChangeLog());
liquibase.setClearCheckSums(properties.isClearChecksums());
liquibase.setContexts(properties.getContexts());
if (!CollectionUtils.isEmpty(properties.getContexts())) {
liquibase.setContexts(StringUtils.collectionToCommaDelimitedString(properties.getContexts()));
}
liquibase.setDefaultSchema(properties.getDefaultSchema());
liquibase.setLiquibaseSchema(properties.getLiquibaseSchema());
liquibase.setLiquibaseTablespace(properties.getLiquibaseTablespace());
@@ -113,7 +116,9 @@ public class LiquibaseAutoConfiguration {
liquibase.setDatabaseChangeLogLockTable(properties.getDatabaseChangeLogLockTable());
liquibase.setDropFirst(properties.isDropFirst());
liquibase.setShouldRun(properties.isEnabled());
liquibase.setLabelFilter(properties.getLabelFilter());
if (!CollectionUtils.isEmpty(properties.getLabelFilter())) {
liquibase.setLabelFilter(StringUtils.collectionToCommaDelimitedString(properties.getLabelFilter()));
}
liquibase.setChangeLogParameters(properties.getParameters());
liquibase.setRollbackFile(properties.getRollbackFile());
liquibase.setTestRollbackOnUpdate(properties.isTestRollbackOnUpdate());

View File

@@ -17,6 +17,7 @@
package org.springframework.boot.autoconfigure.liquibase;
import java.io.File;
import java.util.List;
import java.util.Map;
import liquibase.UpdateSummaryEnum;
@@ -51,9 +52,9 @@ public class LiquibaseProperties {
private boolean clearChecksums;
/**
* Comma-separated list of runtime contexts to use.
* List of runtime contexts to use.
*/
private String contexts;
private List<String> contexts;
/**
* Default database schema.
@@ -112,9 +113,9 @@ public class LiquibaseProperties {
private String url;
/**
* Comma-separated list of runtime labels to use.
* List of runtime labels to use.
*/
private String labelFilter;
private List<String> labelFilter;
/**
* Change log parameters.
@@ -162,11 +163,11 @@ public class LiquibaseProperties {
this.changeLog = changeLog;
}
public String getContexts() {
public List<String> getContexts() {
return this.contexts;
}
public void setContexts(String contexts) {
public void setContexts(List<String> contexts) {
this.contexts = contexts;
}
@@ -266,11 +267,11 @@ public class LiquibaseProperties {
this.url = url;
}
public String getLabelFilter() {
public List<String> getLabelFilter() {
return this.labelFilter;
}
public void setLabelFilter(String labelFilter) {
public void setLabelFilter(List<String> labelFilter) {
this.labelFilter = labelFilter;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -86,13 +86,12 @@ public class ThymeleafProperties {
private Integer templateResolverOrder;
/**
* Comma-separated list of view names (patterns allowed) that can be resolved.
* List of view names (patterns allowed) that can be resolved.
*/
private String[] viewNames;
/**
* Comma-separated list of view names (patterns allowed) that should be excluded from
* resolution.
* List of view names (patterns allowed) that should be excluded from resolution.
*/
private String[] excludedViewNames;

View File

@@ -465,21 +465,21 @@ public class ServerProperties {
private int maxKeepAliveRequests = 100;
/**
* Comma-separated list of additional patterns that match jars to ignore for TLD
* scanning. The special '?' and '*' characters can be used in the pattern to
* match one and only one character and zero or more characters respectively.
* List of additional patterns that match jars to ignore for TLD scanning. The
* special '?' and '*' characters can be used in the pattern to match one and only
* one character and zero or more characters respectively.
*/
private List<String> additionalTldSkipPatterns = new ArrayList<>();
/**
* Comma-separated list of additional unencoded characters that should be allowed
* in URI paths. Only "< > [ \ ] ^ ` { | }" are allowed.
* List of additional unencoded characters that should be allowed in URI paths.
* Only "< > [ \ ] ^ ` { | }" are allowed.
*/
private List<Character> relaxedPathChars = new ArrayList<>();
/**
* Comma-separated list of additional unencoded characters that should be allowed
* in URI query strings. Only "< > [ \ ] ^ ` { | }" are allowed.
* List of additional unencoded characters that should be allowed in URI query
* strings. Only "< > [ \ ] ^ ` { | }" are allowed.
*/
private List<Character> relaxedQueryChars = new ArrayList<>();

View File

@@ -251,8 +251,7 @@ public class WebProperties {
private boolean enabled;
/**
* Comma-separated list of patterns to apply to the content Version
* Strategy.
* List of patterns to apply to the content Version Strategy.
*/
private String[] paths = new String[] { "/**" };
@@ -293,8 +292,7 @@ public class WebProperties {
private boolean enabled;
/**
* Comma-separated list of patterns to apply to the fixed Version
* Strategy.
* List of patterns to apply to the fixed Version Strategy.
*/
private String[] paths = new String[] { "/**" };

View File

@@ -1986,6 +1986,12 @@
"type": "java.lang.Boolean",
"defaultValue": false
},
{
"name": "spring.messages.basename",
"defaultValue": [
"messages"
]
},
{
"name": "spring.mustache.prefix",
"defaultValue": "classpath:/templates/"

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ class PropertiesRabbitConnectionDetailsTests {
@Test
void getAddresses() {
RabbitProperties properties = new RabbitProperties();
properties.setAddresses("localhost,localhost:1234,[::1],[::1]:32863");
properties.setAddresses(List.of("localhost", "localhost:1234", "[::1]", "[::1]:32863"));
PropertiesRabbitConnectionDetails propertiesRabbitConnectionDetails = new PropertiesRabbitConnectionDetails(
properties);
List<Address> addresses = propertiesRabbitConnectionDetails.getAddresses();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.amqp;
import java.util.List;
import com.rabbitmq.client.ConnectionFactory;
import org.junit.jupiter.api.Test;
@@ -54,7 +56,7 @@ class RabbitPropertiesTests {
@Test
void hostIsDeterminedFromFirstAddress() {
this.properties.setAddresses("rabbit1.example.com:1234,rabbit2.example.com:2345");
this.properties.setAddresses(List.of("rabbit1.example.com:1234", "rabbit2.example.com:2345"));
assertThat(this.properties.determineHost()).isEqualTo("rabbit1.example.com");
}
@@ -77,7 +79,7 @@ class RabbitPropertiesTests {
@Test
void determinePortReturnsPortOfFirstAddress() {
this.properties.setAddresses("rabbit1.example.com:1234,rabbit2.example.com:2345");
this.properties.setAddresses(List.of("rabbit1.example.com:1234", "rabbit2.example.com:2345"));
assertThat(this.properties.determinePort()).isEqualTo(1234);
}
@@ -101,19 +103,19 @@ class RabbitPropertiesTests {
@Test
void determinePortReturnsDefaultAmqpPortWhenFirstAddressHasNoExplicitPort() {
this.properties.setPort(1234);
this.properties.setAddresses("rabbit1.example.com,rabbit2.example.com:2345");
this.properties.setAddresses(List.of("rabbit1.example.com", "rabbit2.example.com:2345"));
assertThat(this.properties.determinePort()).isEqualTo(5672);
}
@Test
void determinePortUsingAmqpReturnsPortOfFirstAddress() {
this.properties.setAddresses("amqp://root:password@otherhost,amqps://root:password2@otherhost2");
this.properties.setAddresses(List.of("amqp://root:password@otherhost", "amqps://root:password2@otherhost2"));
assertThat(this.properties.determinePort()).isEqualTo(5672);
}
@Test
void determinePortUsingAmqpsReturnsPortOfFirstAddress() {
this.properties.setAddresses("amqps://root:password@otherhost,amqp://root:password2@otherhost2");
this.properties.setAddresses(List.of("amqps://root:password@otherhost", "amqp://root:password2@otherhost2"));
assertThat(this.properties.determinePort()).isEqualTo(5671);
}
@@ -121,7 +123,7 @@ class RabbitPropertiesTests {
void determinePortReturnsDefaultAmqpsPortWhenFirstAddressHasNoExplicitPortButSslEnabled() {
this.properties.getSsl().setEnabled(true);
this.properties.setPort(1234);
this.properties.setAddresses("rabbit1.example.com,rabbit2.example.com:2345");
this.properties.setAddresses(List.of("rabbit1.example.com", "rabbit2.example.com:2345"));
assertThat(this.properties.determinePort()).isEqualTo(5671);
}
@@ -144,7 +146,7 @@ class RabbitPropertiesTests {
@Test
void determineVirtualHostReturnsVirtualHostOfFirstAddress() {
this.properties.setAddresses("rabbit1.example.com:1234/alpha,rabbit2.example.com:2345/bravo");
this.properties.setAddresses(List.of("rabbit1.example.com:1234/alpha", "rabbit2.example.com:2345/bravo"));
assertThat(this.properties.determineVirtualHost()).isEqualTo("alpha");
}
@@ -157,13 +159,13 @@ class RabbitPropertiesTests {
@Test
void determineVirtualHostReturnsPropertyWhenFirstAddressHasNoVirtualHost() {
this.properties.setVirtualHost("alpha");
this.properties.setAddresses("rabbit1.example.com:1234,rabbit2.example.com:2345/bravo");
this.properties.setAddresses(List.of("rabbit1.example.com:1234", "rabbit2.example.com:2345/bravo"));
assertThat(this.properties.determineVirtualHost()).isEqualTo("alpha");
}
@Test
void determineVirtualHostIsSlashWhenAddressHasTrailingSlash() {
this.properties.setAddresses("amqp://root:password@otherhost:1111/");
this.properties.setAddresses(List.of("amqp://root:password@otherhost:1111/"));
assertThat(this.properties.determineVirtualHost()).isEqualTo("/");
}
@@ -186,7 +188,8 @@ class RabbitPropertiesTests {
@Test
void determineUsernameReturnsUsernameOfFirstAddress() {
this.properties.setAddresses("user:secret@rabbit1.example.com:1234/alpha,rabbit2.example.com:2345/bravo");
this.properties
.setAddresses(List.of("user:secret@rabbit1.example.com:1234/alpha", "rabbit2.example.com:2345/bravo"));
assertThat(this.properties.determineUsername()).isEqualTo("user");
}
@@ -199,7 +202,8 @@ class RabbitPropertiesTests {
@Test
void determineUsernameReturnsPropertyWhenFirstAddressHasNoUsername() {
this.properties.setUsername("alice");
this.properties.setAddresses("rabbit1.example.com:1234/alpha,user:secret@rabbit2.example.com:2345/bravo");
this.properties
.setAddresses(List.of("rabbit1.example.com:1234/alpha", "user:secret@rabbit2.example.com:2345/bravo"));
assertThat(this.properties.determineUsername()).isEqualTo("alice");
}
@@ -216,7 +220,8 @@ class RabbitPropertiesTests {
@Test
void determinePasswordReturnsPasswordOfFirstAddress() {
this.properties.setAddresses("user:secret@rabbit1.example.com:1234/alpha,rabbit2.example.com:2345/bravo");
this.properties
.setAddresses(List.of("user:secret@rabbit1.example.com:1234/alpha", "rabbit2.example.com:2345/bravo"));
assertThat(this.properties.determinePassword()).isEqualTo("secret");
}
@@ -229,7 +234,8 @@ class RabbitPropertiesTests {
@Test
void determinePasswordReturnsPropertyWhenFirstAddressHasNoPassword() {
this.properties.setPassword("12345678");
this.properties.setAddresses("rabbit1.example.com:1234/alpha,user:secret@rabbit2.example.com:2345/bravo");
this.properties
.setAddresses(List.of("rabbit1.example.com:1234/alpha", "user:secret@rabbit2.example.com:2345/bravo"));
assertThat(this.properties.determinePassword()).isEqualTo("12345678");
}
@@ -240,79 +246,80 @@ class RabbitPropertiesTests {
@Test
void customAddresses() {
this.properties.setAddresses("user:secret@rabbit1.example.com:1234/alpha,rabbit2.example.com");
assertThat(this.properties.getAddresses())
.isEqualTo("user:secret@rabbit1.example.com:1234/alpha,rabbit2.example.com");
this.properties.setAddresses(List.of("user:secret@rabbit1.example.com:1234/alpha", "rabbit2.example.com"));
assertThat(this.properties.getAddresses()).containsExactly("user:secret@rabbit1.example.com:1234/alpha",
"rabbit2.example.com");
}
@Test
void ipv6Address() {
this.properties.setAddresses("amqp://foo:bar@[aaaa:bbbb:cccc::d]:1234");
this.properties.setAddresses(List.of("amqp://foo:bar@[aaaa:bbbb:cccc::d]:1234"));
assertThat(this.properties.determineHost()).isEqualTo("[aaaa:bbbb:cccc::d]");
assertThat(this.properties.determinePort()).isEqualTo(1234);
}
@Test
void ipv6AddressDefaultPort() {
this.properties.setAddresses("amqp://foo:bar@[aaaa:bbbb:cccc::d]");
this.properties.setAddresses(List.of("amqp://foo:bar@[aaaa:bbbb:cccc::d]"));
assertThat(this.properties.determineHost()).isEqualTo("[aaaa:bbbb:cccc::d]");
assertThat(this.properties.determinePort()).isEqualTo(5672);
}
@Test
void determineAddressesReturnsAddressesWithJustHostAndPort() {
this.properties.setAddresses("user:secret@rabbit1.example.com:1234/alpha,rabbit2.example.com");
assertThat(this.properties.determineAddresses()).isEqualTo("rabbit1.example.com:1234,rabbit2.example.com:5672");
this.properties.setAddresses(List.of("user:secret@rabbit1.example.com:1234/alpha", "rabbit2.example.com"));
assertThat(this.properties.determineAddresses()).containsExactly("rabbit1.example.com:1234",
"rabbit2.example.com:5672");
}
@Test
void determineAddressesUsesDefaultWhenNoAddressesSet() {
assertThat(this.properties.determineAddresses()).isEqualTo("localhost:5672");
assertThat(this.properties.determineAddresses()).containsExactly("localhost:5672");
}
@Test
void determineAddressesWithSslUsesDefaultWhenNoAddressesSet() {
this.properties.getSsl().setEnabled(true);
assertThat(this.properties.determineAddresses()).isEqualTo("localhost:5671");
assertThat(this.properties.determineAddresses()).containsExactly("localhost:5671");
}
@Test
void determineAddressesUsesHostAndPortPropertiesWhenNoAddressesSet() {
this.properties.setHost("rabbit.example.com");
this.properties.setPort(1234);
assertThat(this.properties.determineAddresses()).isEqualTo("rabbit.example.com:1234");
assertThat(this.properties.determineAddresses()).containsExactly("rabbit.example.com:1234");
}
@Test
void determineAddressesUsesIpv6HostAndPortPropertiesWhenNoAddressesSet() {
this.properties.setHost("[::1]");
this.properties.setPort(32863);
assertThat(this.properties.determineAddresses()).isEqualTo("[::1]:32863");
assertThat(this.properties.determineAddresses()).containsExactly("[::1]:32863");
}
@Test
void determineSslUsingAmqpsReturnsStateOfFirstAddress() {
this.properties.setAddresses("amqps://root:password@otherhost,amqp://root:password2@otherhost2");
this.properties.setAddresses(List.of("amqps://root:password@otherhost", "amqp://root:password2@otherhost2"));
assertThat(this.properties.getSsl().determineEnabled()).isTrue();
}
@Test
void sslDetermineEnabledIsTrueWhenAddressHasNoProtocolAndSslIsEnabled() {
this.properties.getSsl().setEnabled(true);
this.properties.setAddresses("root:password@otherhost");
this.properties.setAddresses(List.of("root:password@otherhost"));
assertThat(this.properties.getSsl().determineEnabled()).isTrue();
}
@Test
void sslDetermineEnabledIsFalseWhenAddressHasNoProtocolAndSslIsDisabled() {
this.properties.getSsl().setEnabled(false);
this.properties.setAddresses("root:password@otherhost");
this.properties.setAddresses(List.of("root:password@otherhost"));
assertThat(this.properties.getSsl().determineEnabled()).isFalse();
}
@Test
void determineSslUsingAmqpReturnsStateOfFirstAddress() {
this.properties.setAddresses("amqp://root:password@otherhost,amqps://root:password2@otherhost2");
this.properties.setAddresses(List.of("amqp://root:password@otherhost", "amqps://root:password2@otherhost2"));
assertThat(this.properties.getSsl().determineEnabled()).isFalse();
}
@@ -360,7 +367,7 @@ class RabbitPropertiesTests {
@Test
void determineUsernameWithoutPassword() {
this.properties.setAddresses("user@rabbit1.example.com:1234/alpha");
this.properties.setAddresses(List.of("user@rabbit1.example.com:1234/alpha"));
assertThat(this.properties.determineUsername()).isEqualTo("user");
assertThat(this.properties.determinePassword()).isEqualTo("guest");
}

View File

@@ -238,7 +238,7 @@ class LiquibaseAutoConfigurationTests {
void overrideContexts() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.contexts:test, production")
.run(assertLiquibase((liquibase) -> assertThat(liquibase.getContexts()).isEqualTo("test, production")));
.run(assertLiquibase((liquibase) -> assertThat(liquibase.getContexts()).isEqualTo("test,production")));
}
@Test
@@ -391,7 +391,7 @@ class LiquibaseAutoConfigurationTests {
void overrideLabelFilter() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.label-filter:test, production")
.run(assertLiquibase((liquibase) -> assertThat(liquibase.getLabelFilter()).isEqualTo("test, production")));
.run(assertLiquibase((liquibase) -> assertThat(liquibase.getLabelFilter()).isEqualTo("test,production")));
}
@Test