Fixed - Spring Boot Starter doesn't convert properly list of sentinel addresses. #1731

pull/1792/head
Nikita Koksharov 6 years ago
parent bc7ab0e586
commit 82050c404a

@ -19,6 +19,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.redisson.Redisson;
@ -102,9 +103,9 @@ public class RedissonAutoConfiguration {
String[] nodes;
if (nodesValue instanceof String) {
nodes = ((String)nodesValue).split(",");
nodes = convert(Arrays.asList(((String)nodesValue).split(",")));
} else {
nodes = ((List<String>)nodesValue).toArray(new String[((List<String>)nodesValue).size()]);
nodes = convert((List<String>)nodesValue);
}
config = new Config();
@ -119,18 +120,11 @@ public class RedissonAutoConfiguration {
Method nodesMethod = ReflectionUtils.findMethod(clusterObject.getClass(), "getNodes");
List<String> nodesObject = (List) ReflectionUtils.invokeMethod(nodesMethod, clusterObject);
List<String> nodes = new ArrayList<String>();
for (String node : nodesObject) {
if (!node.startsWith("redis://") && !node.startsWith("rediss://")) {
nodes.add("redis://" + node);
} else {
nodes.add(node);
}
}
String[] nodes = convert(nodesObject);
config = new Config();
config.useClusterServers()
.addNodeAddress(nodes.toArray(new String[nodes.size()]))
.addNodeAddress(nodes)
.setConnectTimeout(timeout)
.setPassword(redisProperties.getPassword());
} else {
@ -151,7 +145,19 @@ public class RedissonAutoConfiguration {
return Redisson.create(config);
}
protected InputStream getConfigStream() throws IOException {
private String[] convert(List<String> nodesObject) {
List<String> nodes = new ArrayList<String>(nodesObject.size());
for (String node : nodesObject) {
if (!node.startsWith("redis://") && !node.startsWith("rediss://")) {
nodes.add("redis://" + node);
} else {
nodes.add(node);
}
}
return nodes.toArray(new String[nodes.size()]);
}
private InputStream getConfigStream() throws IOException {
Resource resource = ctx.getResource(redissonProperties.getConfig());
InputStream is = resource.getInputStream();
return is;

Loading…
Cancel
Save