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>
This commit is contained in:
parent
58b14cc650
commit
03e95d2dd3
@ -93,14 +93,14 @@ class ObservableTunnel internal constructor(
|
|||||||
@get:Bindable
|
@get:Bindable
|
||||||
var statistics: Statistics? = null
|
var statistics: Statistics? = null
|
||||||
get() {
|
get() {
|
||||||
if (field == null || field!!.isStale)
|
if (field == null || field?.isStale != false)
|
||||||
manager.getTunnelStatistics(this).whenComplete(ExceptionLoggers.E)
|
manager.getTunnelStatistics(this).whenComplete(ExceptionLoggers.E)
|
||||||
return field
|
return field
|
||||||
}
|
}
|
||||||
private set
|
private set
|
||||||
|
|
||||||
val statisticsAsync: CompletionStage<Statistics>
|
val statisticsAsync: CompletionStage<Statistics>
|
||||||
get() = if (statistics == null || statistics!!.isStale)
|
get() = if (statistics == null || statistics?.isStale != false)
|
||||||
manager.getTunnelStatistics(this)
|
manager.getTunnelStatistics(this)
|
||||||
else
|
else
|
||||||
CompletableFuture.completedFuture(statistics)
|
CompletableFuture.completedFuture(statistics)
|
||||||
|
Loading…
Reference in New Issue
Block a user