Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Escape backslashes in source string before loading properties #3172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
belljun3395 wants to merge 1 commit into spring-projects:main
base: main
Choose a base branch
Loading
from belljun3395:escape-backslashes-before-loading-properties

Conversation

Copy link

@belljun3395 belljun3395 commented Jun 22, 2025
edited
Loading

Overview

This PR resolves an IllegalArgumentException that occurs when parsing the Redis INFO 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\...). The Converters.toProperties(String) method in spring-data-redis uses java.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 an IllegalArgumentException. 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 calling Properties.load(), all backslashes (\) in the input string are replaced with double backslashes (\\).

Before:

try (StringReader stringReader = new StringReader(source)) {
 info.load(stringReader);
}

After:

String sourceToLoad = source.replace("\\", "\\\\");
try (StringReader stringReader = new StringReader(sourceToLoad)) {
 info.load(stringReader);
}

This simple change ensures that Properties.load() correctly interprets backslashes as literal characters, preventing any parsing errors. The fix is applied to the Converters class, which is shared by both Jedis and Lettuce client implementations, resolving the issue for both drivers.

Related Issue

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

@belljun3395 belljun3395 force-pushed the escape-backslashes-before-loading-properties branch from 862bbe7 to d7cab20 Compare June 22, 2025 05:05
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 23, 2025
Copy link
Member

Thank you @belljun3395. LGTM

belljun3395 and HyunSangHan reacted with heart emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Labels
type: bug A general bug
Projects
None yet
Milestone
No milestone

AltStyle によって変換されたページ (->オリジナル) /