Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][broker][branch-2.10] Fast fix infinite HTTP call getSubscriptions caused by wrong topicName #22357

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading