Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2060)

Unified Diff: android_webview/java/src/org/chromium/android_webview/HttpAuthDatabase.java

Issue 143663004: FindBugs: Fix a synchronized method warning in HttpAuthDatabase.java. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update findbugs_known_bugs.txt Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/findbugs_filter/findbugs_known_bugs.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/java/src/org/chromium/android_webview/HttpAuthDatabase.java
diff --git a/android_webview/java/src/org/chromium/android_webview/HttpAuthDatabase.java b/android_webview/java/src/org/chromium/android_webview/HttpAuthDatabase.java
index 6e65e060a7033ecacafdebf90f8060e191e987fe..ad28a732c2c31842eae40a17249fee370bdfe584 100644
--- a/android_webview/java/src/org/chromium/android_webview/HttpAuthDatabase.java
+++ b/android_webview/java/src/org/chromium/android_webview/HttpAuthDatabase.java
@@ -52,6 +52,8 @@ public class HttpAuthDatabase {
*/
private boolean mInitialized = false;
+ private final Object mInitializedLock = new Object();
+
/**
* Create an instance of HttpAuthDatabase for the named file, and kick-off background
* initialization of that database.
@@ -74,16 +76,18 @@ public class HttpAuthDatabase {
* @param context the Context to use for opening the database
* @param databaseFile Name of the file to be initialized.
*/
- private synchronized void initOnBackgroundThread(Context context, String databaseFile) {
- if (mInitialized) {
- return;
- }
+ private void initOnBackgroundThread(Context context, String databaseFile) {
+ synchronized (mInitializedLock) {
+ if (mInitialized) {
+ return;
+ }
- initDatabase(context, databaseFile);
+ initDatabase(context, databaseFile);
- // Thread done, notify.
- mInitialized = true;
- notifyAll();
+ // Thread done, notify.
+ mInitialized = true;
+ notifyAll();
+ }
}
/**
@@ -138,7 +142,7 @@ public class HttpAuthDatabase {
* @return true if the database was initialized, false otherwise
*/
private boolean waitForInit() {
- synchronized (this) {
+ synchronized (mInitializedLock) {
while (!mInitialized) {
try {
wait();
boliu 2014/02/04 23:26:25 This needs to be mInitializedLock.wait() I think.
Lei Zhang 2014/02/05 00:50:42 Thanks. Done.
« no previous file with comments | « no previous file | build/android/findbugs_filter/findbugs_known_bugs.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698