You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/02/07 14:41:24 UTC

[GitHub] rabbah closed pull request #3213: Fixes #3212 - WhiskConfig should close the property file source

rabbah closed pull request #3213: Fixes #3212 - WhiskConfig should close the property file source
URL: https://github.com/apache/incubator-openwhisk/pull/3213
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/common/scala/src/main/scala/whisk/core/WhiskConfig.scala b/common/scala/src/main/scala/whisk/core/WhiskConfig.scala
index b306cdbe22..22dfe232c1 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()
       }
     }
   }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services