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

  • Ctang at Mar 22, 2016 at 11:16 am
    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
    + }
    + }
    + }
    + }
      }

Related Discussions

Discussion Navigation
viewthread | post
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