Skip to content

Commit b253fc5

Browse files
Copilothengyunabc
andcommitted
Fix NullPointerException when MCP is disabled
Add null check for mcpRequestHandler before accessing getMcpEndpoint() method. This prevents NullPointerException when arthas.mcpEndpoint is set to empty string (MCP disabled) and accessing endpoints like /arthas-output/. Co-authored-by: hengyunabc <1683936+hengyunabc@users.noreply.github.com>
1 parent 069b966 commit b253fc5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

core/src/main/java/com/taobao/arthas/core/shell/term/impl/http/HttpRequestHandler.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,13 @@ protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request)
7676
}
7777

7878
//handle mcp request
79-
String mcpEndpoint = mcpRequestHandler.getMcpEndpoint();
80-
if (mcpEndpoint.equals(path)) {
81-
mcpRequestHandler.handle(ctx, request);
82-
isMcpHandled = true;
83-
return;
79+
if (mcpRequestHandler != null) {
80+
String mcpEndpoint = mcpRequestHandler.getMcpEndpoint();
81+
if (mcpEndpoint.equals(path)) {
82+
mcpRequestHandler.handle(ctx, request);
83+
isMcpHandled = true;
84+
return;
85+
}
8486
}
8587

8688
//handle webui requests

0 commit comments

Comments
 (0)