Skip to content

Commit 59d6a57

Browse files
committed
Update Observable.isInternalImplementation, get rid of NullPointerException
NullPointerException has been encountered during my tests. It is because java.lang.Class.getPackage() may return null "... if no package information is available from the archive or codebase" (documented feature).
1 parent cdcd75a commit 59d6a57

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3745,7 +3745,8 @@ private boolean isInternalImplementation(Object o) {
37453745
if (o instanceof AtomicObserver)
37463746
return true;
37473747
// we treat the following package as "internal" and don't wrap it
3748-
return o.getClass().getPackage().getName().startsWith("rx.operators");
3748+
Package p = o.getClass().getPackage(); // it can be null
3749+
return p != null && p.getName().startsWith("rx.operators");
37493750
}
37503751

37513752
public static class UnitTest {

0 commit comments

Comments
 (0)