Parcourir la source

HADOOP-4806. HDFS rename should not use src path as a regular expression. (szetszwo)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.19@725448 13f79535-47bb-0310-9956-ffa450edef68
Tsz-wo Sze il y a 16 ans
Parent
commit
5ef1b87375

+ 3 - 0
CHANGES.txt

@@ -1078,6 +1078,9 @@ Release 0.18.3 - Unreleased
 
     HADOOP-4613. Fix block browsing on Web UI. (Johan Oskarsson via shv)
 
+    HADOOP-4806. HDFS rename should not use src path as a regular expression.
+    (szetszwo)
+
 Release 0.18.2 - 2008-11-03
 
   BUG FIXES

+ 2 - 1
src/hdfs/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java

@@ -288,7 +288,8 @@ public class LeaseManager {
     for(Map.Entry<String, Lease> entry : findLeaseWithPrefixPath(src, sortedLeasesByPath)) {
       final String oldpath = entry.getKey();
       final Lease lease = entry.getValue();
-      final String newpath = oldpath.replaceFirst(overwrite, replaceBy);
+      final String newpath = oldpath.replaceFirst(
+          java.util.regex.Pattern.quote(overwrite), replaceBy);
       if (LOG.isDebugEnabled()) {
         LOG.debug("changeLease: replacing " + oldpath + " with " + newpath);
       }

+ 1 - 1
src/test/org/apache/hadoop/hdfs/TestRenameWhileOpen.java

@@ -59,7 +59,7 @@ public class TestRenameWhileOpen extends junit.framework.TestCase {
       final int nnport = cluster.getNameNodePort();
 
       // create file1.
-      Path dir1 = new Path("/user/dir1");
+      Path dir1 = new Path("/user/a+b/dir1");
       Path file1 = new Path(dir1, "file1");
       FSDataOutputStream stm1 = TestFileCreation.createFile(fs, file1, 1);
       System.out.println("testFileCreationDeleteParent: "