diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java index ad75e723707a6..26170bb56f8c5 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java @@ -675,7 +675,8 @@ protected CompletableFuture 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(__ -> diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApi2Test.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApi2Test.java index cb186ce256af2..d84fab7137f86 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApi2Test.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApi2Test.java @@ -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 properties = admin.topics().getProperties(topicName); + Assert.assertNull(properties); Map topicProperties = new HashMap<>(); topicProperties.put("key1", "value1"); - admin.topics().createPartitionedTopic(topicName, 2, topicProperties); - Map properties = admin.topics().getProperties(topicName); + admin.topics().updateProperties(topicName, topicProperties); + properties = admin.topics().getProperties(topicName); Assert.assertNotNull(properties); Assert.assertEquals(properties.get("key1"), "value1");