This is an automated email from the ASF dual-hosted git repository.
jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new dea5e9c254b Improve exception handling in ControllerLeaderLocator
(#17366)
dea5e9c254b is described below
commit dea5e9c254bf8a841afc2a6c203cff2c86bcc60c
Author: Akanksha kedia <[email protected]>
AuthorDate: Wed Jan 14 07:48:00 2026 +0530
Improve exception handling in ControllerLeaderLocator (#17366)
---
.../server/realtime/ControllerLeaderLocator.java | 39 ++++++++++++++++++----
1 file changed, 33 insertions(+), 6 deletions(-)
diff --git
a/pinot-core/src/main/java/org/apache/pinot/server/realtime/ControllerLeaderLocator.java
b/pinot-core/src/main/java/org/apache/pinot/server/realtime/ControllerLeaderLocator.java
index 2262949cba7..430f3667d0b 100644
---
a/pinot-core/src/main/java/org/apache/pinot/server/realtime/ControllerLeaderLocator.java
+++
b/pinot-core/src/main/java/org/apache/pinot/server/realtime/ControllerLeaderLocator.java
@@ -206,14 +206,41 @@ public class ControllerLeaderLocator {
* @param instanceId instance id without any prefix, e.g. localhost_9000
*/
private Pair<String, Integer> convertToHostAndPortPair(String instanceId) {
- // TODO: improve the exception handling.
- if (instanceId == null) {
+ if (instanceId == null || instanceId.trim().isEmpty()) {
+ LOGGER.warn("Instance ID is null or empty");
+ return null;
+ }
+
+ try {
+ int index = instanceId.lastIndexOf('_');
+ if (index <= 0 || index >= instanceId.length() - 1) {
+ LOGGER.error("Invalid instance ID format: {}. Expected format:
hostname_port", instanceId);
+ return null;
+ }
+
+ String leaderHost = instanceId.substring(0, index);
+ String portStr = instanceId.substring(index + 1);
+
+ if (leaderHost.trim().isEmpty()) {
+ LOGGER.error("Empty hostname in instance ID: {}", instanceId);
+ return null;
+ }
+
+ int leaderPort = Integer.parseInt(portStr);
+ if (leaderPort <= 0 || leaderPort > 65535) {
+ LOGGER.error("Invalid port number {} in instance ID: {}. Port must be
between 1 and 65535",
+ leaderPort, instanceId);
+ return null;
+ }
+
+ return Pair.of(leaderHost, leaderPort);
+ } catch (NumberFormatException e) {
+ LOGGER.error("Failed to parse port number from instance ID: {}. Error:
{}", instanceId, e.getMessage());
+ return null;
+ } catch (Exception e) {
+ LOGGER.error("Unexpected error while parsing instance ID: {}. Error:
{}", instanceId, e.getMessage());
return null;
}
- int index = instanceId.lastIndexOf('_');
- String leaderHost = instanceId.substring(0, index);
- int leaderPort = Integer.parseInt(instanceId.substring(index + 1));
- return Pair.of(leaderHost, leaderPort);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]