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 cd...@apache.org on 2008/03/19 20:05:45 UTC

svn commit: r638975 - in /hadoop/core/trunk: CHANGES.txt src/test/org/apache/hadoop/dfs/UpgradeUtilities.java

Author: cdouglas
Date: Wed Mar 19 12:05:39 2008
New Revision: 638975

URL: http://svn.apache.org/viewvc?rev=638975&view=rev
Log:
HADOOP-3036. Fix findbugs warnings in UpgradeUtilities. Contributed by Konstantin Shvachko


Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/test/org/apache/hadoop/dfs/UpgradeUtilities.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=638975&r1=638974&r2=638975&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Wed Mar 19 12:05:39 2008
@@ -283,6 +283,9 @@
     HADOOP-3030. Release reserved space for file in InMemoryFileSystem if
     checksum reservation fails. (Devaraj Das via cdouglas)
 
+    HADOOP-3036. Fix findbugs warnings in UpgradeUtilities. (Konstantin
+    Shvachko via cdouglas)
+
 Release 0.16.2 - Unreleased
 
   BUG FIXES

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/dfs/UpgradeUtilities.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/dfs/UpgradeUtilities.java?rev=638975&r1=638974&r2=638975&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/dfs/UpgradeUtilities.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/dfs/UpgradeUtilities.java Wed Mar 19 12:05:39 2008
@@ -52,7 +52,7 @@
 
   // Root scratch directory on local filesystem 
   private static File TEST_ROOT_DIR = new File(
-                                               System.getProperty("test.build.data","/tmp").toString().replace(' ', '+'));
+      System.getProperty("test.build.data","/tmp").replace(' ', '+'));
   // The singleton master storage directory for Namenode
   private static File namenodeStorage = new File(TEST_ROOT_DIR, "namenodeMaster");
   // A checksum of the contents in namenodeStorage directory
@@ -207,20 +207,25 @@
     Arrays.sort(list);
     CRC32 checksum = new CRC32();
     for (int i = 0; i < list.length; i++) {
-      if (list[i].isFile()) {
-        // skip VERSION file for DataNodes
-        if (nodeType == DATA_NODE &&
-            list[i].getName().equals("VERSION")) 
-          {
-            continue; 
-          }
-        FileInputStream fis = new FileInputStream(list[i]);
+      if (!list[i].isFile()) {
+        continue;
+      }
+      // skip VERSION file for DataNodes
+      if (nodeType == DATA_NODE && list[i].getName().equals("VERSION")) {
+        continue; 
+      }
+      FileInputStream fis = null;
+      try {
+        fis = new FileInputStream(list[i]);
         byte[] buffer = new byte[1024];
         int bytesRead;
         while ((bytesRead = fis.read(buffer)) != -1) {
           checksum.update(buffer, 0, bytesRead);
         }
-        fis.close();
+      } finally {
+        if(fis != null) {
+          fis.close();
+        }
       }
     }
     return checksum.getValue();