Repository: hadoop
Updated Branches:
  refs/heads/trunk 28e224439 -> f40969a14


HDFS-10183. Prevent race condition during class initialization. Contributed by 
Pavel Avgustinov.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/f40969a1
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/f40969a1
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/f40969a1

Branch: refs/heads/trunk
Commit: f40969a141ec6aff254c41e4185cc61ea9e4e554
Parents: 28e2244
Author: Sangjin Lee <sj...@apache.org>
Authored: Fri Apr 20 20:33:10 2018 -0700
Committer: Sangjin Lee <sj...@apache.org>
Committed: Fri Apr 20 20:33:10 2018 -0700

----------------------------------------------------------------------
 .../apache/hadoop/hdfs/server/namenode/FSEditLogAsync.java   | 8 ++++----
 .../org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java  | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/f40969a1/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogAsync.java
----------------------------------------------------------------------
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 c14a310..5990c22 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<Edit> threadEdit = new ThreadLocal<Edit>();
+  private static final ThreadLocal<Edit> THREAD_EDIT = new ThreadLocal<Edit>();
 
   // requires concurrent access from caller threads and syncing thread.
   private final BlockingQueue<Edit> editPendingQ =
@@ -114,16 +114,16 @@ class FSEditLogAsync extends FSEditLog implements 
Runnable {
   @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);
       }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/f40969a1/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java
----------------------------------------------------------------------
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 c0daaf1..8293a82 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<OpInstanceCacheMap> cache =
+    private static final ThreadLocal<OpInstanceCacheMap> CACHE =
         new ThreadLocal<OpInstanceCacheMap>() {
       @Override
       protected OpInstanceCacheMap initialValue() {
@@ -188,7 +188,7 @@ public abstract class FSEditLogOp {
 
     @SuppressWarnings("unchecked")
     public <T extends FSEditLogOp> 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) {


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to