Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
[improve][broker] Improve error messages when updating partition count (
Browse files Browse the repository at this point in the history
  • Loading branch information
alpreu authored Oct 25, 2023
1 parent 789d284 commit 9a369be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,15 @@ protected CompletableFuture<Void> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9a369be

Please sign in to comment.