You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ct...@apache.org on 2016/03/21 17:23:56 UTC
hive git commit: HIVE-13294: AvroSerde leaks the connection in a case
when reading schema from a url (Chaoyu Tang, reviewed by Aihua Xu)
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 <ct...@cloudera.com>
Authored: Mon Mar 21 12:21:58 2016 -0400
Committer: ctang <ct...@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
+ }
+ }
+ }
+ }
}