Return-Path: X-Original-To: apmail-spark-commits-archive@minotaur.apache.org Delivered-To: apmail-spark-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3A4B318D25 for ; Sun, 18 Oct 2015 09:13:04 +0000 (UTC) Received: (qmail 40211 invoked by uid 500); 18 Oct 2015 09:13:04 -0000 Delivered-To: apmail-spark-commits-archive@spark.apache.org Received: (qmail 40182 invoked by uid 500); 18 Oct 2015 09:13:04 -0000 Mailing-List: contact commits-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@spark.apache.org Received: (qmail 40173 invoked by uid 99); 18 Oct 2015 09:13:04 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Oct 2015 09:13:04 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id EE3B6DFF09; Sun, 18 Oct 2015 09:13:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: joshrosen@apache.org To: commits@spark.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: spark git commit: [SPARK-11172] Close JsonParser/Generator in test Date: Sun, 18 Oct 2015 09:13:03 +0000 (UTC) Repository: spark Updated Branches: refs/heads/master e2dfdbb2c -> 3895b2113 [SPARK-11172] Close JsonParser/Generator in test Author: tedyu 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 Authored: Sun Oct 18 02:12:56 2015 -0700 Committer: Josh Rosen 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