Browse Source

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
stable-4.10
Saša Živkov 7 years ago committed by Sasa Zivkov
parent
commit
176466ed28
  1. 4
      org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java
  2. 4
      org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java

4
org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java

@ -64,11 +64,11 @@ import org.slf4j.LoggerFactory;
/** Cache of active {@link Repository} instances. */ /** Cache of active {@link Repository} instances. */
public class RepositoryCache { public class RepositoryCache {
private static final RepositoryCache cache = new RepositoryCache();
private final static Logger LOG = LoggerFactory private final static Logger LOG = LoggerFactory
.getLogger(RepositoryCache.class); .getLogger(RepositoryCache.class);
private static final RepositoryCache cache = new RepositoryCache();
/** /**
* Open an existing repository, reusing a cached instance if possible. * Open an existing repository, reusing a cached instance if possible.
* <p> * <p>

4
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. */ /** Abstraction to support various file system operations not in Java. */
public abstract class FS { 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 * This class creates FS instances. It will be overridden by a Java7 variant
* if such can be detected in {@link #detect(Boolean)}. * 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. */ /** The auto-detected implementation selected for this operating system and JRE. */
public static final FS DETECTED = detect(); public static final FS DETECTED = detect();

Loading…
Cancel
Save