Fix lazy initialization of non-volatile static field in GerritLauncher

The `myHome` static member of GerritLauncher is lazy initialized in
the `getHomeDirectory` method.

According to FindBugs:

   Because the compiler or processor may reorder instructions, threads
   are not guaranteed to see a completely initialized object, if the
   method can be called by multiple threads.

Fix this by declaring the member as 'volatile'.

Change-Id: If2fd90ce83d5b383539aac41dddcacaca1729300
This commit is contained in:
David Pursehouse
2013-10-22 10:18:30 +09:00
parent c7ddde3209
commit 54c874b7b0

View File

@@ -302,7 +302,7 @@ public final class GerritLauncher {
}
private volatile static File myArchive;
private static File myHome;
private volatile static File myHome;
/**
* Locate the JAR/WAR file we were launched from.