Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -19,6 +19,7 @@
package org.apache.pulsar.client.impl;

import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
Expand All @@ -33,6 +34,7 @@
import java.util.regex.Pattern;
import java.util.stream.IntStream;

import io.netty.util.Timeout;
import org.apache.pulsar.broker.namespace.NamespaceService;
import org.apache.pulsar.client.api.Consumer;
import org.apache.pulsar.client.api.Message;
Expand Down Expand Up @@ -809,7 +811,9 @@ public void testAutoUnsubscribePatternConsumer() throws Exception {
// 7. call recheckTopics to unsubscribe topic 1,3, verify topics number: 2=6-1-3
log.debug("recheck topics change");
PatternMultiTopicsConsumerImpl<byte[]> consumer1 = ((PatternMultiTopicsConsumerImpl<byte[]>) consumer);
consumer1.run(consumer1.getRecheckPatternTimeout());
Timeout recheckPatternTimeout = spy(consumer1.getRecheckPatternTimeout());
doReturn(false).when(recheckPatternTimeout).isCancelled();
consumer1.run(recheckPatternTimeout);
Thread.sleep(100);
assertEquals(((PatternMultiTopicsConsumerImpl<byte[]>) consumer).getPartitions().size(), 2);
assertEquals(((PatternMultiTopicsConsumerImpl<byte[]>) consumer).getConsumers().size(), 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,7 @@ public void testPartitionsUpdatesForMultipleTopics() throws Exception {
assertEquals(admin.topics().getPartitionedTopicMetadata(topicName1).partitions, 3);

consumer.getRecheckPatternTimeout().task().run(consumer.getRecheckPatternTimeout());
Assert.assertTrue(consumer.getRecheckPatternTimeout().isCancelled());

Awaitility.await().untilAsserted(() -> {
Assert.assertEquals(consumer.getPartitionsOfTheTopicMap(), 8);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ public PatternMultiTopicsConsumerImpl(Pattern topicsPattern,
long watcherId = client.newTopicListWatcherId();
new TopicListWatcher(topicsChangeListener, client, topicsPattern, watcherId,
namespaceName, topicsHash, watcherFuture);
watcherFuture.exceptionally(ex -> {
log.debug("Unable to create topic list watcher. Falling back to only polling for new topics", ex);
return null;
});
watcherFuture
.thenAccept(__ -> recheckPatternTimeout.cancel())
.exceptionally(ex -> {
log.warn("Unable to create topic list watcher. Falling back to only polling for new topics", ex);
return null;
});
} else {
log.debug("Not creating topic list watcher for subscription mode {}", subscriptionMode);
watcherFuture.complete(null);
Expand Down