summaryrefslogtreecommitdiffhomepage
path: root/ui/src/main
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-04-15 01:55:31 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2020-04-15 01:57:55 -0600
commit03e95d2dd37ac86fb7d4068e369412df6c9ac16a (patch)
treed6b00ece318436f4dea087cb39ad1cd77210b177 /ui/src/main
parent58b14cc65019ca0efff4ef296f9d9eacadd9573d (diff)
ObservableTunnel: account for race in renulling stats
The stats might become null between these two checks, when a tunnel flips off, resulting in a null pointer dereference: at com.wireguard.android.model.ObservableTunnel.getStatisticsAsync (ObservableTunnel.java:103) at com.wireguard.android.fragment.TunnelDetailFragment.updateStats (TunnelDetailFragment.java:108) at com.wireguard.android.fragment.TunnelDetailFragment.access$updateStats (TunnelDetailFragment.java:27) at com.wireguard.android.fragment.TunnelDetailFragment$onResume$1.run (TunnelDetailFragment.java:74) at java.util.TimerThread.mainLoop (TimerThread.java:562) at java.util.TimerThread.run (TimerThread.java:512) Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main')
-rw-r--r--ui/src/main/java/com/wireguard/android/model/ObservableTunnel.kt4
1 files changed, 2 insertions, 2 deletions
diff --git a/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.kt b/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.kt
index e7134c51..f8691cbb 100644
--- a/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.kt
+++ b/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.kt
@@ -93,14 +93,14 @@ class ObservableTunnel internal constructor(
@get:Bindable
var statistics: Statistics? = null
get() {
- if (field == null || field!!.isStale)
+ if (field == null || field?.isStale != false)
manager.getTunnelStatistics(this).whenComplete(ExceptionLoggers.E)
return field
}
private set
val statisticsAsync: CompletionStage<Statistics>
- get() = if (statistics == null || statistics!!.isStale)
+ get() = if (statistics == null || statistics?.isStale != false)
manager.getTunnelStatistics(this)
else
CompletableFuture.completedFuture(statistics)