Author: szetszwo Date: Fri Nov 30 02:52:03 2012 New Revision: 1415481 URL: http://svn.apache.org/viewvc?rev=1415481&view=rev Log: svn merge -c 1415480 from trunk for HDFS-4242. Map.Entry is incorrectly used in LeaseManager since the behavior of it is undefined after the iteration or modifications of the map.
Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/ (props changed) hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/ (props changed) hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/ ------------------------------------------------------------------------------ Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs:r1415480 Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1415481&r1=1415480&r2=1415481&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original) +++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Fri Nov 30 02:52:03 2012 @@ -266,6 +266,10 @@ Release 2.0.3-alpha - Unreleased HDFS-4216. Do not ignore QuotaExceededException when adding symlinks. (szetszwo) + HDFS-4242. Map.Entry is incorrectly used in LeaseManager since the behavior + of it is undefined after the iteration or modifications of the map. + (szetszwo) + Release 2.0.2-alpha - 2012-09-07 INCOMPATIBLE CHANGES Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/ ------------------------------------------------------------------------------ Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java:r1415480 Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java?rev=1415481&r1=1415480&r2=1415481&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java (original) +++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java Fri Nov 30 02:52:03 2012 @@ -17,9 +17,12 @@ */ package org.apache.hadoop.hdfs.server.namenode; +import static org.apache.hadoop.util.Time.now; + import java.io.IOException; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.SortedMap; @@ -39,8 +42,6 @@ import org.apache.hadoop.util.Daemon; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; -import static org.apache.hadoop.util.Time.now; - /** * LeaseManager does the lease housekeeping for writing on files. * This class also provides useful static methods for lease recovery. @@ -340,7 +341,8 @@ public class LeaseManager { } final int len = overwrite.length(); - for(Map.Entry<String, Lease> entry : findLeaseWithPrefixPath(src, sortedLeasesByPath)) { + for(Map.Entry<String, Lease> entry + : findLeaseWithPrefixPath(src, sortedLeasesByPath).entrySet()) { final String oldpath = entry.getKey(); final Lease lease = entry.getValue(); //overwrite must be a prefix of oldpath @@ -355,7 +357,8 @@ public class LeaseManager { } synchronized void removeLeaseWithPrefixPath(String prefix) { - for(Map.Entry<String, Lease> entry : findLeaseWithPrefixPath(prefix, sortedLeasesByPath)) { + for(Map.Entry<String, Lease> entry + : findLeaseWithPrefixPath(prefix, sortedLeasesByPath).entrySet()) { if (LOG.isDebugEnabled()) { LOG.debug(LeaseManager.class.getSimpleName() + ".removeLeaseWithPrefixPath: entry=" + entry); @@ -364,13 +367,13 @@ public class LeaseManager { } } - static private List<Map.Entry<String, Lease>> findLeaseWithPrefixPath( + static private Map<String, Lease> findLeaseWithPrefixPath( String prefix, SortedMap<String, Lease> path2lease) { if (LOG.isDebugEnabled()) { LOG.debug(LeaseManager.class.getSimpleName() + ".findLease: prefix=" + prefix); } - List<Map.Entry<String, Lease>> entries = new ArrayList<Map.Entry<String, Lease>>(); + final Map<String, Lease> entries = new HashMap<String, Lease>(); final int srclen = prefix.length(); for(Map.Entry<String, Lease> entry : path2lease.tailMap(prefix).entrySet()) { @@ -379,7 +382,7 @@ public class LeaseManager { return entries; } if (p.length() == srclen || p.charAt(srclen) == Path.SEPARATOR_CHAR) { - entries.add(entry); + entries.put(entry.getKey(), entry.getValue()); } } return entries;