From 176466ed281f85f2ba92ae8b605fb43eb3e010d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20=C5=BDivkov?= Date: Fri, 27 Oct 2017 12:29:52 +0200 Subject: [PATCH] Move loggers to the top of their class There is a possibility of hitting NPE on a logger if it is not the first statically initialized member. For example, if another static initializer creates an instance of its class and the logger is used from the constructor. Change-Id: I51fa855a8883c107f2e4ef5ac039dc12a571a7ae --- .../src/org/eclipse/jgit/lib/RepositoryCache.java | 4 ++-- org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java index 53e9fe3c5..efbbfbce2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java @@ -64,11 +64,11 @@ import org.slf4j.LoggerFactory; /** Cache of active {@link Repository} instances. */ public class RepositoryCache { - private static final RepositoryCache cache = new RepositoryCache(); - private final static Logger LOG = LoggerFactory .getLogger(RepositoryCache.class); + private static final RepositoryCache cache = new RepositoryCache(); + /** * Open an existing repository, reusing a cached instance if possible. *

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 1cc39bd46..5cc8afc78 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -77,6 +77,8 @@ import org.slf4j.LoggerFactory; /** Abstraction to support various file system operations not in Java. */ public abstract class FS { + private static final Logger LOG = LoggerFactory.getLogger(FS.class); + /** * This class creates FS instances. It will be overridden by a Java7 variant * if such can be detected in {@link #detect(Boolean)}. @@ -158,8 +160,6 @@ public abstract class FS { } } - private final static Logger LOG = LoggerFactory.getLogger(FS.class); - /** The auto-detected implementation selected for this operating system and JRE. */ public static final FS DETECTED = detect();