瀏覽代碼

MAPREDUCE-5364. Deadlock between RenewalTimerTask methods cancel() and run(). (kkambatl via tucu)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1@1499566 13f79535-47bb-0310-9956-ffa450edef68
Alejandro Abdelnur 12 年之前
父節點
當前提交
617c346c42
共有 2 個文件被更改,包括 9 次插入5 次删除
  1. 3 0
      CHANGES.txt
  2. 6 5
      src/mapred/org/apache/hadoop/mapreduce/security/token/DelegationTokenRenewal.java

+ 3 - 0
CHANGES.txt

@@ -71,6 +71,9 @@ Release 1.3.0 - unreleased
     HADOOP-9678. TestRPC#testStopsAllThreads intermittently fails on Windows.
     (Ivan Mitic via cnauroth)
 
+    MAPREDUCE-5364. Deadlock between RenewalTimerTask methods cancel() and run(). 
+    (kkambatl via tucu)
+
 Release 1.2.1 - Unreleased 
 
   INCOMPATIBLE CHANGES

+ 6 - 5
src/mapred/org/apache/hadoop/mapreduce/security/token/DelegationTokenRenewal.java

@@ -30,6 +30,7 @@ import java.util.Set;
 import java.util.Timer;
 import java.util.TimerTask;
 import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -200,13 +201,13 @@ public class DelegationTokenRenewal {
    */
   private static class RenewalTimerTask extends TimerTask {
     private DelegationTokenToRenew dttr;
-    private boolean cancelled = false;
+    private AtomicBoolean cancelled = new AtomicBoolean(false);
     
     RenewalTimerTask(DelegationTokenToRenew t) {  dttr = t;  }
     
     @Override
-    public synchronized void run() {
-      if (cancelled) {
+    public void run() {
+      if (cancelled.get()) {
         return;
       }
 
@@ -234,8 +235,8 @@ public class DelegationTokenRenewal {
     }
 
     @Override
-    public synchronized boolean cancel() {
-      cancelled = true;
+    public boolean cancel() {
+      cancelled.set(true);
       return super.cancel();
     }
   }