Browse Source

HADOOP-902. Fix a NullPointerException in HDFS client when closing output streams. Contributed by Raghu.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@497617 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 years ago
parent
commit
7a36941f49
2 changed files with 15 additions and 12 deletions
  1. 3 0
      CHANGES.txt
  2. 12 12
      src/java/org/apache/hadoop/dfs/DFSClient.java

+ 3 - 0
CHANGES.txt

@@ -41,6 +41,9 @@ Trunk (unreleased changes)
 
 12. HADOOP-905.  Remove some dead code from JobClient.  (cutting)
 
+13. HADOOP-902.  Fix a NullPointerException in HDFS client when
+    closing output streams.  (Raghu Angadi via cutting)
+
 
 Release 0.10.1 - 2007-01-10
 

+ 12 - 12
src/java/org/apache/hadoop/dfs/DFSClient.java

@@ -967,17 +967,21 @@ class DFSClient implements FSConstants {
          * filedescriptor that we don't own.
          */
         private void closeBackupStream() throws IOException {
-          OutputStream stream = backupStream;
-          backupStream = null;
-          stream.close();
+          if ( backupStream != null ) {
+            OutputStream stream = backupStream;
+            backupStream = null;
+            stream.close();
+          }   
         }
         /* Similar to closeBackupStream(). Theoritically deleting a file
          * twice could result in deleting a file that we should not.
          */
         private void deleteBackupFile() {
-          File file = backupFile;
-          backupFile = null;
-          file.delete();
+          if ( backupFile != null ) {
+            File file = backupFile;
+            backupFile = null;
+            file.delete();
+          }
         }
         
         private File newBackupFile() throws IOException {
@@ -1322,12 +1326,8 @@ class DFSClient implements FSConstants {
               }
             }
             
-            if ( backupStream != null ) {
-              closeBackupStream();
-            }
-            if ( backupFile != null ) {
-              deleteBackupFile();
-            }
+            closeBackupStream();
+            deleteBackupFile();
 
             if (s != null) {
                 s.close();