NPE when forum post arrives before parent is loaded
- Android version: 4.1.2
- Phone model: Samsung Galaxy Ace 2 (GT-I8160)
- Briar version: 1.2.15 (885b03cf) (debug build)
The crash happened when I opened a forum from the invitation message in a private conversation, then quickly hit the back button.
Stacktrace:
java.lang.NullPointerException
at org.briarproject.briar.client.MessageTreeImpl.parseNode(MessageTreeImpl.java:74)
at org.briarproject.briar.client.MessageTreeImpl.add(MessageTreeImpl.java:50)
at org.briarproject.briar.client.MessageTreeImpl.add(MessageTreeImpl.java:57)
at org.briarproject.briar.android.threaded.ThreadListViewModel.addItem(ThreadListViewModel.java:200)
at org.briarproject.briar.android.forum.ForumViewModel.eventOccurred(ForumViewModel.java:98)
at org.briarproject.bramble.event.EventBusImpl.lambda$broadcast$0(EventBusImpl.java:42)
at org.briarproject.bramble.event.EventBusImpl.lambda$broadcast$0$EventBusImpl(EventBusImpl.java)
at org.briarproject.bramble.event.-$$Lambda$EventBusImpl$clxOMxNLcHINGTGi9tkg-7meojQ.run(lambda)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4867)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
at dalvik.system.NativeStart.main(Native Method)
Edited log:
02-19 14:29:35.867 I/BaseActivity: Pausing ConversationActivity
02-19 14:29:35.918 I/BaseActivity: Creating ForumActivity
02-19 14:29:36.128 I/BaseActivity: Starting ForumActivity
02-19 14:29:36.129 I/BaseActivity: Resuming ForumActivity
02-19 14:29:36.253 I/DuplexOutgoingSession: Generated ack: true
02-19 14:29:36.254 I/DuplexOutgoingSession: Sent ack
02-19 14:29:36.643 I/BaseActivity: Pausing ForumActivity
02-19 14:29:36.692 I/BaseActivity: Resuming ConversationActivity
02-19 14:29:36.763 I/ForumViewModel: Forum post received, adding...
The message tree assumes that when a message is added, its parent (which is a dependency) is already in the tree.
ForumViewModel logs the amount of time taken to load the message headers and bodies. This is a debug build, so messages logged with logDuration() would appear in the log. Those messages don't appear in the log, so it looks like the new message was added to the tree before the initial load completed, so its parent was present in the DB but not in the tree.