From 594d4fb8c1715dd7bae79a805d4061fa075ef63a Mon Sep 17 00:00:00 2001 From: Andrey G Date: Tue, 19 Mar 2024 19:00:06 +0200 Subject: [PATCH] FMWK-357 Fix setting hosts in configuration (#719) --- .../config/AerospikeDataConfigurationSupport.java | 9 +++++---- .../data/aerospike/convert/AerospikeConverter.java | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/springframework/data/aerospike/config/AerospikeDataConfigurationSupport.java b/src/main/java/org/springframework/data/aerospike/config/AerospikeDataConfigurationSupport.java index ba2af37f0..b0299aec8 100644 --- a/src/main/java/org/springframework/data/aerospike/config/AerospikeDataConfigurationSupport.java +++ b/src/main/java/org/springframework/data/aerospike/config/AerospikeDataConfigurationSupport.java @@ -247,17 +247,18 @@ protected AerospikeSettings aerospikeSettings(AerospikeDataSettings dataSettings // values set via configureDataSettings() have precedence over the parameters from application.properties configureDataSettings(dataSettings); - // getHosts() return value has precedence over hosts parameter from application.properties + // getHosts() has precedence over hosts parameter from application.properties Collection hosts; if ((hosts = getHosts()) != null) { connectionSettings.setHostsArray(hosts.toArray(new Host[0])); - } else if (!StringUtils.hasText(connectionSettings.getHosts())) { + } else if (StringUtils.hasText(connectionSettings.getHosts())) { + connectionSettings.setHostsArray(Host.parseHosts(connectionSettings.getHosts(), getDefaultPort())); + } else { throw new IllegalStateException("No hosts found, please set hosts parameter in application.properties or " + "override getHosts() method"); } - connectionSettings.setHostsArray(Host.parseHosts(connectionSettings.getHosts(), getDefaultPort())); - // nameSpace() return value has precedence over namespace parameter from application.properties + // nameSpace() has precedence over namespace parameter from application.properties String namespace; if ((namespace = nameSpace()) != null) connectionSettings.setNamespace(namespace); diff --git a/src/main/java/org/springframework/data/aerospike/convert/AerospikeConverter.java b/src/main/java/org/springframework/data/aerospike/convert/AerospikeConverter.java index 64b7cd808..b5504ede2 100644 --- a/src/main/java/org/springframework/data/aerospike/convert/AerospikeConverter.java +++ b/src/main/java/org/springframework/data/aerospike/convert/AerospikeConverter.java @@ -29,7 +29,7 @@ public interface AerospikeConverter extends AerospikeReader, AerospikeWr /** * Key that identifies POJO's class. */ - public static final String CLASS_KEY = "@_class"; + String CLASS_KEY = "@_class"; /** * Access Aerospike-specific conversion service.