[prev in list] [next in list] [prev in thread] [next in thread]
List: hadoop-commits
Subject: svn commit: r1367200 - in /hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common:
From: bobby () apache ! org
Date: 2012-07-30 18:07:20
Message-ID: 20120730180720.42F07238890B () eris ! apache ! org
[Download RAW message or body]
Author: bobby
Date: Mon Jul 30 18:07:19 2012
New Revision: 1367200
URL: http://svn.apache.org/viewvc?rev=1367200&view=rev
Log:
svn merge -c 1367196 FIXES: HADOOP-8634. Ensure FileSystem#close doesn't squawk for \
deleteOnExit paths (daryn via bobby)
Modified:
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemCaching.java
Modified: hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1367200&r1=1367199&r2=1367200&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt \
(original)
+++ hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt \
Mon Jul 30 18:07:19 2012 @@ -132,6 +132,9 @@ Release 0.23.3 - UNRELEASED
HADOOP-8627. FS deleteOnExit may delete the wrong path (daryn via bobby)
+ HADOOP-8634. Ensure FileSystem#close doesn't squawk for deleteOnExit paths
+ (daryn via bobby)
+
Release 0.23.2 - UNRELEASED
NEW FEATURES
Modified: hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-common-pro \
ject/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java?rev=1367200&r1=1367199&r2=1367200&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java \
(original)
+++ hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java \
Mon Jul 30 18:07:19 2012 @@ -1165,7 +1165,9 @@ public abstract class FileSystem \
extends
for (Iterator<Path> iter = deleteOnExit.iterator(); iter.hasNext();) {
Path path = iter.next();
try {
- delete(path, true);
+ if (exists(path)) {
+ delete(path, true);
+ }
}
catch (IOException e) {
LOG.info("Ignoring failure to deleteOnExit for path " + path);
Modified: hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemCaching.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-common-pro \
ject/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemCaching.java?rev=1367200&r1=1367199&r2=1367200&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemCaching.java \
(original)
+++ hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemCaching.java \
Mon Jul 30 18:07:19 2012 @@ -35,7 +35,7 @@ import java.security.PrivilegedException
import java.util.concurrent.Semaphore;
import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.*;
public class TestFileSystemCaching {
@@ -267,4 +267,28 @@ public class TestFileSystemCaching {
});
assertNotSame(fsA, fsA1);
}
-}
+
+ @Test
+ public void testDeleteOnExitChecksExists() throws Exception {
+ FileSystem mockFs = mock(FileSystem.class);
+ FileSystem fs = new FilterFileSystem(mockFs);
+ Path p = new Path("/a");
+
+ // path has to exist for deleteOnExit to register it
+ when(mockFs.getFileStatus(p)).thenReturn(new FileStatus());
+ fs.deleteOnExit(p);
+ verify(mockFs).getFileStatus(eq(p));
+ fs.close();
+ verify(mockFs).delete(eq(p), anyBoolean());
+ reset(mockFs);
+
+ // make sure it doesn't try to delete a file that doesn't exist
+ when(mockFs.getFileStatus(p)).thenReturn(new FileStatus());
+ fs.deleteOnExit(p);
+ verify(mockFs).getFileStatus(eq(p));
+ reset(mockFs);
+ fs.close();
+ verify(mockFs).getFileStatus(eq(p));
+ verify(mockFs, never()).delete(any(Path.class), anyBoolean());
+ }
+}
\ No newline at end of file
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic