FAQ
Repository: hive
Updated Branches:
   refs/heads/branch-2.0 896016126 -> 2552a93ef


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/2552a93e
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/2552a93e
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/2552a93e

Branch: refs/heads/branch-2.0
Commit: 2552a93ef5264fadc7c80e85e2ed879ed7f63234
Parents: 8960161
Author: ctang <ctang@cloudera.com>
Authored: Mon Mar 21 12:21:58 2016 -0400
Committer: ctang <ctang@cloudera.com>
Committed: Mon Mar 21 12:23:41 2016 -0400

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


http://git-wip-us.apache.org/repos/asf/hive/blob/2552a93e/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

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 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