Skip to content

Commit 34122b4

Browse files
Restrict identification of "internal" operators to only the rx.operators package
- based on discussion at ReactiveX#221 - don't wrap at AtomicObserver again - anything outside of rx.operators will be wrapped
1 parent ac3cee8 commit 34122b4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

rxjava-core/src/main/java/rx/Observable.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3325,7 +3325,11 @@ private boolean isInternalImplementation(Object o) {
33253325
if (o == null) {
33263326
return true;
33273327
}
3328-
return (o.getClass().getPackage().getName().startsWith("rx."));
3328+
// prevent double-wrapping (yeah it happens)
3329+
if (o instanceof AtomicObserver)
3330+
return true;
3331+
// we treat the following package as "internal" and don't wrap it
3332+
return o.getClass().getPackage().getName().startsWith("rx.operators");
33293333
}
33303334

33313335
public static class UnitTest {
@@ -3658,11 +3662,7 @@ public void run() {
36583662
}).start();
36593663
return s;
36603664
}
3661-
}).subscribe(new AtomicObserver<String>(new AtomicObservableSubscription(), new Observer<String>() {
3662-
// we are manually wrapping in AtomicObserver here to simulate
3663-
// what will happen when a user provided Observer implementation is passed in
3664-
// since the subscribe method will wrap it in AtomicObserver if it's not in an rx.* package
3665-
3665+
}).subscribe(new Observer<String>() {
36663666
@Override
36673667
public void onCompleted() {
36683668
System.out.println("completed");
@@ -3683,7 +3683,7 @@ public void onNext(String v) {
36833683
count.incrementAndGet();
36843684
}
36853685

3686-
}));
3686+
});
36873687

36883688
// wait for async sequence to complete
36893689
latch.await();

0 commit comments

Comments
 (0)