diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogAsync.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogAsync.java index c14a31021ff..5990c2273fd 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogAsync.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogAsync.java @@ -40,7 +40,7 @@ class FSEditLogAsync extends FSEditLog implements Runnable { // use separate mutex to avoid possible deadlock when stopping the thread. private final Object syncThreadLock = new Object(); private Thread syncThread; - private static ThreadLocal threadEdit = new ThreadLocal(); + private static final ThreadLocal THREAD_EDIT = new ThreadLocal(); // requires concurrent access from caller threads and syncing thread. private final BlockingQueue editPendingQ = @@ -114,16 +114,16 @@ public void close() { @Override void logEdit(final FSEditLogOp op) { Edit edit = getEditInstance(op); - threadEdit.set(edit); + THREAD_EDIT.set(edit); enqueueEdit(edit); } @Override public void logSync() { - Edit edit = threadEdit.get(); + Edit edit = THREAD_EDIT.get(); if (edit != null) { // do NOT remove to avoid expunge & rehash penalties. - threadEdit.set(null); + THREAD_EDIT.set(null); if (LOG.isDebugEnabled()) { LOG.debug("logSync " + edit); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java index c0daaf19ebb..8293a82db91 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java @@ -157,7 +157,7 @@ public abstract class FSEditLogOp { int rpcCallId; public static class OpInstanceCache { - private static ThreadLocal cache = + private static final ThreadLocal CACHE = new ThreadLocal() { @Override protected OpInstanceCacheMap initialValue() { @@ -188,7 +188,7 @@ public OpInstanceCache get() { @SuppressWarnings("unchecked") public T get(FSEditLogOpCodes opCode) { - return useCache ? (T)cache.get().get(opCode) : (T)newInstance(opCode); + return useCache ? (T)CACHE.get().get(opCode) : (T)newInstance(opCode); } private static FSEditLogOp newInstance(FSEditLogOpCodes opCode) {