diff --git a/akka-http-core/src/main/scala/akka/http/scaladsl/model/ErrorInfo.scala b/akka-http-core/src/main/scala/akka/http/scaladsl/model/ErrorInfo.scala index 57b87cee07..5f3f4ba701 100644 --- a/akka-http-core/src/main/scala/akka/http/scaladsl/model/ErrorInfo.scala +++ b/akka-http-core/src/main/scala/akka/http/scaladsl/model/ErrorInfo.scala @@ -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` " + diff --git a/akka-http-core/src/test/scala/akka/http/impl/engine/server/HttpServerSpec.scala b/akka-http-core/src/test/scala/akka/http/impl/engine/server/HttpServerSpec.scala index f3cb1224f4..dbb3adc141 100644 --- a/akka-http-core/src/test/scala/akka/http/impl/engine/server/HttpServerSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/impl/engine/server/HttpServerSpec.scala @@ -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]) diff --git a/project/MiMa.scala b/project/MiMa.scala index 289445f619..4d47c4757e 100644 --- a/project/MiMa.scala +++ b/project/MiMa.scala @@ -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") ) ) }