Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,13 @@ private synchronized RemotingCommand updateAndCreateTopicList(ChannelHandlerCont
RemotingCommand request) throws RemotingCommandException {
long startTime = System.currentTimeMillis();


final RemotingCommand response = RemotingCommand.createResponseCommand(null);
if (request.getBody() == null) {
response.setCode(ResponseCode.SYSTEM_ERROR);
response.setRemark("requestBody must not be null");
return response;
}
final CreateTopicListRequestBody requestBody = CreateTopicListRequestBody.decode(request.getBody(), CreateTopicListRequestBody.class);
List<TopicConfig> topicConfigList = requestBody.getTopicConfigList();

Expand All @@ -643,8 +650,6 @@ private synchronized RemotingCommand updateAndCreateTopicList(ChannelHandlerCont
String topicNames = builder.toString();
LOGGER.info("AdminBrokerProcessor#updateAndCreateTopicList: topicNames: {}, called by {}", topicNames, RemotingHelper.parseChannelRemoteAddr(ctx.channel()));

final RemotingCommand response = RemotingCommand.createResponseCommand(null);

long executionTime;

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ public void testProcessRequest_success() throws RemotingCommandException, Unknow
assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS);
}

@Test
public void testProcessRequestBodyNull() throws Throwable {
BrokerConfig brokerConfig = new BrokerConfig();
ResumeCheckHalfMessageRequestHeader header = createResumeCheckHalfMessageRequestHeader();
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_TOPIC_LIST, header);
request.makeCustomHeaderToNet();
RemotingCommand response = adminBrokerProcessor.processRequest(handlerContext, request);
assertThat(response.getCode()).isEqualTo(ResponseCode.SYSTEM_ERROR);
}

@Test
public void testProcessRequest_fail() throws RemotingCommandException, UnknownHostException {
RemotingCommand request = createResumeCheckHalfMessageCommand();
Expand Down
Loading