You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by sh...@apache.org on 2009/03/30 21:03:40 UTC
svn commit: r760105 - in /hadoop/core/branches/branch-0.20: CHANGES.txt
src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
src/test/org/apache/hadoop/hdfs/TestFileCreation.java
Author: shv
Date: Mon Mar 30 19:03:39 2009
New Revision: 760105
URL: http://svn.apache.org/viewvc?rev=760105&view=rev
Log:
HADOOP-5551. Merge -r 760097:760098 from trunk to branch 0.20.
Modified:
hadoop/core/branches/branch-0.20/CHANGES.txt
hadoop/core/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/hdfs/TestFileCreation.java
Modified: hadoop/core/branches/branch-0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/CHANGES.txt?rev=760105&r1=760104&r2=760105&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/CHANGES.txt (original)
+++ hadoop/core/branches/branch-0.20/CHANGES.txt Mon Mar 30 19:03:39 2009
@@ -679,7 +679,7 @@
Total-Output/Total-Input. (Sharad Agarwal via ddas)
HADOOP-5142. Fix MapWritable#putAll to store key/value classes.
- (DoÄacan Güney via enis)
+ (Do??acan G??ney via enis)
HADOOP-4744. Workaround for jetty6 returning -1 when getLocalPort
is invoked on the connector. The workaround patch retries a few
@@ -894,6 +894,9 @@
HADOOP-4780. Cache the size of directories in DistributedCache, avoiding
long delays in recalculating it. (He Yongqiang via cdouglas)
+ HADOOP-5551. Prevent directory destruction on file create.
+ (Brian Bockelman via shv)
+
Release 0.19.1 - 2009-02-23
IMPROVEMENTS
Modified: hadoop/core/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=760105&r1=760104&r2=760105&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java (original)
+++ hadoop/core/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java Mon Mar 30 19:03:39 2009
@@ -998,8 +998,15 @@
if (!DFSUtil.isValidName(src)) {
throw new IOException("Invalid file name: " + src);
}
+
+ // Verify that the destination does not exist as a directory already.
+ boolean pathExists = dir.exists(src);
+ if (pathExists && dir.isDir(src)) {
+ throw new IOException("Cannot create file "+ src + "; already exists as a directory.");
+ }
+
if (isPermissionEnabled) {
- if (append || (overwrite && dir.exists(src))) {
+ if (append || (overwrite && pathExists)) {
checkPathAccess(src, FsAction.WRITE);
}
else {
Modified: hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/hdfs/TestFileCreation.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/hdfs/TestFileCreation.java?rev=760105&r1=760104&r2=760105&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/hdfs/TestFileCreation.java (original)
+++ hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/hdfs/TestFileCreation.java Mon Mar 30 19:03:39 2009
@@ -187,6 +187,22 @@
System.out.println(fs.getFileStatus(path).isDir());
assertTrue("/ should be a directory",
fs.getFileStatus(path).isDir() == true);
+
+ //
+ // Create a directory inside /, then try to overwrite it
+ //
+ Path dir1 = new Path("/test_dir");
+ fs.mkdirs(dir1);
+ System.out.println("createFile: Creating " + dir1.getName() +
+ " for overwrite of existing directory.");
+ try {
+ fs.create(dir1, true); // Create path, overwrite=true
+ fs.close();
+ assertTrue("Did not prevent directory from being overwritten.", false);
+ } catch (IOException ie) {
+ if (!ie.getMessage().contains("already exists as a directory."))
+ throw ie;
+ }
// create a new file in home directory. Do not close it.
//