Kaynağa Gözat

HADOOP-2080. Fix for NPE in previous patch.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@587326 13f79535-47bb-0310-9956-ffa450edef68
Owen O'Malley 17 yıl önce
ebeveyn
işleme
a80160d50a

+ 8 - 2
src/java/org/apache/hadoop/fs/ChecksumFileSystem.java

@@ -37,7 +37,7 @@ import org.apache.hadoop.util.StringUtils;
  *****************************************************************/
 public abstract class ChecksumFileSystem extends FilterFileSystem {
   private static final byte[] CHECKSUM_VERSION = new byte[] {'c', 'r', 'c', 0};
-  private final int bytesPerChecksum;
+  private int bytesPerChecksum;
 
   public static double getApproxChkSumLength(long size) {
     return ChecksumFSOutputSummer.CHKSUM_AS_FRACTION * size;
@@ -45,7 +45,13 @@ public abstract class ChecksumFileSystem extends FilterFileSystem {
   
   public ChecksumFileSystem(FileSystem fs) {
     super(fs);
-    bytesPerChecksum = getConf().getInt("io.bytes.per.checksum", 512);
+  }
+
+  public void setConf(Configuration conf) {
+    super.setConf(conf);
+    if (conf != null) {
+      bytesPerChecksum = conf.getInt("io.bytes.per.checksum", 512);
+    }
   }
 
   /** get the raw file system */