Fix lazy initialization of non-volatile static field in GerritLauncher

The `myArchive` static member of GerritLauncher is lazy initialized in
the `getDistributionArchive` 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: I2774cc12c2ee749331f72ff83c3d317b073787f3
This commit is contained in:
David Pursehouse
2013-08-23 19:03:11 +09:00
parent faf1c4e2ee
commit c32be67180

View File

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