From a2885e15d590a15b83faea2ddb768cd35de5abd1 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Tue, 23 May 2023 09:58:22 +0300 Subject: [PATCH] Feature - support of the new Redis options for Spring Boot 3.1 #5056 --- .../starter/RedissonAutoConfiguration.java | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/redisson-spring-boot-starter/src/main/java/org/redisson/spring/starter/RedissonAutoConfiguration.java b/redisson-spring-boot-starter/src/main/java/org/redisson/spring/starter/RedissonAutoConfiguration.java index 1a057b35e..a6e09476e 100644 --- a/redisson-spring-boot-starter/src/main/java/org/redisson/spring/starter/RedissonAutoConfiguration.java +++ b/redisson-spring-boot-starter/src/main/java/org/redisson/spring/starter/RedissonAutoConfiguration.java @@ -224,11 +224,7 @@ public class RedissonAutoConfiguration { } } else { config = new Config(); - String prefix = REDIS_PROTOCOL_PREFIX; - Method method = ReflectionUtils.findMethod(RedisProperties.class, "isSsl"); - if (method != null && (Boolean)ReflectionUtils.invokeMethod(method, redisProperties)) { - prefix = REDISS_PROTOCOL_PREFIX; - } + String prefix = getPrefix(); SingleServerConfig c = config.useSingleServer() .setAddress(prefix + redisProperties.getHost() + ":" + redisProperties.getPort()) @@ -251,11 +247,33 @@ public class RedissonAutoConfiguration { return Redisson.create(config); } + private String getPrefix() { + String prefix = REDIS_PROTOCOL_PREFIX; + Method isSSLMethod = ReflectionUtils.findMethod(RedisProperties.class, "isSsl"); + Method getSSLMethod = ReflectionUtils.findMethod(RedisProperties.class, "getSsl"); + if (isSSLMethod != null) { + if ((Boolean) ReflectionUtils.invokeMethod(isSSLMethod, redisProperties)) { + prefix = REDISS_PROTOCOL_PREFIX; + } + } else if (getSSLMethod != null) { + Object ss = ReflectionUtils.invokeMethod(getSSLMethod, redisProperties); + if (ss != null) { + Method isEnabledMethod = ReflectionUtils.findMethod(ss.getClass(), "isEnabled"); + Boolean enabled = (Boolean) ReflectionUtils.invokeMethod(isEnabledMethod, ss); + if (enabled) { + prefix = REDISS_PROTOCOL_PREFIX; + } + } + } + return prefix; + } + private String[] convert(List nodesObject) { - List nodes = new ArrayList(nodesObject.size()); + List nodes = new ArrayList<>(nodesObject.size()); for (String node : nodesObject) { if (!node.startsWith(REDIS_PROTOCOL_PREFIX) && !node.startsWith(REDISS_PROTOCOL_PREFIX)) { - nodes.add(REDIS_PROTOCOL_PREFIX + node); + String prefix = getPrefix(); + nodes.add(prefix + node); } else { nodes.add(node); }