You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/12/28 08:26:15 UTC

[GitHub] [pulsar] eolivelli commented on a diff in pull request #19086: [fix][broker] Reject create non existent persistent partitions.

eolivelli commented on code in PR #19086:
URL: https://github.com/apache/pulsar/pull/19086#discussion_r1058149005


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/persistent/PersistentTopicTest.java:
##########
@@ -402,4 +405,22 @@ public void testUpdateCursorLastActive() throws Exception {
         assertTrue(persistentSubscription.getCursor().getLastActive() > beforeRemoveConsumerTimestamp);
         assertTrue(persistentSubscription2.getCursor().getLastActive() > beforeRemoveConsumerTimestamp);
     }
+
+
+    @Test
+    public void testCreateNonExistentPartitions() throws PulsarAdminException {
+        final String topicName = "non-persistent://prop/ns-abc/testCreateNonExistentPartitions";
+        admin.topics().createPartitionedTopic(topicName, 4);
+        TopicName partition = TopicName.get(topicName).getPartition(4);
+        try {
+            @Cleanup
+            Producer<byte[]> producer = pulsarClient.newProducer()
+                    .topic(partition.toString())
+                    .create();
+            fail("unexpected behaviour");
+        } catch (PulsarClientException ex) {

Review Comment:
   nit: you can catch directly TopicDoesNotExistException and let other exception escape the try block
   
   otherwise if the exception is not the expected the logs won't tell you anything useful



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org