Skip to content

Commit fcefa21

Browse files
GroupBy: No need to close over parentSubscription
As per #770 (comment)
1 parent 2765090 commit fcefa21

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

rxjava-core/src/main/java/rx/operators/OperatorGroupBy.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ public OperatorGroupBy(final Func1<? super T, ? extends K> keySelector) {
4444

4545
@Override
4646
public Operator<? super T> call(final Operator<? super GroupedObservable<K, T>> childOperator) {
47-
final CompositeSubscription parentSubscription = new CompositeSubscription();
48-
// a parentSubscription to decouple the subscription as the inner subscriptions need a separate lifecycle
47+
// a new CompositeSubscription to decouple the subscription as the inner subscriptions need a separate lifecycle
4948
// and will unsubscribe on this parent if they are all unsubscribed
50-
return new Operator<T>(parentSubscription) {
49+
return new Operator<T>(new CompositeSubscription()) {
5150
private final Map<K, PublishSubject<T>> groups = new HashMap<K, PublishSubject<T>>();
5251
private final AtomicInteger completionCounter = new AtomicInteger(0);
5352

@@ -132,7 +131,7 @@ public void onNext(T t) {
132131

133132
private void completeInner() {
134133
if (completionCounter.decrementAndGet() == 0) {
135-
parentSubscription.unsubscribe();
134+
unsubscribe();
136135
for (PublishSubject<T> ps : groups.values()) {
137136
ps.onCompleted();
138137
}

0 commit comments

Comments
 (0)