Skip to content

Commit

Permalink
fix NPE to update topic properties
Browse files Browse the repository at this point in the history
  • Loading branch information
bjhuxiaohua committed Aug 30, 2022
1 parent 2f4af65 commit 6cddfa9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,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 @@ -894,14 +894,17 @@ public void testUpdatePartitionedTopicProperties() throws Exception {
final String topicName = "persistent://" + namespace + "/testUpdatePartitionedTopicProperties";
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");

// update with new key, old properties should keep
topicProperties = new HashMap<>();
topicProperties.put("key2", "value2");
Expand Down

0 comments on commit 6cddfa9

Please sign in to comment.