Skip to content

Commit

Permalink
[SPARK-11172] Close JsonParser/Generator in test
Browse files Browse the repository at this point in the history
Author: tedyu <[email protected]>

Closes #9157 from tedyu/master.
  • Loading branch information
tedyu authored and JoshRosen committed Oct 18, 2015
1 parent e2dfdbb commit 3895b21
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3895b21

Please sign in to comment.