I have created the following two Actions
def action1: Action[Either[MaxSizeExceeded, AnyContent]] = silhouette.SecuredAction.async(parse.maxLength(maxAllowedBodySize, parse.anyContent)(materializer)) { ...}
def action2:Action[AnyContent] = silhouette.UserAwareAction.async { ...}
While unit testing them, I found that result of action1's return is Future[Result] while that of action2 is Accumulator[ByteString, Result]
val response:Accumulator[ByteString,Result] = testEnv.controller.action1(request)
val response:Future[Result] = userTestEnv.controller.action2(request)
I can't quite figure out why there is a difference? Why are return type different?
I believe the reason is that for
Actionof type [Either[MaxSizeExceeded, AnyContent]], theActionreturnsAccumulator- https://www.playframework.com/documentation/2.6.x/ScalaEssentialActionIn general, it seems that if
Playknows that the body can be fit in memory then it returnsFuture[Result]otherwise it returnsAccumulator.