Copilot commented on code in PR #13513:
URL: https://github.com/apache/skywalking/pull/13513#discussion_r2373856268
##########
oap-server/server-query-plugin/status-query-plugin/src/main/java/org/apache/skywalking/oap/query/debug/AlarmStatusQueryHandler.java:
##########
@@ -137,6 +138,9 @@ public HttpResponse getAlarmRuleContext(@Param("ruleName")
String ruleName, @Par
Map<String, RunningRule> runningRules =
getAlarmRulesWatcher().getRunningContext().values().stream().flatMap(List::stream)
.collect(Collectors.toMap(RunningRule::getRuleName, r -> r));
RunningRule rule = runningRules.get(ruleName);
+ if (rule == null) {
+ return HttpResponse.of(MediaType.JSON_UTF_8, "{}");
+ }
Map<AlarmEntity, RunningRule.Window> windows = rule.getWindows();
RunningRule.Window window = windows.keySet().stream().filter(e ->
e.getName().equals(entityName)).map(windows::get)
.findFirst().orElse(null);
Review Comment:
After adding the null check for `rule` at line 141, there's still a
potential NPE at line 147. The `window` variable can be null from
`orElse(null)` and is used later without null checking. Consider adding a null
check for `window` before its usage.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]