You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by gi...@git.apache.org on 2017/05/18 20:00:25 UTC

[GitHub] rabbah commented on a change in pull request #2256: surface errors in runtimes.manifest configuration in the controller logs

rabbah commented on a change in pull request #2256: surface errors in runtimes.manifest configuration in the controller logs
URL: https://github.com/apache/incubator-openwhisk/pull/2256#discussion_r117334530
 
 

 ##########
 File path: common/scala/src/main/scala/whisk/core/entity/ExecManifest.scala
 ##########
 @@ -41,20 +41,14 @@ protected[core] object ExecManifest {
      *
      * @param config a valid configuration
      * @param reinit re-initialize singleton iff true
-     * @return true if initialized successfully, or if previously initialized
+     * @return the manifest if initialized successfully, or if previously initialized
      */
-    protected[core] def initialize(config: WhiskConfig, reinit: Boolean = false): Boolean = {
+    protected[core] def initialize(config: WhiskConfig, reinit: Boolean = false): Try[_] = {
         if (manifest.isEmpty || reinit) {
-            val result = Try(config.runtimesManifest.parseJson.asJsObject)
+            Try(config.runtimesManifest.parseJson.asJsObject)
                 .flatMap(runtimes(_))
                 .map(m => manifest = Some(m))
-            result match {
-                case Success(res) =>
-                    true
-                case Failure(e) =>
-                    throw new IllegalStateException("Runtimes manifest is set but it's invalid: " + e.toString)
-            }
-        } else true
+        } else Success(manifest)
 
 Review comment:
   how about this alternate:
   
   ```git
   diff --git a/common/scala/src/main/scala/whisk/core/entity/ExecManifest.scala b/common/scala/src/main/scala/whisk/core/entity/ExecManifest.scala
   index 36bc262..71e3971 100644
   --- a/common/scala/src/main/scala/whisk/core/entity/ExecManifest.scala
   +++ b/common/scala/src/main/scala/whisk/core/entity/ExecManifest.scala
   @@ -16,7 +16,7 @@
    
    package whisk.core.entity
    
   -import scala.util.{Failure, Success, Try}
   +import scala.util.{ Failure, Success, Try }
    import spray.json._
    import spray.json.DefaultJsonProtocol._
    import whisk.core.WhiskConfig
   @@ -43,12 +43,12 @@ protected[core] object ExecManifest {
         * @param reinit re-initialize singleton iff true
         * @return the manifest if initialized successfully, or if previously initialized
         */
   -    protected[core] def initialize(config: WhiskConfig, reinit: Boolean = false): Try[_] = {
   +    protected[core] def initialize(config: WhiskConfig, reinit: Boolean = false): Try[Runtimes] = {
            if (manifest.isEmpty || reinit) {
   -            Try(config.runtimesManifest.parseJson.asJsObject)
   -                .flatMap(runtimes(_))
   -                .map(m => manifest = Some(m))
   -        } else Success(manifest)
   +            val mf = Try(config.runtimesManifest.parseJson.asJsObject).flatMap(runtimes(_))
   +            mf.foreach(m => manifest = Some(m))
   +            mf
   +        } else Success(manifest.get)
   ```
 
----------------------------------------------------------------
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