markusthoemmes commented on a change in pull request #2218: Port Controller 
from Spray to Akka
URL: 
https://github.com/apache/incubator-openwhisk/pull/2218#discussion_r132206383
 
 

 ##########
 File path: core/controller/src/main/scala/whisk/core/controller/Actions.scala
 ##########
 @@ -619,18 +626,33 @@ trait WhiskActionsApi
     /** Max atomic action count allowed for sequences */
     private lazy val actionSequenceLimit = 
whiskConfig.actionSequenceLimit.toInt
 
-    /** Custom deserializer for timeout query parameter. */
-    private implicit val stringToTimeoutDeserializer = new 
FromStringDeserializer[FiniteDuration] {
-        val max = WhiskActionsApi.maxWaitForBlockingActivation.toMillis
-        def apply(msecs: String): Either[DeserializationError, FiniteDuration] 
= {
-            Try { msecs.toInt } match {
-                case Success(i) if i > 0 && i <= max => Right(i.milliseconds)
-                case _ => Left {
-                    
MalformedContent(Messages.invalidTimeout(WhiskActionsApi.maxWaitForBlockingActivation))
-                }
+    implicit val stringToFiniteDuration: Unmarshaller[String, FiniteDuration] 
= {
+        Unmarshaller.strict[String, FiniteDuration] { value =>
+            val max = WhiskActionsApi.maxWaitForBlockingActivation.toMillis
+
+            Try {
+                value.toInt
+            } match {
+                case Success(i) if i > 0 && i <= max => i.milliseconds
+                case _ => throw new 
IllegalArgumentException(Messages.invalidTimeout(WhiskActionsApi.maxWaitForBlockingActivation))
             }
         }
     }
+
+    implicit val entityToJsObject: Unmarshaller[HttpEntity, JsObject] = {
+        
Unmarshaller.byteStringUnmarshaller.forContentTypes(`application/json`).mapWithCharset
 { (data, charset) =>
+            val decoded = data.decodeString(charset.nioCharset.name)
+
+            Try {
 
 Review comment:
   FWIW, here is the unmarshaller I wrote while debugging performance issues:
   
   ```scala
   implicit val entityToJsObject: FromEntityUnmarshaller[JsObject] =
           
Unmarshaller.byteStringUnmarshaller.forContentTypes(`application/json`).mapWithCharset
 { (data, charset) =>
               if (data.size == 0) {
                   JsObject()
               } else {
                   val input =
                       if (charset == HttpCharsets.`UTF-8`) 
ParserInput(data.toArray)
                       else ParserInput(data.decodeString(charset.nioCharset))
                   JsonParser(input).asJsObject
               }
           }
   ```
 
----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to