From 9a369be004ee69764ecc68e6f16fd1cad861b2aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Preu=C3=9F?= <11444089+alpreu@users.noreply.github.com> Date: Wed, 25 Oct 2023 04:12:28 +0200 Subject: [PATCH] [improve][broker] Improve error messages when updating partition count (#21243) --- .../pulsar/broker/admin/impl/PersistentTopicsBase.java | 5 +++-- .../org/apache/pulsar/broker/admin/PersistentTopicsTest.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) 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 790902d70e8ac..eac4335a26d2d 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 @@ -354,14 +354,15 @@ protected CompletableFuture internalCreateNonPartitionedTopicAsync(boolean } if (expectPartitions < currentMetadataPartitions) { throw new RestException(422 /* Unprocessable entity*/, - String.format("Expect partitions %s can't less than current partitions %s.", + String.format("Desired partitions %s can't be less than the current partitions %s.", expectPartitions, currentMetadataPartitions)); } int brokerMaximumPartitionsPerTopic = pulsarService.getConfiguration() .getMaxNumPartitionsPerPartitionedTopic(); if (brokerMaximumPartitionsPerTopic != 0 && expectPartitions > brokerMaximumPartitionsPerTopic) { throw new RestException(422 /* Unprocessable entity*/, - String.format("Expect partitions %s grater than maximum partitions per topic %s", + String.format("Desired partitions %s can't be greater than the maximum partitions per" + + " topic %s.", expectPartitions, brokerMaximumPartitionsPerTopic)); } final PulsarAdmin admin; diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java index 4da7da4e0f9a6..01e76aeb6f6d3 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java @@ -1665,7 +1665,7 @@ public void testUpdatePartitionedTopic() true, 3); verify(response, timeout(5000).times(1)).resume(throwableCaptor.capture()); Assert.assertEquals(throwableCaptor.getValue().getMessage(), - "Expect partitions 3 can't less than current partitions 4."); + "Desired partitions 3 can't be less than the current partitions 4."); response = mock(AsyncResponse.class); metaCaptor = ArgumentCaptor.forClass(PartitionedTopicMetadata.class);