From 7566a197b098492426730b48b5b31d1846881cde Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 15 Dec 2017 10:13:40 +0100 Subject: [PATCH] Fix type for spring.data.cassandra.contact-points Closes gh-11354 --- .../cassandra/CassandraAutoConfiguration.java | 4 +--- .../autoconfigure/cassandra/CassandraProperties.java | 12 ++++++------ .../additional-spring-configuration-metadata.json | 6 ++++++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java index bbe07dbd91..dc90883d95 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java @@ -34,7 +34,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.util.StringUtils; /** * {@link EnableAutoConfiguration Auto-configuration} for Cassandra. @@ -91,8 +90,7 @@ public class CassandraAutoConfiguration { builder.withSSL(); } builder.withPoolingOptions(getPoolingOptions()); - String points = properties.getContactPoints(); - builder.addContactPoints(StringUtils.commaDelimitedListToStringArray(points)); + builder.addContactPoints(properties.getContactPoints().toArray(new String[0])); customize(builder); return builder.build(); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java index 5e37bdd967..52e8ea82c5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java @@ -18,6 +18,9 @@ package org.springframework.boot.autoconfigure.cassandra; import java.time.Duration; import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import com.datastax.driver.core.ConsistencyLevel; import com.datastax.driver.core.ProtocolOptions; @@ -55,7 +58,8 @@ public class CassandraProperties { /** * Comma-separated list of cluster node addresses. */ - private String contactPoints = "localhost"; + private final List contactPoints = new ArrayList<>( + Collections.singleton("localhost")); /** * Port of the Cassandra server. @@ -148,14 +152,10 @@ public class CassandraProperties { this.clusterName = clusterName; } - public String getContactPoints() { + public List getContactPoints() { return this.contactPoints; } - public void setContactPoints(String contactPoints) { - this.contactPoints = contactPoints; - } - public int getPort() { return this.port; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index f9bdc541ca..74683db3ea 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -90,6 +90,12 @@ "name": "spring.datasource.initialization-mode", "defaultValue": "embedded" }, + { + "name": "spring.data.cassandra.contact-points", + "defaultValue": [ + "localhost" + ] + }, { "name": "spring.data.cassandra.compression", "defaultValue": "none"