Commit 83ef62e3 authored by Rob Buis's avatar Rob Buis Committed by Commit Bot

Fix errorprone StaticGuardedByInstance warnings

Fix errorprone StaticGuardedByInstance warnings and make
sure it is treated as error after this CL.

http://errorprone.info/bugpattern/StaticGuardedByInstance

Bug: 803625
Change-Id: Ica786979670c8ec58c07691122e225acc56e62df
Reviewed-on: https://chromium-review.googlesource.com/961041
Commit-Queue: agrieve <agrieve@chromium.org>
Reviewed-by: default avataragrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543078}
parent 18c790fe
......@@ -10,22 +10,23 @@ import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.CalledByNativeUnchecked;
import org.chromium.base.annotations.JNINamespace;
import java.util.concurrent.atomic.AtomicBoolean;
@JNINamespace("base::android")
class JavaHandlerThreadHelpers {
private static class TestException extends Exception {}
private static boolean sTaskExecuted;
// This is executed as part of base_unittests. This tests that JavaHandlerThread can be used
// by itself without attaching to its native peer.
@CalledByNative
private static JavaHandlerThread testAndGetJavaHandlerThread() {
sTaskExecuted = false;
final AtomicBoolean taskExecuted = new AtomicBoolean();
final Object lock = new Object();
Runnable runnable = new Runnable() {
@Override
public void run() {
synchronized (lock) {
sTaskExecuted = true;
taskExecuted.set(true);
lock.notifyAll();
}
}
......@@ -37,7 +38,7 @@ class JavaHandlerThreadHelpers {
Handler handler = new Handler(thread.getLooper());
handler.post(runnable);
synchronized (lock) {
while (!sTaskExecuted) {
while (!taskExecuted.get()) {
try {
lock.wait();
} catch (InterruptedException e) {
......
......@@ -35,8 +35,6 @@ ERRORPRONE_WARNINGS_TO_TURN_OFF = [
'AssertionFailureIgnored',
# TODO(crbug.com/803589): Follow steps in bug.
'MissingFail',
# TODO(crbug.com/803625): Follow steps in bug.
'StaticGuardedByInstance',
# Android platform default is always UTF-8.
# https://developer.android.com/reference/java/nio/charset/Charset.html#defaultCharset()
'DefaultCharset',
......@@ -98,6 +96,7 @@ ERRORPRONE_WARNINGS_TO_ERROR = [
'MissingOverride',
'NarrowingCompoundAssignment',
'ParameterName',
'StaticGuardedByInstance',
'StaticQualifiedUsingExpression',
'UseCorrectAssertInTests',
]
......
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