Jelajahi Sumber

Merge -c 1499566 from branch-1 to branch-1.2 to fix 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.2@1499899 13f79535-47bb-0310-9956-ffa450edef68
Arun Murthy 12 tahun lalu
induk
melakukan
35abda1a55

+ 3 - 0
CHANGES.txt

@@ -1,5 +1,8 @@
 Hadoop Change Log
 Hadoop Change Log
 
 
+    MAPREDUCE-5364. Deadlock between RenewalTimerTask methods cancel() and run(). 
+    (kkambatl via tucu)
+
 Release 1.2.1 - Unreleased 
 Release 1.2.1 - Unreleased 
 
 
   INCOMPATIBLE CHANGES
   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.Timer;
 import java.util.TimerTask;
 import java.util.TimerTask;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.logging.LogFactory;
@@ -200,13 +201,13 @@ public class DelegationTokenRenewal {
    */
    */
   private static class RenewalTimerTask extends TimerTask {
   private static class RenewalTimerTask extends TimerTask {
     private DelegationTokenToRenew dttr;
     private DelegationTokenToRenew dttr;
-    private boolean cancelled = false;
+    private AtomicBoolean cancelled = new AtomicBoolean(false);
     
     
     RenewalTimerTask(DelegationTokenToRenew t) {  dttr = t;  }
     RenewalTimerTask(DelegationTokenToRenew t) {  dttr = t;  }
     
     
     @Override
     @Override
-    public synchronized void run() {
-      if (cancelled) {
+    public void run() {
+      if (cancelled.get()) {
         return;
         return;
       }
       }
 
 
@@ -234,8 +235,8 @@ public class DelegationTokenRenewal {
     }
     }
 
 
     @Override
     @Override
-    public synchronized boolean cancel() {
-      cancelled = true;
+    public boolean cancel() {
+      cancelled.set(true);
       return super.cancel();
       return super.cancel();
     }
     }
   }
   }