This is an automated email from the ASF dual-hosted git repository.
tuglu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new 22776112f60 Fix potential NPE in broker dynamic config syncer
22776112f60 is described below
commit 22776112f609510b271ad552de77668799e47577
Author: jtuglu1 <[email protected]>
AuthorDate: Wed Mar 11 22:11:49 2026 -0700
Fix potential NPE in broker dynamic config syncer
Fix potential NPE in broker dynamic config syncer. Probably unlikely, but
might as well handle gracefully.
---
.../druid/server/http/BaseDynamicConfigSyncer.java | 4 ++++
.../http/CoordinatorDynamicConfigSyncerTest.java | 26 ++++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git
a/server/src/main/java/org/apache/druid/server/http/BaseDynamicConfigSyncer.java
b/server/src/main/java/org/apache/druid/server/http/BaseDynamicConfigSyncer.java
index db608d6e27e..9c74298e34e 100644
---
a/server/src/main/java/org/apache/druid/server/http/BaseDynamicConfigSyncer.java
+++
b/server/src/main/java/org/apache/druid/server/http/BaseDynamicConfigSyncer.java
@@ -180,6 +180,9 @@ public abstract class BaseDynamicConfigSyncer<DynamicConfig>
{
final Stopwatch stopwatch = Stopwatch.createStarted();
final ServiceLocation brokerLocation =
convertDiscoveryNodeToServiceLocation(broker);
+ if (brokerLocation == null) {
+ return;
+ }
final BrokerClient brokerClient = new BrokerClientImpl(
clientFactory.makeClient(
NodeRole.BROKER.getJsonName(),
@@ -255,6 +258,7 @@ public abstract class BaseDynamicConfigSyncer<DynamicConfig>
{
final DruidNode druidNode = discoveryDruidNode.getDruidNode();
if (druidNode == null) {
+ log.warn("Could not determine DruidNode for DiscoveryDruidNode[%s]",
discoveryDruidNode);
return null;
}
diff --git
a/server/src/test/java/org/apache/druid/server/http/CoordinatorDynamicConfigSyncerTest.java
b/server/src/test/java/org/apache/druid/server/http/CoordinatorDynamicConfigSyncerTest.java
index 2764ab0e6f1..526469203e6 100644
---
a/server/src/test/java/org/apache/druid/server/http/CoordinatorDynamicConfigSyncerTest.java
+++
b/server/src/test/java/org/apache/druid/server/http/CoordinatorDynamicConfigSyncerTest.java
@@ -103,4 +103,30 @@ public class CoordinatorDynamicConfigSyncerTest
.jsonContent(DefaultObjectMapper.INSTANCE, config);
verify(serviceClient).asyncRequest(eq(requestBuilder),
ArgumentMatchers.any());
}
+
+ @Test
+ public void testSync_whenDruidNode_isNull()
+ {
+ CoordinatorDynamicConfig config = CoordinatorDynamicConfig
+ .builder()
+ .withMaxSegmentsToMove(105)
+ .withReplicantLifetime(500)
+ .withReplicationThrottleLimit(5)
+ .build();
+
+ doReturn(config).when(coordinatorConfigManager).getCurrentDynamicConfig();
+ List<DiscoveryDruidNode> nodes = List.of(
+ new DiscoveryDruidNode(
+ null,
+ NodeRole.BROKER,
+ null,
+ null
+ )
+ );
+ doReturn(nodes).when(druidNodeDiscovery).getAllNodes();
+
+ target.broadcastConfigToBrokers();
+ RequestBuilder requestBuilder = new RequestBuilder(HttpMethod.POST,
"/druid-internal/v1/config/coordinator")
+ .jsonContent(DefaultObjectMapper.INSTANCE, config);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]