FAQ
Repository: hive
Updated Branches:
   refs/heads/master bcb7d9e13 -> 9c5d28bca


HIVE-13294: AvroSerde leaks the connection in a case when reading schema from a url (Chaoyu Tang, reviewed by Aihua Xu)


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

Branch: refs/heads/master
Commit: 9c5d28bcab7a1d5862ddab7fa87b6d13ed9528ab
Parents: bcb7d9e
Author: ctang <ctang@cloudera.com>
Authored: Mon Mar 21 12:21:58 2016 -0400
Committer: ctang <ctang@cloudera.com>
Committed: Tue Mar 22 04:12:44 2016 -0700

----------------------------------------------------------------------
  .../hadoop/hive/serde2/avro/AvroSerdeUtils.java | 20 +++++++++++++++++++-
  1 file changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/9c5d28bc/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerdeUtils.java
----------------------------------------------------------------------
diff --git a/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerdeUtils.java b/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerdeUtils.java
index 08ae6ef..08ee62b 100644
--- a/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerdeUtils.java
+++ b/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerdeUtils.java
@@ -134,7 +134,7 @@ public class AvroSerdeUtils {
        Schema s = getSchemaFromFS(schemaString, conf);
        if (s == null) {
          //in case schema is not a file system
- return AvroSerdeUtils.getSchemaFor(new URL(schemaString).openStream());
+ return AvroSerdeUtils.getSchemaFor(new URL(schemaString));
        }
        return s;
      } catch (IOException ioe) {
@@ -260,4 +260,22 @@ public class AvroSerdeUtils {
      }
      return schema;
    }
+
+ public static Schema getSchemaFor(URL url) {
+ InputStream in = null;
+ try {
+ in = url.openStream();
+ return getSchemaFor(in);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to parse Avro schema", e);
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
+ }
+ }
  }

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
groupcommits @
categorieshive, hadoop
postedMar 21, '16 at 4:23p
activeMar 22, '16 at 11:16a
posts2
users1
websitehive.apache.org

1 user in discussion

Ctang: 2 posts

People

Translate

site design / logo © 2021 Grokbase