Skip to content

Commit 2ab0ae4

Browse files
committed
[ISSUE #9439] utilize MixAll.isWindows for platform-specific escaping
1 parent 577371e commit 2ab0ae4

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

  • common/src/main/java/org/apache/rocketmq/common

common/src/main/java/org/apache/rocketmq/common/MixAll.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,17 @@ public static String properties2String(final Properties properties, final boolea
334334

335335
public static Properties string2Properties(final String str) {
336336
Properties properties = new Properties();
337+
String processedStr = str;
338+
339+
if (isWindows()) {
340+
processedStr = str.replace("\\", "\\\\");
341+
log.info("Detected Windows OS, escaped backslashes for properties string.");
342+
}
337343
try {
338-
InputStream in = new ByteArrayInputStream(str.getBytes(DEFAULT_CHARSET));
344+
InputStream in = new ByteArrayInputStream(processedStr.getBytes(DEFAULT_CHARSET));
339345
properties.load(in);
340346
} catch (Exception e) {
341-
log.error("Failed to handle properties", e);
347+
log.error("Failed to handle properties from string: '{}'", processedStr, e);
342348
return null;
343349
}
344350

0 commit comments

Comments
 (0)