Author: cutting Date: Thu Jan 18 14:54:55 2007 New Revision: 497617 URL: http://svn.apache.org/viewvc?view=rev&rev=497617 Log: HADOOP-902. Fix a NullPointerException in HDFS client when closing output streams. Contributed by Raghu.
Modified: lucene/hadoop/trunk/CHANGES.txt lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSClient.java Modified: lucene/hadoop/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=497617&r1=497616&r2=497617 ============================================================================== --- lucene/hadoop/trunk/CHANGES.txt (original) +++ lucene/hadoop/trunk/CHANGES.txt Thu Jan 18 14:54:55 2007 @@ -41,6 +41,9 @@ 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 Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSClient.java URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSClient.java?view=diff&rev=497617&r1=497616&r2=497617 ============================================================================== --- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSClient.java (original) +++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSClient.java Thu Jan 18 14:54:55 2007 @@ -967,17 +967,21 @@ * 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 @@ } } - if ( backupStream != null ) { - closeBackupStream(); - } - if ( backupFile != null ) { - deleteBackupFile(); - } + closeBackupStream(); + deleteBackupFile(); if (s != null) { s.close();