From 59d6a57f9a5e93146bcc83bcdb6f7c26ce644c51 Mon Sep 17 00:00:00 2001 From: rgerasimen Date: Thu, 4 Jul 2013 17:05:48 +0300 Subject: [PATCH] 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). --- rxjava-core/src/main/java/rx/Observable.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rxjava-core/src/main/java/rx/Observable.java b/rxjava-core/src/main/java/rx/Observable.java index b93f1621cf..65f348e9b1 100644 --- a/rxjava-core/src/main/java/rx/Observable.java +++ b/rxjava-core/src/main/java/rx/Observable.java @@ -3745,7 +3745,8 @@ private boolean isInternalImplementation(Object o) { if (o instanceof AtomicObserver) return true; // we treat the following package as "internal" and don't wrap it - return o.getClass().getPackage().getName().startsWith("rx.operators"); + Package p = o.getClass().getPackage(); // it can be null + return p != null && p.getName().startsWith("rx.operators"); } public static class UnitTest {