Commit f1e3e026 authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Fix race condition in SafetyCheckUpdatesDelegateImpl

Likely pretty innocuous, but it's possible a GC could happen between the
two weakRef.get() calls.

Bug: None
Change-Id: I345fac7f72a70cef8aed80a834b47f3514d7f51a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2477048
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarAndrey Zaytsev <andzaytsev@google.com>
Commit-Queue: Andrey Zaytsev <andzaytsev@google.com>
Cr-Commit-Position: refs/heads/master@{#818446}
parent 36bea98c
...@@ -68,8 +68,9 @@ public class SafetyCheckUpdatesDelegateImpl implements SafetyCheckUpdatesDelegat ...@@ -68,8 +68,9 @@ public class SafetyCheckUpdatesDelegateImpl implements SafetyCheckUpdatesDelegat
int status = mOmaha.checkForUpdates(); int status = mOmaha.checkForUpdates();
// Post the results back to the UI thread. // Post the results back to the UI thread.
PostTask.postTask(UiThreadTaskTraits.DEFAULT, () -> { PostTask.postTask(UiThreadTaskTraits.DEFAULT, () -> {
if (statusCallback.get() != null) { Callback<Integer> strongRef = statusCallback.get();
statusCallback.get().onResult(convertOmahaUpdateStatus(status)); if (strongRef != null) {
strongRef.onResult(convertOmahaUpdateStatus(status));
} }
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment