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/01/28 13:00:50 UTC

[GitHub] markusthoemmes commented on issue #3228: Expensive fillInStackTrace when parsing CompletionMessage

markusthoemmes commented on issue #3228: Expensive fillInStackTrace when parsing CompletionMessage
URL: https://github.com/apache/incubator-openwhisk/issues/3228#issuecomment-361061319
 
 
   > That could help or just json deserialize and case match on object, string|number.
   
   I'd prefer that one. Quick PoC:
   
   ```diff
   diff --git a/common/scala/src/main/scala/whisk/core/connector/Message.scala b/common/scala/src/main/scala/whisk/core/connector/Message.scala
   index d79ba267..5c68192d 100644
   --- a/common/scala/src/main/scala/whisk/core/connector/Message.scala
   +++ b/common/scala/src/main/scala/whisk/core/connector/Message.scala
   @@ -95,6 +95,20 @@ case class CompletionMessage(override val transid: TransactionId,
    }
    
    object CompletionMessage extends DefaultJsonProtocol {
   +  implicit def eitherResponse =
   +    new JsonFormat[Either[ActivationId, WhiskActivation]] {
   +      def write(either: Either[ActivationId, WhiskActivation]) = either match {
   +        case Right(a) => a.toJson
   +        case Left(b)  => b.toJson
   +      }
   +
   +      def read(value: JsValue) = value match {
   +        case _: JsString => Left(value.convertTo[ActivationId])
   +        case _: JsObject => Right(value.convertTo[WhiskActivation])
   +        case _           => deserializationError("could not read response")
   +      }
   +    }
   +
      def parse(msg: String): Try[CompletionMessage] = Try(serdes.read(msg.parseJson))
      private val serdes = jsonFormat3(CompletionMessage.apply)
    }
   
   ```
   
   Works ? 

----------------------------------------------------------------
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