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:
commit
ad8ab128c4
3 changed files with 10 additions and 2 deletions
|
|
@ -80,7 +80,10 @@ object EntityStreamException {
|
||||||
* The limit can also be configured in code, by calling [[HttpEntity#withSizeLimit]]
|
* The limit can also be configured in code, by calling [[HttpEntity#withSizeLimit]]
|
||||||
* on the entity before materializing its `dataBytes` stream.
|
* 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 =
|
override def toString =
|
||||||
s"EntityStreamSizeException: actual entity size ($actualSize) exceeded content length limit ($limit bytes)! " +
|
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` " +
|
s"You can configure this by setting `akka.http.[server|client].parsing.max-content-length` or calling `HttpEntity.withSizeLimit` " +
|
||||||
|
|
|
||||||
|
|
@ -899,6 +899,7 @@ class HttpServerSpec extends AkkaSpec(
|
||||||
.thrownBy(entity.dataBytes.runFold(ByteString.empty)(_ ++ _).awaitResult(100.millis))
|
.thrownBy(entity.dataBytes.runFold(ByteString.empty)(_ ++ _).awaitResult(100.millis))
|
||||||
.getCause
|
.getCause
|
||||||
error shouldEqual EntityStreamSizeException(limit, Some(actualSize))
|
error shouldEqual EntityStreamSizeException(limit, Some(actualSize))
|
||||||
|
error.getMessage should include ("exceeded content length limit")
|
||||||
|
|
||||||
responses.expectRequest()
|
responses.expectRequest()
|
||||||
responses.sendError(error.asInstanceOf[Exception])
|
responses.sendError(error.asInstanceOf[Exception])
|
||||||
|
|
@ -921,6 +922,7 @@ class HttpServerSpec extends AkkaSpec(
|
||||||
.thrownBy(entity.dataBytes.runFold(ByteString.empty)(_ ++ _).awaitResult(100.millis))
|
.thrownBy(entity.dataBytes.runFold(ByteString.empty)(_ ++ _).awaitResult(100.millis))
|
||||||
.getCause
|
.getCause
|
||||||
error shouldEqual EntityStreamSizeException(limit, None)
|
error shouldEqual EntityStreamSizeException(limit, None)
|
||||||
|
error.getMessage should include ("exceeded content length limit")
|
||||||
|
|
||||||
responses.expectRequest()
|
responses.expectRequest()
|
||||||
responses.sendError(error.asInstanceOf[Exception])
|
responses.sendError(error.asInstanceOf[Exception])
|
||||||
|
|
|
||||||
|
|
@ -670,7 +670,10 @@ object MiMa extends AutoPlugin {
|
||||||
// #19983 withoutSizeLimit overrides for Scala API
|
// #19983 withoutSizeLimit overrides for Scala API
|
||||||
ProblemFilters.exclude[ReversedMissingMethodProblem]("akka.http.scaladsl.model.RequestEntity.withoutSizeLimit"),
|
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.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")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue