hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject svn commit: r744115 - in /hadoop/core/branches/branch-0.20: ./ src/core/org/apache/hadoop/fs/s3/ src/core/org/apache/hadoop/fs/s3native/ src/hdfs/org/apache/hadoop/hdfs/ src/test/org/apache/hadoop/fs/
Date Fri, 13 Feb 2009 14:12:04 GMT
Author: enis
Date: Fri Feb 13 14:12:02 2009
New Revision: 744115

URL: http://svn.apache.org/viewvc?rev=744115&view=rev
Log:
Merge r744113:744114 from trunk to branch-0.20. Fixes HADOOP-4760. 

Modified:
    hadoop/core/branches/branch-0.20/CHANGES.txt
    hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/s3/S3InputStream.java
    hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/s3/S3OutputStream.java
    hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/s3native/NativeS3FileSystem.java
    hadoop/core/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java
    hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/fs/FileSystemContractBaseTest.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=744115&r1=744114&r2=744115&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/CHANGES.txt (original)
+++ hadoop/core/branches/branch-0.20/CHANGES.txt Fri Feb 13 14:12:02 2009
@@ -690,6 +690,9 @@
     HADOOP-5067. Fixes TaskInProgress.java to keep track of count of failed and
     killed tasks correctly. (Amareshwari Sriramadasu via ddas)
 
+    HADOOP-4760. HDFS streams should not throw exceptions when closed twice. 
+    (enis)
+
 Release 0.19.0 - 2008-11-18
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/s3/S3InputStream.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/s3/S3InputStream.java?rev=744115&r1=744114&r2=744115&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/s3/S3InputStream.java (original)
+++ hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/s3/S3InputStream.java Fri
Feb 13 14:12:02 2009
@@ -168,7 +168,7 @@
   @Override
   public void close() throws IOException {
     if (closed) {
-      throw new IOException("Stream closed");
+      return;
     }
     if (blockStream != null) {
       blockStream.close();

Modified: hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/s3/S3OutputStream.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/s3/S3OutputStream.java?rev=744115&r1=744114&r2=744115&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/s3/S3OutputStream.java
(original)
+++ hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/s3/S3OutputStream.java
Fri Feb 13 14:12:02 2009
@@ -200,7 +200,7 @@
   @Override
   public synchronized void close() throws IOException {
     if (closed) {
-      throw new IOException("Stream closed");
+      return;
     }
 
     flush();

Modified: hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/s3native/NativeS3FileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/s3native/NativeS3FileSystem.java?rev=744115&r1=744114&r2=744115&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/s3native/NativeS3FileSystem.java
(original)
+++ hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/s3native/NativeS3FileSystem.java
Fri Feb 13 14:12:02 2009
@@ -164,7 +164,7 @@
     @Override
     public synchronized void close() throws IOException {
       if (closed) {
-        throw new IOException("Stream closed");
+        return;
       }
 
       backupStream.close();

Modified: hadoop/core/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java?rev=744115&r1=744114&r2=744115&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java (original)
+++ hadoop/core/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java Fri Feb
13 14:12:02 2009
@@ -205,12 +205,13 @@
    * created and close connections to the namenode.
    */
   public synchronized void close() throws IOException {
-    checkOpen();
-    clientRunning = false;
-    leasechecker.close();
-
-    // close connections to the namenode
-    RPC.stopProxy(rpcNamenode);
+    if(clientRunning) {
+      clientRunning = false;
+      leasechecker.close();
+  
+      // close connections to the namenode
+      RPC.stopProxy(rpcNamenode);
+    }
   }
 
   /**
@@ -1583,11 +1584,11 @@
      */
     @Override
     public synchronized void close() throws IOException {
-      checkOpen();
       if (closed) {
-        throw new IOException("Stream closed");
+        return;
       }
-
+      checkOpen();
+      
       if ( blockReader != null ) {
         blockReader.close();
         blockReader = null;
@@ -2540,12 +2541,8 @@
     }
 
     private void isClosed() throws IOException {
-      if (closed) {
-        if (lastException != null) {
+      if (closed && lastException != null) {
           throw lastException;
-        } else {
-          throw new IOException("Stream closed.");
-        }
       }
     }
 
@@ -3067,6 +3064,8 @@
      */
     @Override
     public void close() throws IOException {
+      if(closed)
+        return;
       closeInternal();
       leasechecker.remove(src);
       

Modified: hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/fs/FileSystemContractBaseTest.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/fs/FileSystemContractBaseTest.java?rev=744115&r1=744114&r2=744115&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/fs/FileSystemContractBaseTest.java
(original)
+++ hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/fs/FileSystemContractBaseTest.java
Fri Feb 13 14:12:02 2009
@@ -423,6 +423,26 @@
         fs.exists(path("/test/new/newdir/dir/subdir/file2")));
   }
 
+  public void testInputStreamClosedTwice() throws IOException {
+    //HADOOP-4760 according to Closeable#close() closing already-closed 
+    //streams should have no effect. 
+    Path src = path("/test/hadoop/file");
+    createFile(src);
+    FSDataInputStream in = fs.open(src);
+    in.close();
+    in.close();
+  }
+  
+  public void testOutputStreamClosedTwice() throws IOException {
+    //HADOOP-4760 according to Closeable#close() closing already-closed 
+    //streams should have no effect. 
+    Path src = path("/test/hadoop/file");
+    FSDataOutputStream out = fs.create(src);
+    out.writeChar('H'); //write some data
+    out.close();
+    out.close();
+  }
+  
   protected Path path(String pathString) {
     return new Path(pathString).makeQualified(fs);
   }



Mime
View raw message