crunch-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gr...@apache.org
Subject crunch git commit: CRUNCH-567 Fix potential NPE on close
Date Sat, 03 Oct 2015 15:02:20 GMT
Repository: crunch
Updated Branches:
  refs/heads/master f629b8e6b -> abaa203b6


CRUNCH-567 Fix potential NPE on close

Prevent a potential NPE on calling close on an incompletely
initialized AvroRecordReader or HFileRecordReader.

Contributed by Sean Owen.


Project: http://git-wip-us.apache.org/repos/asf/crunch/repo
Commit: http://git-wip-us.apache.org/repos/asf/crunch/commit/abaa203b
Tree: http://git-wip-us.apache.org/repos/asf/crunch/tree/abaa203b
Diff: http://git-wip-us.apache.org/repos/asf/crunch/diff/abaa203b

Branch: refs/heads/master
Commit: abaa203b6d6ac141e9e11410a62e2655d140e04b
Parents: f629b8e
Author: Gabriel Reid <greid@apache.org>
Authored: Sat Oct 3 17:00:15 2015 +0200
Committer: Gabriel Reid <greid@apache.org>
Committed: Sat Oct 3 17:00:15 2015 +0200

----------------------------------------------------------------------
 .../java/org/apache/crunch/types/avro/AvroRecordReader.java     | 5 ++++-
 .../main/java/org/apache/crunch/io/hbase/HFileInputFormat.java  | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/crunch/blob/abaa203b/crunch-core/src/main/java/org/apache/crunch/types/avro/AvroRecordReader.java
----------------------------------------------------------------------
diff --git a/crunch-core/src/main/java/org/apache/crunch/types/avro/AvroRecordReader.java
b/crunch-core/src/main/java/org/apache/crunch/types/avro/AvroRecordReader.java
index a5339fb..ab2f30e 100644
--- a/crunch-core/src/main/java/org/apache/crunch/types/avro/AvroRecordReader.java
+++ b/crunch-core/src/main/java/org/apache/crunch/types/avro/AvroRecordReader.java
@@ -103,6 +103,9 @@ class AvroRecordReader<T> extends RecordReader<AvroWrapper<T>,
NullWritable> {
 
   @Override
   public void close() throws IOException {
-    reader.close();
+    if (reader != null) {
+      reader.close();
+      reader = null;
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/crunch/blob/abaa203b/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileInputFormat.java
----------------------------------------------------------------------
diff --git a/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileInputFormat.java b/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileInputFormat.java
index 26821bf..b286f51 100644
--- a/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileInputFormat.java
+++ b/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileInputFormat.java
@@ -177,7 +177,10 @@ public class HFileInputFormat extends FileInputFormat<NullWritable,
KeyValue> {
 
     @Override
     public void close() throws IOException {
-      in.close();
+      if (in != null) {
+        in.close();
+        in = null;
+      }
     }
 
     // This method is copied from o.a.h.hbase.regionserver.StoreFileScanner, as we don't
want


Mime
View raw message