rabbah commented on a change in pull request #2218: Port Controller from Spray
to Akka
URL:
https://github.com/apache/incubator-openwhisk/pull/2218#discussion_r132202766
##########
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:
perhaps this should check `decoded.length > 0` and decode else return
JsObject and skip the try/catch in that case.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services