hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sur...@apache.org
Subject svn commit: r899856 - in /hadoop/common/trunk: CHANGES.txt src/java/org/apache/hadoop/fs/FileContext.java src/java/org/apache/hadoop/io/compress/CompressionCodecFactory.java src/java/org/apache/hadoop/util/ReflectionUtils.java
Date Sat, 16 Jan 2010 00:44:41 GMT
Author: suresh
Date: Sat Jan 16 00:44:40 2010
New Revision: 899856

URL: http://svn.apache.org/viewvc?rev=899856&view=rev
Log:
HADOOP-6489. Fix 3 findbugs warnings. Contributed by Erik Steffl.

Modified:
    hadoop/common/trunk/CHANGES.txt
    hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileContext.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/compress/CompressionCodecFactory.java
    hadoop/common/trunk/src/java/org/apache/hadoop/util/ReflectionUtils.java

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=899856&r1=899855&r2=899856&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Sat Jan 16 00:44:40 2010
@@ -137,6 +137,8 @@
     HADOOP-6402. testConf.xsl is not well-formed XML. (Steve Loughran
     via tomwhite)
 
+    HADOOP-6489. Fix 3 findbugs warnings. (Erik Steffl via suresh)
+
 Release 0.21.0 - Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileContext.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileContext.java?rev=899856&r1=899855&r2=899856&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileContext.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileContext.java Sat Jan 16 00:44:40
2010
@@ -156,6 +156,7 @@
   
   public static final Log LOG = LogFactory.getLog(FileContext.class);
   public static final FsPermission DEFAULT_PERM = FsPermission.getDefault();
+  volatile private static FileContext localFsSingleton = null;
   
   /**
    * List of files that should be deleted on JVM shutdown.
@@ -342,7 +343,6 @@
     return getFileContext(new Configuration());
   } 
   
-  private static FileContext localFsSingleton = null;
   /**
    * 
    * @return a FileContext for the local filesystem using the default config.

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/io/compress/CompressionCodecFactory.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/compress/CompressionCodecFactory.java?rev=899856&r1=899855&r2=899856&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/io/compress/CompressionCodecFactory.java
(original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/io/compress/CompressionCodecFactory.java
Sat Jan 16 00:44:40 2010
@@ -199,29 +199,38 @@
           System.out.println("Codec for " + args[i] + " not found.");
         } else { 
           if (encode) {
-            CompressionOutputStream out = 
-              codec.createOutputStream(new java.io.FileOutputStream(args[i]));
-            byte[] buffer = new byte[100];
-            String inFilename = removeSuffix(args[i], 
-                                             codec.getDefaultExtension());
-            java.io.InputStream in = new java.io.FileInputStream(inFilename);
-            int len = in.read(buffer);
-            while (len > 0) {
-              out.write(buffer, 0, len);
-              len = in.read(buffer);
+            CompressionOutputStream out = null;
+            java.io.InputStream in = null;
+            try {
+              out = codec.createOutputStream(
+                  new java.io.FileOutputStream(args[i]));
+              byte[] buffer = new byte[100];
+              String inFilename = removeSuffix(args[i], 
+                  codec.getDefaultExtension());
+              in = new java.io.FileInputStream(inFilename);
+              int len = in.read(buffer);
+              while (len > 0) {
+                out.write(buffer, 0, len);
+                len = in.read(buffer);
+              }
+            } finally {
+              if(out != null) { out.close(); }
+              if(in  != null) { in.close(); }
             }
-            in.close();
-            out.close();
           } else {
-            CompressionInputStream in = 
-              codec.createInputStream(new java.io.FileInputStream(args[i]));
-            byte[] buffer = new byte[100];
-            int len = in.read(buffer);
-            while (len > 0) {
-              System.out.write(buffer, 0, len);
-              len = in.read(buffer);
+            CompressionInputStream in = null;
+            try {
+              in = codec.createInputStream(
+                  new java.io.FileInputStream(args[i]));
+              byte[] buffer = new byte[100];
+              int len = in.read(buffer);
+              while (len > 0) {
+                System.out.write(buffer, 0, len);
+                len = in.read(buffer);
+              }
+            } finally {
+              if(in != null) { in.close(); }
             }
-            in.close();
           }
         }
       }

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/util/ReflectionUtils.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/util/ReflectionUtils.java?rev=899856&r1=899855&r2=899856&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/util/ReflectionUtils.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/util/ReflectionUtils.java Sat Jan 16 00:44:40
2010
@@ -47,7 +47,7 @@
 public class ReflectionUtils {
     
   private static final Class<?>[] EMPTY_ARRAY = new Class[]{};
-  private static SerializationFactory serialFactory = null;
+  volatile private static SerializationFactory serialFactory = null;
 
   /** 
    * Cache of constructors for each class. Pins the classes so they



Mime
View raw message