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

[12.0.x] ISPN-13229 LocalPublisherManagerImpl doesn't clean up changeListener … #10583

Merged
merged 1 commit into from Jan 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -34,7 +34,6 @@
import org.infinispan.factories.impl.ComponentRef;
import org.infinispan.factories.scopes.Scope;
import org.infinispan.factories.scopes.Scopes;
import org.infinispan.commons.reactive.RxJavaInterop;
import org.infinispan.reactive.publisher.impl.commands.reduction.PublisherResult;
import org.infinispan.reactive.publisher.impl.commands.reduction.SegmentPublisherResult;
import org.infinispan.stream.StreamMarshalling;
Expand Down Expand Up @@ -241,19 +240,18 @@ private SegmentAwarePublisherImpl(IntSet segments, CacheSet<I> set,

@Override
public void subscribe(Subscriber<? super R> s, IntConsumer completedSegmentConsumer, IntConsumer lostSegmentConsumer) {
Flowable<Publisher<R>> segmentPublishers;
Flowable<R> resultPublisher;
switch (deliveryGuarantee) {
case AT_MOST_ONCE:
segmentPublishers = Flowable.fromStream(segments.intStream().mapToObj(segment -> {
Publisher<I> publisher = set.localPublisher(segment);
if (predicate != null) {
publisher = Flowable.fromPublisher(publisher)
.filter(predicate);
}
resultPublisher = Flowable.fromIterable(segments).concatMap(segment -> {
Publisher<I> publisher = set.localPublisher(segment);
if (predicate != null) {
publisher = Flowable.fromPublisher(publisher)
.filter(predicate);
}
return Flowable.fromPublisher(transformer.apply(publisher))
.doOnComplete(() -> completedSegmentConsumer.accept(segment));
}));

});
break;
case AT_LEAST_ONCE:
case EXACTLY_ONCE:
Expand All @@ -265,7 +263,7 @@ public void subscribe(Subscriber<? super R> s, IntConsumer completedSegmentConsu
// Check topology before submitting
listener.verifyTopology(distributionManager.getCacheTopology());

segmentPublishers = Flowable.fromStream(segments.intStream().mapToObj(segment -> {
resultPublisher = Flowable.fromIterable(segments).concatMap(segment -> {
if (!concurrentSet.contains(segment)) {
return Flowable.empty();
}
Expand All @@ -282,13 +280,13 @@ public void subscribe(Subscriber<? super R> s, IntConsumer completedSegmentConsu
lostSegmentConsumer.accept(segment);
}
});
}));
}).doFinally(() -> changeListener.remove(listener));
break;
default:
throw new UnsupportedOperationException("Unsupported delivery guarantee: " + deliveryGuarantee);
}

segmentPublishers.concatMap(RxJavaInterop.identityFunction()).subscribe(s);
resultPublisher.subscribe(s);
}
}

Expand Down