hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nh...@apache.org
Subject incubator-hawq git commit: HAWQ-188. Close Avro schema resource in case of exception
Date Wed, 25 Nov 2015 23:01:33 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 06b7f2f05 -> 29dd3ed41


HAWQ-188. Close Avro schema resource in case of exception


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/29dd3ed4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/29dd3ed4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/29dd3ed4

Branch: refs/heads/master
Commit: 29dd3ed41004089bbbb0d4cc43ffc41f5a67cbd5
Parents: 06b7f2f
Author: Noa Horn <nhorn@pivotal.io>
Authored: Tue Nov 24 10:44:17 2015 -0800
Committer: Noa Horn <nhorn@pivotal.io>
Committed: Wed Nov 25 14:56:06 2015 -0800

----------------------------------------------------------------------
 .../apache/hawq/pxf/plugins/hdfs/AvroResolver.java   | 15 ++++++++++++---
 .../pxf/plugins/hdfs/utilities/HdfsUtilities.java    |  2 +-
 2 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/29dd3ed4/pxf/pxf-hdfs/src/main/java/org/apache/hawq/pxf/plugins/hdfs/AvroResolver.java
----------------------------------------------------------------------
diff --git a/pxf/pxf-hdfs/src/main/java/org/apache/hawq/pxf/plugins/hdfs/AvroResolver.java
b/pxf/pxf-hdfs/src/main/java/org/apache/hawq/pxf/plugins/hdfs/AvroResolver.java
index 317040f..5586f1c 100644
--- a/pxf/pxf-hdfs/src/main/java/org/apache/hawq/pxf/plugins/hdfs/AvroResolver.java
+++ b/pxf/pxf-hdfs/src/main/java/org/apache/hawq/pxf/plugins/hdfs/AvroResolver.java
@@ -62,9 +62,18 @@ public class AvroResolver extends Plugin implements ReadResolver {
     public AvroResolver(InputData input) throws IOException {
         super(input);
 
-        Schema schema = isAvroFile() ? getAvroSchema(new Configuration(),
-                input.getDataSource())
-                : (new Schema.Parser()).parse(openExternalSchema());
+        Schema schema;
+
+        if (isAvroFile()) {
+            schema = getAvroSchema(new Configuration(), input.getDataSource());
+        } else {
+            InputStream externalSchema = openExternalSchema();
+            try {
+                schema = (new Schema.Parser()).parse(externalSchema);
+            } finally {
+                externalSchema.close();
+            }
+        }
 
         reader = new GenericDatumReader<>(schema);
         fields = schema.getFields();

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/29dd3ed4/pxf/pxf-hdfs/src/main/java/org/apache/hawq/pxf/plugins/hdfs/utilities/HdfsUtilities.java
----------------------------------------------------------------------
diff --git a/pxf/pxf-hdfs/src/main/java/org/apache/hawq/pxf/plugins/hdfs/utilities/HdfsUtilities.java
b/pxf/pxf-hdfs/src/main/java/org/apache/hawq/pxf/plugins/hdfs/utilities/HdfsUtilities.java
index aa854fc..155ae26 100644
--- a/pxf/pxf-hdfs/src/main/java/org/apache/hawq/pxf/plugins/hdfs/utilities/HdfsUtilities.java
+++ b/pxf/pxf-hdfs/src/main/java/org/apache/hawq/pxf/plugins/hdfs/utilities/HdfsUtilities.java
@@ -191,7 +191,7 @@ public class HdfsUtilities {
      * @param conf Hadoop configuration
      * @param dataSource Avro file (i.e fileName.avro) path
      * @return the Avro schema
-     * @throws IOException if I/O error occured while accessing Avro schema file
+     * @throws IOException if I/O error occurred while accessing Avro schema file
      */
     public static Schema getAvroSchema(Configuration conf, String dataSource)
             throws IOException {


Mime
View raw message