You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ra...@apache.org on 2018/02/07 14:41:23 UTC
[incubator-openwhisk] branch master updated: Fixes #3212 -
WhiskConfig should close the property file source (#3213)
This is an automated email from the ASF dual-hosted git repository.
rabbah pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new ae34234 Fixes #3212 - WhiskConfig should close the property file source (#3213)
ae34234 is described below
commit ae342340a24578cd2af97130e906373c5d669c7d
Author: Chetan Mehrotra <ch...@apache.org>
AuthorDate: Wed Feb 7 20:11:19 2018 +0530
Fixes #3212 - WhiskConfig should close the property file source (#3213)
Close the source instance with try-finally usage.
---
.../src/main/scala/whisk/core/WhiskConfig.scala | 25 +++++++++++++---------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/common/scala/src/main/scala/whisk/core/WhiskConfig.scala b/common/scala/src/main/scala/whisk/core/WhiskConfig.scala
index b306cdb..22dfe23 100644
--- a/common/scala/src/main/scala/whisk/core/WhiskConfig.scala
+++ b/common/scala/src/main/scala/whisk/core/WhiskConfig.scala
@@ -135,18 +135,23 @@ object WhiskConfig {
implicit logging: Logging) = {
if (file != null && file.exists) {
logging.info(this, s"reading properties from file $file")
- for (line <- Source.fromFile(file).getLines if line.trim != "") {
- val parts = line.split('=')
- if (parts.length >= 1) {
- val p = parts(0).trim
- val v = if (parts.length == 2) parts(1).trim else ""
- if (properties.contains(p)) {
- properties += p -> v
- logging.debug(this, s"properties file set value for $p")
+ val source = Source.fromFile(file)
+ try {
+ for (line <- source.getLines if line.trim != "") {
+ val parts = line.split('=')
+ if (parts.length >= 1) {
+ val p = parts(0).trim
+ val v = if (parts.length == 2) parts(1).trim else ""
+ if (properties.contains(p)) {
+ properties += p -> v
+ logging.debug(this, s"properties file set value for $p")
+ }
+ } else {
+ logging.warn(this, s"ignoring properties $line")
}
- } else {
- logging.warn(this, s"ignoring properties $line")
}
+ } finally {
+ source.close()
}
}
}
--
To stop receiving notification emails like this one, please contact
rabbah@apache.org.