NPE when storing local socket address
I saw this crash on the Samsung Galaxy Ace 2 (Android 4.1.2) while testing a branch. The relevant code is the same on master.
It's not clear from the stacktrace which of the following methods returned null:
- ServerSocket#getLocalSocketAddress() (docs say is shouldn't return null since the socket is bound, but maybe a race condition?)
- InetSocketAddress#getAddress() (docs say it returns null for an unresolved address - but resolution shouldn't be needed here)
07-03 12:02:39.758 6661-6661/org.briarproject.briar.android.debug I/AndroidNetworkManager: Received broadcast android.net.conn.CONNECTIVITY_CHANGE
07-03 12:03:55.329 6661-6711/org.briarproject.briar.android.debug I/TorPlugin: Online: true, wifi: true
07-03 12:03:55.329 6661-6734/org.briarproject.briar.android.debug I/AndroidLanTcpPlugin: Queue time 3 ms
07-03 12:03:55.339 6661-6711/org.briarproject.briar.android.debug I/TorPlugin: Country code: GB
07-03 12:03:55.339 6661-6734/org.briarproject.briar.android.debug I/AndroidLanTcpPlugin: Connected to wifi
07-03 12:03:55.349 6661-6711/org.briarproject.briar.android.debug I/TorPlugin: Charging: true
07-03 12:03:55.359 6661-6711/org.briarproject.briar.android.debug I/TorPlugin: Enabling network
07-03 12:03:55.359 6661-6711/org.briarproject.briar.android.debug I/TorPlugin: Not using bridges
07-03 12:03:55.359 6661-6711/org.briarproject.briar.android.debug I/TorPlugin: Enabling connection padding
07-03 12:03:55.369 6661-7222/org.briarproject.briar.android.debug I/PluginManagerImpl: org.briarproject.bramble.lan changed from state INACTIVE to ACTIVE
07-03 12:03:55.369 6661-6661/org.briarproject.briar.android.debug I/PluginViewModel: TransportStateEvent: org.briarproject.bramble.lan is ACTIVE
07-03 12:03:55.479 6661-6758/org.briarproject.briar.android.debug I/TorPlugin: NOTICE DisableNetwork is set. Tor will not make or accept non-control network connections. Shutting down all existing connections.
07-03 12:03:55.489 6661-6734/org.briarproject.briar.android.debug I/PollerImpl: Polling plugin org.briarproject.bramble.lan
07-03 12:03:55.639 6661-6758/org.briarproject.briar.android.debug I/TorPlugin: NOTICE DisableNetwork is set. Tor will not make or accept non-control network connections. Shutting down all existing connections.
07-03 12:03:55.639 6661-6711/org.briarproject.briar.android.debug I/RenewableWakeLock: Acquiring wake lock org.briarproject.briar.android.debug
07-03 12:03:55.749 6661-6734/org.briarproject.briar.android.debug I/ConnectionRegistryImpl: 0 contacts connected or better: org.briarproject.bramble.lan
07-03 12:03:55.789 6661-7222/org.briarproject.briar.android.debug I/PluginManagerImpl: Merging settings took 40 ms
07-03 12:03:55.789 6661-7222/org.briarproject.briar.android.debug I/TcpPlugin: Listening on 192.168.1.77
07-03 12:03:55.839 6661-7222/org.briarproject.briar.android.debug I/TcpPlugin: Failed to bind fe[scrubbed]88
07-03 12:03:55.839 6661-7222/org.briarproject.briar.android.debug I/TcpPlugin: Failed to bind fe[scrubbed]88
07-03 12:03:55.839 6661-7222/org.briarproject.briar.android.debug W/dalvikvm: threadid=13: thread exiting with uncaught exception (group=0x4146b2a0)
07-03 12:03:55.859 6661-7222/org.briarproject.briar.android.debug E/ACRA: ACRA caught a NullPointerException for org.briarproject.briar.android.debug
java.lang.NullPointerException
at org.briarproject.bramble.plugin.tcp.LanTcpPlugin.setLocalIpv6SocketAddress(LanTcpPlugin.java:197)
at org.briarproject.bramble.plugin.tcp.LanTcpPlugin.setLocalSocketAddress(LanTcpPlugin.java:188)
at org.briarproject.bramble.plugin.tcp.TcpPlugin.bind(TcpPlugin.java:177)
at org.briarproject.bramble.plugin.tcp.TcpPlugin.lambda$bind$0$TcpPlugin(TcpPlugin.java:148)
at org.briarproject.bramble.plugin.tcp.-$$Lambda$TcpPlugin$uW6V8780O_W211y3Jq96bZYsB4U.run(lambda)
at org.briarproject.bramble.PoliteExecutor.lambda$execute$0$PoliteExecutor(PoliteExecutor.java:57)
at org.briarproject.bramble.-$$Lambda$PoliteExecutor$Lhtp6tpdaSoSplu828CNOD0u06w.run(lambda)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)