Commit 039c278e authored by thestig@chromium.org's avatar thestig@chromium.org

FindBugs: Fix a synchronized method warning in HttpAuthDatabase.java.

Review URL: https://codereview.chromium.org/143663004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248914 0039d316-1c4b-4281-b951-d872f2087c98
parent ec66f374
...@@ -52,6 +52,8 @@ public class HttpAuthDatabase { ...@@ -52,6 +52,8 @@ public class HttpAuthDatabase {
*/ */
private boolean mInitialized = false; private boolean mInitialized = false;
private final Object mInitializedLock = new Object();
/** /**
* Create an instance of HttpAuthDatabase for the named file, and kick-off background * Create an instance of HttpAuthDatabase for the named file, and kick-off background
* initialization of that database. * initialization of that database.
...@@ -74,16 +76,18 @@ public class HttpAuthDatabase { ...@@ -74,16 +76,18 @@ public class HttpAuthDatabase {
* @param context the Context to use for opening the database * @param context the Context to use for opening the database
* @param databaseFile Name of the file to be initialized. * @param databaseFile Name of the file to be initialized.
*/ */
private synchronized void initOnBackgroundThread(Context context, String databaseFile) { private void initOnBackgroundThread(Context context, String databaseFile) {
if (mInitialized) { synchronized (mInitializedLock) {
return; if (mInitialized) {
} return;
}
initDatabase(context, databaseFile); initDatabase(context, databaseFile);
// Thread done, notify. // Thread done, notify.
mInitialized = true; mInitialized = true;
notifyAll(); mInitializedLock.notifyAll();
}
} }
/** /**
...@@ -138,10 +142,10 @@ public class HttpAuthDatabase { ...@@ -138,10 +142,10 @@ public class HttpAuthDatabase {
* @return true if the database was initialized, false otherwise * @return true if the database was initialized, false otherwise
*/ */
private boolean waitForInit() { private boolean waitForInit() {
synchronized (this) { synchronized (mInitializedLock) {
while (!mInitialized) { while (!mInitialized) {
try { try {
wait(); mInitializedLock.wait();
} catch (InterruptedException e) { } catch (InterruptedException e) {
Log.e(LOGTAG, "Caught exception while checking initialization", e); Log.e(LOGTAG, "Caught exception while checking initialization", e);
} }
......
...@@ -2,7 +2,6 @@ H C EC: Using pointer equality to compare a JavaBridgeCoercionTest$CustomType wi ...@@ -2,7 +2,6 @@ H C EC: Using pointer equality to compare a JavaBridgeCoercionTest$CustomType wi
H P Bx: Boxing/unboxing to parse a primitive org.chromium.content.browser.ViewportTest.evaluateIntegerValue(String) At ViewportTest.java H P Bx: Boxing/unboxing to parse a primitive org.chromium.content.browser.ViewportTest.evaluateIntegerValue(String) At ViewportTest.java
M B Nm: The method name org.chromium.base.test.util.ScalableTimeout.ScaleTimeout(long) doesn't start with a lower case letter At ScalableTimeout.java M B Nm: The method name org.chromium.base.test.util.ScalableTimeout.ScaleTimeout(long) doesn't start with a lower case letter At ScalableTimeout.java
M B RV: Exceptional return value of java.io.File.delete() ignored in org.chromium.base.test.util.TestFileUtil.deleteFile(String) At TestFileUtil.java M B RV: Exceptional return value of java.io.File.delete() ignored in org.chromium.base.test.util.TestFileUtil.deleteFile(String) At TestFileUtil.java
M C CSM: Shouldn't use synchronized method, please narrow down the synchronization scope. At HttpAuthDatabase.java
M C CSM: Shouldn't use synchronized method, please narrow down the synchronization scope. At JavaBridgeArrayCoercionTest.java M C CSM: Shouldn't use synchronized method, please narrow down the synchronization scope. At JavaBridgeArrayCoercionTest.java
M C CSM: Shouldn't use synchronized method, please narrow down the synchronization scope. At JavaBridgeArrayTest.java M C CSM: Shouldn't use synchronized method, please narrow down the synchronization scope. At JavaBridgeArrayTest.java
M C CSM: Shouldn't use synchronized method, please narrow down the synchronization scope. At JavaBridgeBasicsTest.java M C CSM: Shouldn't use synchronized method, please narrow down the synchronization scope. At JavaBridgeBasicsTest.java
...@@ -15,7 +14,6 @@ M C CSM: Shouldn't use synchronized method, please narrow down the synchronizati ...@@ -15,7 +14,6 @@ M C CSM: Shouldn't use synchronized method, please narrow down the synchronizati
M C CSM: Shouldn't use synchronized method, please narrow down the synchronization scope. At SimpleSynchronizedMethod.java M C CSM: Shouldn't use synchronized method, please narrow down the synchronization scope. At SimpleSynchronizedMethod.java
M C CSM: Shouldn't use synchronized method, please narrow down the synchronization scope. At SimpleSynchronizedStaticMethod.java M C CSM: Shouldn't use synchronized method, please narrow down the synchronization scope. At SimpleSynchronizedStaticMethod.java
M C CSM: Shouldn't use synchronized method, please narrow down the synchronization scope. At TraceEvent.java M C CSM: Shouldn't use synchronized method, please narrow down the synchronization scope. At TraceEvent.java
M C CST: Shouldn't use synchronized(this), please narrow down the synchronization scope. At HttpAuthDatabase.java
M C CST: Shouldn't use synchronized(this), please narrow down the synchronization scope. At SimpleSynchronizedThis.java M C CST: Shouldn't use synchronized(this), please narrow down the synchronization scope. At SimpleSynchronizedThis.java
M D DMI: Hard coded reference to an absolute pathname in org.chromium.android_webview.test.ArchiveTest.testAutoBadPath() At ArchiveTest.java M D DMI: Hard coded reference to an absolute pathname in org.chromium.android_webview.test.ArchiveTest.testAutoBadPath() At ArchiveTest.java
M D DMI: Hard coded reference to an absolute pathname in org.chromium.android_webview.test.ArchiveTest.testExplicitBadPath() At ArchiveTest.java M D DMI: Hard coded reference to an absolute pathname in org.chromium.android_webview.test.ArchiveTest.testExplicitBadPath() At ArchiveTest.java
......
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