From 3d13dae790e0b1e1e0ec3d744ace04af52c24fd4 Mon Sep 17 00:00:00 2001 From: Hoolefu Date: Mon, 30 Mar 2020 20:35:24 +0800 Subject: [PATCH] [ISSUE#728]check ChannelHandlerContext whether is null [ISSUE#728]check ChannelHandlerContext whether is null --- .../processor/DefaultRequestProcessor.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java index d62be47b..44a2b6f2 100644 --- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java +++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java @@ -384,10 +384,12 @@ public class DefaultRequestProcessor extends AsyncNettyRequestProcessor implemen int wipeTopicCnt = this.namesrvController.getRouteInfoManager().wipeWritePermOfBrokerByLock(requestHeader.getBrokerName()); - log.info("wipe write perm of broker[{}], client: {}, {}", - requestHeader.getBrokerName(), - RemotingHelper.parseChannelRemoteAddr(ctx.channel()), - wipeTopicCnt); + if (ctx != null) { + log.info("wipe write perm of broker[{}], client: {}, {}", + requestHeader.getBrokerName(), + RemotingHelper.parseChannelRemoteAddr(ctx.channel()), + wipeTopicCnt); + } responseHeader.setWipeTopicCount(wipeTopicCnt); response.setCode(ResponseCode.SUCCESS); @@ -502,7 +504,9 @@ public class DefaultRequestProcessor extends AsyncNettyRequestProcessor implemen } private RemotingCommand updateConfig(ChannelHandlerContext ctx, RemotingCommand request) { - log.info("updateConfig called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel())); + if (ctx != null) { + log.info("updateConfig called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel())); + } final RemotingCommand response = RemotingCommand.createResponseCommand(null); @@ -518,13 +522,6 @@ public class DefaultRequestProcessor extends AsyncNettyRequestProcessor implemen return response; } - if (bodyStr == null) { - log.error("updateConfig get null body!"); - response.setCode(ResponseCode.SYSTEM_ERROR); - response.setRemark("string2Properties error"); - return response; - } - Properties properties = MixAll.string2Properties(bodyStr); if (properties == null) { log.error("updateConfig MixAll.string2Properties error {}", bodyStr); -- GitLab