Skip to content

Commit

Permalink
Add uncaught exception handler to message retrieval thread
Browse files Browse the repository at this point in the history
Related #6644
// FREEBIE
  • Loading branch information
moxie0 committed Jun 2, 2017
1 parent 711740d commit 5672701
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,14 @@ public static void registerActivityStopped(Context activity) {
return pipe;
}

private class MessageRetrievalThread extends Thread {
private class MessageRetrievalThread extends Thread implements Thread.UncaughtExceptionHandler {

private AtomicBoolean stopThread = new AtomicBoolean(false);

MessageRetrievalThread() {
setUncaughtExceptionHandler(this);
}

@Override
public void run() {
while (!stopThread.get()) {
Expand Down Expand Up @@ -235,5 +239,11 @@ public void onMessage(SignalServiceEnvelope envelope) {
public void stopThread() {
stopThread.set(true);
}

@Override
public void uncaughtException(Thread t, Throwable e) {
Log.w(TAG, "*** Uncaught exception!");
Log.w(TAG, e);
}
}
}

0 comments on commit 5672701

Please sign in to comment.