From bdf3e43d7652e8fbfbf3416d8b8df1c6dbddbc14 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Tue, 18 Oct 2016 13:51:27 +0900 Subject: [PATCH] FS: Fix lazy initialization of non-volatile static field The 'factory' field is lazy initialized in the detect() 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: Ib32663bb28c9564584256e01f625b4e7875e6223 Signed-off-by: David Pursehouse --- org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java index a55b5c0ac5..dcd7970cbc 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -164,7 +164,7 @@ public abstract class FS { /** The auto-detected implementation selected for this operating system and JRE. */ public static final FS DETECTED = detect(); - private static FSFactory factory; + private volatile static FSFactory factory; /** * Auto-detect the appropriate file system abstraction. -- 2.39.5