spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshro...@apache.org
Subject spark git commit: [SPARK-11172] Close JsonParser/Generator in test
Date Sun, 18 Oct 2015 09:13:03 GMT
Repository: spark
Updated Branches:
  refs/heads/master e2dfdbb2c -> 3895b2113


[SPARK-11172] Close JsonParser/Generator in test

Author: tedyu <yuzhihong@gmail.com>

Closes #9157 from tedyu/master.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/3895b211
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/3895b211
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/3895b211

Branch: refs/heads/master
Commit: 3895b2113a726171b3c9c04fe41b3cc93d6d14b5
Parents: e2dfdbb
Author: tedyu <yuzhihong@gmail.com>
Authored: Sun Oct 18 02:12:56 2015 -0700
Committer: Josh Rosen <joshrosen@databricks.com>
Committed: Sun Oct 18 02:12:56 2015 -0700

----------------------------------------------------------------------
 .../sql/execution/datasources/json/JsonSuite.scala    | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/3895b211/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/json/JsonSuite.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/json/JsonSuite.scala
b/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/json/JsonSuite.scala
index b614e6c..7540223 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/json/JsonSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/json/JsonSuite.scala
@@ -47,13 +47,15 @@ class JsonSuite extends QueryTest with SharedSQLContext with TestJsonData
{
     val factory = new JsonFactory()
     def enforceCorrectType(value: Any, dataType: DataType): Any = {
       val writer = new StringWriter()
-      val generator = factory.createGenerator(writer)
-      generator.writeObject(value)
-      generator.flush()
+      Utils.tryWithResource(factory.createGenerator(writer)) { generator =>
+        generator.writeObject(value)
+        generator.flush()
+      }
 
-      val parser = factory.createParser(writer.toString)
-      parser.nextToken()
-      JacksonParser.convertField(factory, parser, dataType)
+      Utils.tryWithResource(factory.createParser(writer.toString)) { parser =>
+        parser.nextToken()
+        JacksonParser.convertField(factory, parser, dataType)
+      }
     }
 
     val intNumber: Int = 2147483647


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org


Mime
View raw message