From 871561cd541f3d09ee195dc41dca1087b30d38e7 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 b93f1621cfa..65f348e9b18 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 {