Merge branch '665-android-executor-npe' into 'master'

Fix potential NPE in AndroidExecutorImpl

Always wait for the startup latch to ensure the background thread's Handler is initialised before using it.

Closes #665.

See merge request !319
This commit is contained in:
Torsten Grote
2016-09-19 16:15:41 +00:00

View File

@@ -39,10 +39,11 @@ class AndroidExecutorImpl implements AndroidExecutor {
}
private void startIfNecessary() {
if (started.getAndSet(true)) return;
Thread t = new Thread(loop, "AndroidExecutor");
t.setDaemon(true);
t.start();
if (!started.getAndSet(true)) {
Thread t = new Thread(loop, "AndroidExecutor");
t.setDaemon(true);
t.start();
}
try {
startLatch.await();
} catch (InterruptedException e) {