aboutsummaryrefslogtreecommitdiff
path: root/examples/src
diff options
context:
space:
mode:
authorwm624@hotmail.com <wm624@hotmail.com>2016-11-10 10:54:36 +0000
committerSean Owen <sowen@cloudera.com>2016-11-10 10:54:36 +0000
commit22a9d064e95af71f757113f1869f754cc862df35 (patch)
tree84ef9a282f54df6be1e44642863db65d2f4f8512 /examples/src
parent96a59109a912db9d5f6fc07dedd9d8a3eee97b96 (diff)
downloadspark-22a9d064e95af71f757113f1869f754cc862df35.tar.gz
spark-22a9d064e95af71f757113f1869f754cc862df35.tar.bz2
spark-22a9d064e95af71f757113f1869f754cc862df35.zip
[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 <wm624@hotmail.com> Closes #15818 from wangmiao1981/rtest.
Diffstat (limited to 'examples/src')
-rw-r--r--examples/src/main/scala/org/apache/spark/examples/LocalFileLR.scala4
1 files changed, 3 insertions, 1 deletions
diff --git a/examples/src/main/scala/org/apache/spark/examples/LocalFileLR.scala b/examples/src/main/scala/org/apache/spark/examples/LocalFileLR.scala
index 3d02ce0561..a897cad02f 100644
--- a/examples/src/main/scala/org/apache/spark/examples/LocalFileLR.scala
+++ b/examples/src/main/scala/org/apache/spark/examples/LocalFileLR.scala
@@ -51,7 +51,8 @@ object LocalFileLR {
showWarning()
- val lines = scala.io.Source.fromFile(args(0)).getLines().toArray
+ val fileSrc = scala.io.Source.fromFile(args(0))
+ val lines = fileSrc.getLines().toArray
val points = lines.map(parsePoint _)
val ITERATIONS = args(1).toInt
@@ -69,6 +70,7 @@ object LocalFileLR {
w -= gradient
}
+ fileSrc.close()
println("Final w: " + w)
}
}