Skip to content

Commit

Permalink
[fix][broker] Fix NPE when updating topic's properties (apache#17352)
Browse files Browse the repository at this point in the history
Co-authored-by: bjhuxiaohua <[email protected]>
(cherry picked from commit f1d1158)
  • Loading branch information
Flowermin authored and nodece committed Nov 27, 2023
1 parent 09d445c commit 537679f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,8 @@ protected CompletableFuture<Void> internalUpdatePropertiesAsync(boolean authorit
return namespaceResources()
.getPartitionedTopicResources().updatePartitionedTopicAsync(topicName,
p -> new PartitionedTopicMetadata(p.partitions,
MapUtils.putAll(p.properties, properties.entrySet().toArray())));
p.properties == null ? properties
: MapUtils.putAll(p.properties, properties.entrySet().toArray())));
});
}
}).thenAccept(__ ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -909,11 +909,14 @@ public void testUpdatePartitionedTopicProperties() throws Exception {
final String topicNameTwo = "persistent://" + namespace + "/testUpdatePartitionedTopicProperties2";
admin.namespaces().createNamespace(namespace, 20);

// create partitioned topic with properties
// create partitioned topic without properties
admin.topics().createPartitionedTopic(topicName, 2);
Map<String, String> properties = admin.topics().getProperties(topicName);
Assert.assertNull(properties);
Map<String, String> topicProperties = new HashMap<>();
topicProperties.put("key1", "value1");
admin.topics().createPartitionedTopic(topicName, 2, topicProperties);
Map<String, String> properties = admin.topics().getProperties(topicName);
admin.topics().updateProperties(topicName, topicProperties);
properties = admin.topics().getProperties(topicName);
Assert.assertNotNull(properties);
Assert.assertEquals(properties.get("key1"), "value1");

Expand Down

0 comments on commit 537679f

Please sign in to comment.