Escape backslashes in source string before loading properties #3172
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR resolves an
IllegalArgumentException
that occurs when parsing the RedisINFO
command response in a Windows environment. This issue is described in GitHub issue #3099 and is also related to the previously closed issue #1281.The Problem
On Windows, the Redis
INFO
command output can contain values with backslashes (\
), such as the path to the executable (executable:C:\Users\...
). TheConverters.toProperties(String)
method inspring-data-redis
usesjava.util.Properties.load()
internally to parse this response.However,
Properties.load()
treats the backslash as a special escape character. Consequently, it misinterprets sequences like\u
in a file path as a Unicode escape sequence, leading to anIllegalArgumentException
. This poses a challenge for developers working in a Windows environment.The Solution
To address this while preserving the existing code structure, I've introduced a minimal change to the
Converters.toProperties(String)
method. Before callingProperties.load()
, all backslashes (\
) in the input string are replaced with double backslashes (\\
).Before:
After:
This simple change ensures that
Properties.load()
correctly interprets backslashes as literal characters, preventing any parsing errors. The fix is applied to theConverters
class, which is shared by bothJedis
andLettuce
client implementations, resolving the issue for both drivers.Related Issue