Skip to content

Commit

Permalink
[fix][broker] Fast fix infinite HTTP call getSubscriptions caused by …
Browse files Browse the repository at this point in the history
…wrong topicName
  • Loading branch information
poorbarcode committed Mar 26, 2024
1 parent 9b432d7 commit 35b12f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2222,7 +2222,7 @@ protected void internalCreateSubscription(AsyncResponse asyncResponse, String su
getPartitionedTopicMetadataAsync(topicName, authoritative, allowAutoTopicCreation))
.thenAccept(partitionMetadata -> {
final int numPartitions = partitionMetadata.partitions;
if (numPartitions > 0) {
if (partitionMetadata.partitions > 0 && !isUnexpectedTopicName(partitionMetadata)) {
final CompletableFuture<Void> future = new CompletableFuture<>();
final AtomicInteger count = new AtomicInteger(numPartitions);
final AtomicInteger failureCount = new AtomicInteger(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected void cleanup() throws Exception {
}

@Test
public void testInfiniteHttpCallGetSubscriptions() throws Exception {
public void testInfiniteHttpCallGetOrCreateSubscriptions() throws Exception {
final String randomStr = UUID.randomUUID().toString().replaceAll("-", "");
final String partitionedTopicName = "persistent://my-property/my-ns/tp1_" + randomStr;
final String topic_p0 = partitionedTopicName + TopicName.PARTITIONED_TOPIC_SUFFIX + "0";
Expand All @@ -64,6 +64,7 @@ public void testInfiniteHttpCallGetSubscriptions() throws Exception {
// Do test.
ProducerAndConsumerEntry pcEntry = triggerDLQCreated(topic_p0, topicDLQ, subscriptionName);
admin.topics().getSubscriptions(topicDLQ);
admin.topics().createSubscription(topicDLQ, "s1", MessageId.earliest);

// cleanup.
pcEntry.consumer.close();
Expand All @@ -72,7 +73,7 @@ public void testInfiniteHttpCallGetSubscriptions() throws Exception {
}

@Test
public void testInfiniteHttpCallGetSubscriptions2() throws Exception {
public void testInfiniteHttpCallGetOrCreateSubscriptions2() throws Exception {
final String randomStr = UUID.randomUUID().toString().replaceAll("-", "");
final String topicName = "persistent://my-property/my-ns/tp1_" + randomStr + "-partition-0-abc";
Producer<String> producer = pulsarClient.newProducer(Schema.STRING)
Expand All @@ -81,13 +82,14 @@ public void testInfiniteHttpCallGetSubscriptions2() throws Exception {

// Do test.
admin.topics().getSubscriptions(topicName);
admin.topics().createSubscription(topicName, "s1", MessageId.earliest);

// cleanup.
producer.close();
}

@Test
public void testInfiniteHttpCallGetSubscriptions3() throws Exception {
public void testInfiniteHttpCallGetOrCreateSubscriptions3() throws Exception {
final String randomStr = UUID.randomUUID().toString().replaceAll("-", "");
final String topicName = "persistent://my-property/my-ns/tp1_" + randomStr + "-partition-0";
Producer<String> producer = pulsarClient.newProducer(Schema.STRING)
Expand All @@ -96,6 +98,7 @@ public void testInfiniteHttpCallGetSubscriptions3() throws Exception {

// Do test.
admin.topics().getSubscriptions(topicName);
admin.topics().createSubscription(topicName, "s1", MessageId.earliest);

// cleanup.
producer.close();
Expand Down

0 comments on commit 35b12f7

Please sign in to comment.