Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fix for NPE in TDBatcher #66

Closed
wants to merge 1 commit into from

2 participants

@pegli

I'm not sure how I did it, but I ran into a case where I was getting the following NullPointerException:


     [exec] [DEBUG] E/AndroidRuntime(  340): java.lang.NullPointerException
     [exec] [DEBUG] E/AndroidRuntime(  340):    at com.couchbase.touchdb.support.TDBatcher.flush(TDBatcher.java:75)
     [exec] [DEBUG] E/AndroidRuntime(  340):    at com.couchbase.touchdb.replicator.TDPuller.changeTrackerStopped(TDPuller.java:140)
     [exec] [DEBUG] E/AndroidRuntime(  340):    at com.couchbase.touchdb.replicator.changetracker.TDChangeTracker.stopped(TDChangeTracker.java:304)
     [exec] [DEBUG] E/AndroidRuntime(  340):    at com.couchbase.touchdb.replicator.changetracker.TDChangeTracker.stop(TDChangeTracker.java:297)
     [exec] [DEBUG] E/AndroidRuntime(  340):    at com.couchbase.touchdb.replicator.changetracker.TDChangeTracker.run(TDChangeTracker.java:208)
     [exec] [DEBUG] E/AndroidRuntime(  340):    at java.lang.Thread.run(Thread.java:1096)

Since other parts of TDBatcher were checking to see if the handler object was null, I just added a null check in flush() and it seems to work ok.

@mschoch
Owner

Thanks, I ran into this same one yesterday. I have the patch in my tree already. Unfortunately the replicator is in a sad place right now. Hopefully I make more tangible progress today.

@pegli pegli closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 9, 2012
  1. @pegli
This page is out of date. Refresh to see the latest.
View
4 TouchDB-Android/src/com/couchbase/touchdb/support/TDBatcher.java
@@ -72,7 +72,9 @@ public void queueObject(T object) {
public void flush() {
synchronized(this) {
if(inbox != null) {
- handler.removeCallbacks(processNowRunnable);
+ if (handler != null) {
+ handler.removeCallbacks(processNowRunnable);
+ }
processNow();
}
}
Something went wrong with that request. Please try again.