From 4ec53f69f4454c52f94c29af761ca17e46447721 Mon Sep 17 00:00:00 2001 From: Jeff Tao Date: Mon, 14 Oct 2024 16:10:54 +0800 Subject: [PATCH] Optimize duplicate code in `StringToPropertiesConverter`. --- .../convert/StringToPropertiesConverter.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/springframework/data/redis/connection/convert/StringToPropertiesConverter.java b/src/main/java/org/springframework/data/redis/connection/convert/StringToPropertiesConverter.java index 7f8889eabc..7f70d10bb1 100644 --- a/src/main/java/org/springframework/data/redis/connection/convert/StringToPropertiesConverter.java +++ b/src/main/java/org/springframework/data/redis/connection/convert/StringToPropertiesConverter.java @@ -15,29 +15,22 @@ */ package org.springframework.data.redis.connection.convert; -import java.io.StringReader; import java.util.Properties; import org.springframework.core.convert.converter.Converter; -import org.springframework.data.redis.RedisSystemException; /** * Converts Strings to {@link Properties} * * @author Jennifer Hickey * @author Christoph Strobl + * @author Jeff Tao */ public class StringToPropertiesConverter implements Converter { @Override public Properties convert(String source) { - Properties info = new Properties(); - try (StringReader stringReader = new StringReader(source)) { - info.load(stringReader); - } catch (Exception ex) { - throw new RedisSystemException("Cannot read Redis info", ex); - } - return info; + return Converters.toProperties(source); } }