From 22a9d064e95af71f757113f1869f754cc862df35 Mon Sep 17 00:00:00 2001 From: "wm624@hotmail.com" Date: Thu, 10 Nov 2016 10:54:36 +0000 Subject: [SPARK-14914][CORE] Fix Resource not closed after using, for unit tests and example ## What changes were proposed in this pull request? This is a follow-up work of #15618. Close file source; For any newly created streaming context outside the withContext, explicitly close the context. ## How was this patch tested? Existing unit tests. Author: wm624@hotmail.com Closes #15818 from wangmiao1981/rtest. --- .../spark/sql/hive/thriftserver/HiveThriftServer2Suites.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sql/hive-thriftserver') diff --git a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2Suites.scala b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2Suites.scala index 8f2c4fafa0..5d20ec958c 100644 --- a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2Suites.scala +++ b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2Suites.scala @@ -609,7 +609,12 @@ class HiveThriftBinaryServerSuite extends HiveThriftJdbcTest { test("SPARK-11043 check operation log root directory") { val expectedLine = "Operation log root directory is created: " + operationLogPath.getAbsoluteFile - assert(Source.fromFile(logPath).getLines().exists(_.contains(expectedLine))) + val bufferSrc = Source.fromFile(logPath) + Utils.tryWithSafeFinally { + assert(bufferSrc.getLines().exists(_.contains(expectedLine))) + } { + bufferSrc.close() + } } } -- cgit v1.2.3