Skip to content

Commit 341d4ef

Browse files
committed
[ISSUE #9439]:Add escape for win in the method returning broker configuration
1 parent 577371e commit 341d4ef

5 files changed

Lines changed: 13 additions & 0 deletions

File tree

broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,7 @@ private RemotingCommand getBrokerConfig(ChannelHandlerContext ctx, RemotingComma
10661066
String content = this.brokerController.getConfiguration().getAllConfigsFormatString();
10671067
if (content != null && content.length() > 0) {
10681068
try {
1069+
content = MixAll.adjustConfigForPlatform(content);
10691070
response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
10701071
} catch (UnsupportedEncodingException e) {
10711072
LOGGER.error("AdminBrokerProcessor#getBrokerConfig: unexpected error, caller={}",

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,4 +557,13 @@ public static boolean topicAllowsLMQ(String topic) {
557557
&& !topic.startsWith(TopicValidator.SYSTEM_TOPIC_PREFIX)
558558
&& !topic.equals(TopicValidator.RMQ_SYS_SCHEDULE_TOPIC);
559559
}
560+
561+
public static String adjustConfigForPlatform(String config) {
562+
if (StringUtils.isNotBlank(config)) {
563+
if (isWindows()) {
564+
config = config.replace("\\", "\\\\");
565+
}
566+
}
567+
return config;
568+
}
560569
}

container/src/main/java/org/apache/rocketmq/container/BrokerContainerProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ private RemotingCommand getBrokerConfig(ChannelHandlerContext ctx, RemotingComma
291291
String content = this.brokerContainer.getConfiguration().getAllConfigsFormatString();
292292
if (content != null && content.length() > 0) {
293293
try {
294+
content = MixAll.adjustConfigForPlatform(content);
294295
response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
295296
} catch (UnsupportedEncodingException e) {
296297
LOGGER.error("", e);

controller/src/main/java/org/apache/rocketmq/controller/processor/ControllerRequestProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ private RemotingCommand handleGetControllerConfig(ChannelHandlerContext ctx, Rem
311311
String content = this.controllerManager.getConfiguration().getAllConfigsFormatString();
312312
if (content != null && content.length() > 0) {
313313
try {
314+
content = MixAll.adjustConfigForPlatform(content);
314315
response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
315316
} catch (UnsupportedEncodingException e) {
316317
log.error("getConfig error, ", e);

namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@ private RemotingCommand getConfig(ChannelHandlerContext ctx, RemotingCommand req
658658
String content = this.namesrvController.getConfiguration().getAllConfigsFormatString();
659659
if (StringUtils.isNotBlank(content)) {
660660
try {
661+
content = MixAll.adjustConfigForPlatform(content);
661662
response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
662663
} catch (UnsupportedEncodingException e) {
663664
log.error("getConfig error, ", e);

0 commit comments

Comments
 (0)