From bbdf06f83a429aa76102eb5b0d89a42facbf60b7 Mon Sep 17 00:00:00 2001 From: pedroazevedo-fd Date: Fri, 10 Jan 2025 11:42:37 +0000 Subject: [PATCH] fix: Decode ComponentId to avoid UI throwing errors --- .../apache/storm/daemon/nimbus/Nimbus.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java b/storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java index c84572270dc..74610cbe952 100644 --- a/storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java +++ b/storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java @@ -35,9 +35,11 @@ import java.io.OutputStream; import java.net.BindException; import java.net.ServerSocket; +import java.net.URLDecoder; import java.nio.ByteBuffer; import java.nio.channels.Channels; import java.nio.channels.WritableByteChannel; +import java.nio.charset.StandardCharsets; import java.security.Principal; import java.util.ArrayList; import java.util.Arrays; @@ -4717,26 +4719,27 @@ public ComponentPageInfo getComponentPageInfo(String topoId, String componentId, nodeToHost = Collections.emptyMap(); } + String sanitizedComponentId = URLDecoder.decode(componentId, StandardCharsets.UTF_8); ComponentPageInfo compPageInfo = StatsUtil.aggCompExecsStats(exec2HostPort, info.taskToComponent, info.beats, window, - includeSys, topoId, topology, componentId); + includeSys, topoId, topology, sanitizedComponentId); if (compPageInfo.get_component_type() == ComponentType.SPOUT) { - NormalizedResourceRequest spoutResources = ResourceUtils.getSpoutResources(topology, topoConf, componentId); + NormalizedResourceRequest spoutResources = ResourceUtils.getSpoutResources(topology, topoConf, sanitizedComponentId); if (spoutResources == null) { - spoutResources = new NormalizedResourceRequest(topoConf, componentId); + spoutResources = new NormalizedResourceRequest(topoConf, sanitizedComponentId); } compPageInfo.set_resources_map(spoutResources.toNormalizedMap()); } else { //bolt - NormalizedResourceRequest boltResources = ResourceUtils.getBoltResources(topology, topoConf, componentId); + NormalizedResourceRequest boltResources = ResourceUtils.getBoltResources(topology, topoConf, sanitizedComponentId); if (boltResources == null) { - boltResources = new NormalizedResourceRequest(topoConf, componentId); + boltResources = new NormalizedResourceRequest(topoConf, sanitizedComponentId); } compPageInfo.set_resources_map(boltResources.toNormalizedMap()); } compPageInfo.set_topology_name(info.topoName); - compPageInfo.set_errors(stormClusterState.errors(topoId, componentId)); + compPageInfo.set_errors(stormClusterState.errors(topoId, sanitizedComponentId)); compPageInfo.set_topology_status(extractStatusStr(info.base)); if (info.base.is_set_component_debug()) { - DebugOptions debug = info.base.get_component_debug().get(componentId); + DebugOptions debug = info.base.get_component_debug().get(sanitizedComponentId); if (debug != null) { compPageInfo.set_debug_options(debug); } @@ -4747,7 +4750,7 @@ public ComponentPageInfo getComponentPageInfo(String topoId, String componentId, List tasks = compToTasks.get(StormCommon.EVENTLOGGER_COMPONENT_ID); tasks.sort(null); // Find the task the events from this component route to. - int taskIndex = TupleUtils.chooseTaskIndex(Collections.singletonList(componentId), tasks.size()); + int taskIndex = TupleUtils.chooseTaskIndex(Collections.singletonList(sanitizedComponentId), tasks.size()); int taskId = tasks.get(taskIndex); String host = null; Integer port = null;