Merge pull request #20014 from johanandren/wip-20014-non-null-message-on-stream-size-ex-johanandren

=htt #20014 Provide a description as stream size exception message
This commit is contained in:
Johan Andrén 2016-03-14 15:03:59 +01:00
commit ad8ab128c4
3 changed files with 10 additions and 2 deletions

View file

@ -80,7 +80,10 @@ object EntityStreamException {
* The limit can also be configured in code, by calling [[HttpEntity#withSizeLimit]]
* on the entity before materializing its `dataBytes` stream.
*/
case class EntityStreamSizeException(limit: Long, actualSize: Option[Long] = None) extends RuntimeException {
final case class EntityStreamSizeException(limit: Long, actualSize: Option[Long] = None) extends RuntimeException {
override def getMessage = toString
override def toString =
s"EntityStreamSizeException: actual entity size ($actualSize) exceeded content length limit ($limit bytes)! " +
s"You can configure this by setting `akka.http.[server|client].parsing.max-content-length` or calling `HttpEntity.withSizeLimit` " +

View file

@ -899,6 +899,7 @@ class HttpServerSpec extends AkkaSpec(
.thrownBy(entity.dataBytes.runFold(ByteString.empty)(_ ++ _).awaitResult(100.millis))
.getCause
error shouldEqual EntityStreamSizeException(limit, Some(actualSize))
error.getMessage should include ("exceeded content length limit")
responses.expectRequest()
responses.sendError(error.asInstanceOf[Exception])
@ -921,6 +922,7 @@ class HttpServerSpec extends AkkaSpec(
.thrownBy(entity.dataBytes.runFold(ByteString.empty)(_ ++ _).awaitResult(100.millis))
.getCause
error shouldEqual EntityStreamSizeException(limit, None)
error.getMessage should include ("exceeded content length limit")
responses.expectRequest()
responses.sendError(error.asInstanceOf[Exception])

View file

@ -670,7 +670,10 @@ object MiMa extends AutoPlugin {
// #19983 withoutSizeLimit overrides for Scala API
ProblemFilters.exclude[ReversedMissingMethodProblem]("akka.http.scaladsl.model.RequestEntity.withoutSizeLimit"),
ProblemFilters.exclude[ReversedMissingMethodProblem]("akka.http.scaladsl.model.UniversalEntity.withoutSizeLimit"),
ProblemFilters.exclude[ReversedMissingMethodProblem]("akka.http.scaladsl.model.ResponseEntity.withoutSizeLimit")
ProblemFilters.exclude[ReversedMissingMethodProblem]("akka.http.scaladsl.model.ResponseEntity.withoutSizeLimit"),
// #20014 should have been final always
ProblemFilters.exclude[FinalClassProblem]("akka.http.scaladsl.model.EntityStreamSizeException")
)
)
}