diff --git a/docs/src/main/paradox/release-notes/releases-2.1.md b/docs/src/main/paradox/release-notes/releases-2.1.md index b0092de78e..0b1d66c325 100644 --- a/docs/src/main/paradox/release-notes/releases-2.1.md +++ b/docs/src/main/paradox/release-notes/releases-2.1.md @@ -22,6 +22,24 @@ Pekko HTTP 2.1.0 has not been released yet. These notes list the changes merged so far. +### Removed APIs + +These removals are source and binary incompatible with Pekko HTTP 2.0. Recompile applications and +libraries that used the removed members against the replacement APIs before upgrading. + +* For HTTP 413 and 422, use Scala `ContentTooLarge` and `UnprocessableContent` or Java + `CONTENT_TOO_LARGE` and `UNPROCESSABLE_CONTENT`. The wire status codes are unchanged. +* Replace the four-argument Scala `HttpMethod.custom` and Java `HttpMethods.custom` factories with + the five-argument overload. Choose `contentLengthAllowed` for the method explicitly; a fixed Boolean + is not equivalent to the old status-dependent rule. +* In the Java routing DSL, use the `java.time.Duration` overloads of `withRequestTimeout`, + `extractStrictEntity` and `toStrictEntity` for finite durations. To disable the timeout, use + `withoutRequestTimeout`. This does not also install a timeout response handler. +* The legacy Scala coding implementation types (`Gzip`, `Deflate`, `NoCoding`, `StreamDecoder` + and `Compressor`) are now package-internal. Use `Coders.Gzip`, `Coders.Deflate` and + `Coders.NoCoding` for built-in codecs, or `Coders.fromFlows` for a custom codec. The Java + `Coder` enum and its built-in variants are unchanged. + ### Behavior Changes * The `Link` header parser now accepts unquoted `anchor` values that are valid HTTP tokens and URI references, diff --git a/docs/src/test/scala/docs/http/scaladsl/server/directives/CodingDirectivesExamplesSpec.scala b/docs/src/test/scala/docs/http/scaladsl/server/directives/CodingDirectivesExamplesSpec.scala index 7366904e05..d1ce501702 100644 --- a/docs/src/test/scala/docs/http/scaladsl/server/directives/CodingDirectivesExamplesSpec.scala +++ b/docs/src/test/scala/docs/http/scaladsl/server/directives/CodingDirectivesExamplesSpec.scala @@ -14,7 +14,7 @@ package docs.http.scaladsl.server.directives import org.apache.pekko -import pekko.http.scaladsl.coding.{ Coder, Coders, Gzip } +import pekko.http.scaladsl.coding.{ Coder, Coders } import pekko.http.scaladsl.model.{ HttpEntity, HttpResponse } import pekko.http.scaladsl.model.headers.{ `Accept-Encoding`, `Content-Encoding`, HttpEncoding, HttpEncodings } import pekko.http.scaladsl.model.headers.HttpEncodings._ diff --git a/http-core/src/main/java/org/apache/pekko/http/javadsl/model/HttpMethods.java b/http-core/src/main/java/org/apache/pekko/http/javadsl/model/HttpMethods.java index 808a6c1ad5..87bffddeae 100644 --- a/http-core/src/main/java/org/apache/pekko/http/javadsl/model/HttpMethods.java +++ b/http-core/src/main/java/org/apache/pekko/http/javadsl/model/HttpMethods.java @@ -34,27 +34,6 @@ private HttpMethods() {} public static final HttpMethod QUERY = org.apache.pekko.http.scaladsl.model.HttpMethods.QUERY(); public static final HttpMethod TRACE = org.apache.pekko.http.scaladsl.model.HttpMethods.TRACE(); - /** - * Create a custom method type. - * - * @deprecated The created method will compute the presence of Content-Length headers based on - * deprecated logic, use {@link #custom(String, boolean, boolean, - * org.apache.pekko.http.javadsl.model.RequestEntityAcceptance, boolean)} instead. Deprecated - * since 1.4.0. - */ - @Deprecated(since = "1.4.0") - public static HttpMethod custom( - String value, - boolean safe, - boolean idempotent, - org.apache.pekko.http.javadsl.model.RequestEntityAcceptance requestEntityAcceptance) { - // This cast is safe as implementation of RequestEntityAcceptance only exists in Scala - org.apache.pekko.http.scaladsl.model.RequestEntityAcceptance scalaRequestEntityAcceptance = - (org.apache.pekko.http.scaladsl.model.RequestEntityAcceptance) requestEntityAcceptance; - return org.apache.pekko.http.scaladsl.model.HttpMethod.custom( - value, safe, idempotent, scalaRequestEntityAcceptance); - } - /** * Create a custom method type. * diff --git a/http-core/src/main/java/org/apache/pekko/http/javadsl/model/StatusCodes.java b/http-core/src/main/java/org/apache/pekko/http/javadsl/model/StatusCodes.java index d1ef4227e5..af73458c97 100644 --- a/http-core/src/main/java/org/apache/pekko/http/javadsl/model/StatusCodes.java +++ b/http-core/src/main/java/org/apache/pekko/http/javadsl/model/StatusCodes.java @@ -100,13 +100,6 @@ private StatusCodes() {} public static final StatusCode CONTENT_TOO_LARGE = org.apache.pekko.http.scaladsl.model.StatusCodes.ContentTooLarge(); - /** - * @deprecated deprecated in favor of CONTENT_TOO_LARGE since 1.1.0 - */ - @Deprecated(since = "1.1.0") - public static final StatusCode PAYLOAD_TOO_LARGE = - org.apache.pekko.http.scaladsl.model.StatusCodes.PayloadTooLarge(); - public static final StatusCode URI_TOO_LONG = org.apache.pekko.http.scaladsl.model.StatusCodes.UriTooLong(); @@ -126,13 +119,6 @@ private StatusCodes() {} public static final StatusCode UNPROCESSABLE_CONTENT = org.apache.pekko.http.scaladsl.model.StatusCodes.UnprocessableContent(); - /** - * @deprecated deprecated in favor of UNPROCESSABLE_CONTENT since 1.1.0 - */ - @Deprecated(since = "1.1.0") - public static final StatusCode UNPROCESSABLE_ENTITY = - org.apache.pekko.http.scaladsl.model.StatusCodes.UnprocessableEntity(); - public static final StatusCode LOCKED = org.apache.pekko.http.scaladsl.model.StatusCodes.Locked(); public static final StatusCode FAILED_DEPENDENCY = org.apache.pekko.http.scaladsl.model.StatusCodes.FailedDependency(); diff --git a/http-core/src/main/mima-filters/2.1.x.backwards.excludes/pre-2-deprecations.excludes b/http-core/src/main/mima-filters/2.1.x.backwards.excludes/pre-2-deprecations.excludes new file mode 100644 index 0000000000..85dbbc7ac2 --- /dev/null +++ b/http-core/src/main/mima-filters/2.1.x.backwards.excludes/pre-2-deprecations.excludes @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Intentional removals of public APIs deprecated before 2.0; keep every other overload checked. +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.model.HttpMethods.custom(java.lang.String,Boolean,Boolean,org.apache.pekko.http.javadsl.model.RequestEntityAcceptance)org.apache.pekko.http.javadsl.model.HttpMethod") +ProblemFilters.exclude[MissingFieldProblem]("org.apache.pekko.http.javadsl.model.StatusCodes.PAYLOAD_TOO_LARGE") +ProblemFilters.exclude[MissingFieldProblem]("org.apache.pekko.http.javadsl.model.StatusCodes.UNPROCESSABLE_ENTITY") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.model.HttpMethod.custom(java.lang.String,Boolean,Boolean,org.apache.pekko.http.scaladsl.model.RequestEntityAcceptance)org.apache.pekko.http.scaladsl.model.HttpMethod") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.model.StatusCodes.PayloadTooLarge()org.apache.pekko.http.scaladsl.model.StatusCodes#ClientError") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.model.StatusCodes.UnprocessableEntity()org.apache.pekko.http.scaladsl.model.StatusCodes#ClientError") diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpMethod.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpMethod.scala index c54f9216d8..93fa2129dc 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpMethod.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpMethod.scala @@ -56,21 +56,6 @@ final case class HttpMethod private[http] ( object HttpMethod { - // the allowsEntity condition was used to determine what responses provided the Content-Length header, before the fix - private def oldContentLengthCondition(status: StatusCode) = status.allowsEntity - - /** - * Create a custom method type. - * @deprecated The created method will compute the presence of Content-Length headers based on deprecated logic. - */ - @deprecated("Use the overload with contentLengthAllowed parameter", since = "1.4.0") - def custom(name: String, safe: Boolean, idempotent: Boolean, requestEntityAcceptance: RequestEntityAcceptance) - : HttpMethod = { - requireToken(name) - require(!safe || idempotent, "An HTTP method cannot be safe without being idempotent") - apply(name, safe, idempotent, requestEntityAcceptance, oldContentLengthCondition) - } - /** * Create a custom method type. */ diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/StatusCode.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/StatusCode.scala index 7e853dfb02..b16e5ddf46 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/StatusCode.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/StatusCode.scala @@ -178,8 +178,6 @@ object StatusCodes extends ObjectRegistry[Int, StatusCode] { val LengthRequired = reg(c(411)("Length Required", "The request did not specify the length of its content, which is required by the requested resource.")) val PreconditionFailed = reg(c(412)("Precondition Failed", "The server does not meet one of the preconditions that the requester put on the request.")) val ContentTooLarge = reg(c(413)("Content Too Large", "The request content is larger than the server is willing or able to process.")) - @deprecated("deprecated in favor of ContentTooLarge", "1.1.0") - val PayloadTooLarge = ContentTooLarge val UriTooLong = reg(c(414)("URI Too Long", "The URI provided was too long for the server to process.")) val UnsupportedMediaType = reg(c(415)("Unsupported Media Type", "The request entity has a media type which the server or resource does not support.")) val RangeNotSatisfiable = reg(c(416)("Range Not Satisfiable", "The client has asked for a portion of the file, but the server cannot supply that portion.")) @@ -188,8 +186,6 @@ object StatusCodes extends ObjectRegistry[Int, StatusCode] { val EnhanceYourCalm = reg(c(420)("Enhance Your Calm", "You are being rate-limited.")) // Twitter only val MisdirectedRequest = reg(c(421)("Misdirected Request", "The request was directed at a server that is not able to produce a response.")) // RFC 9110 section 15.5.20 val UnprocessableContent = reg(c(422)("Unprocessable Content", "The request was well-formed but was unable to be followed due to semantic errors.")) - @deprecated("deprecated in favor of UnprocessableContent", "1.1.0") - val UnprocessableEntity = UnprocessableContent val Locked = reg(c(423)("Locked", "The resource that is being accessed is locked.")) val FailedDependency = reg(c(424)("Failed Dependency", "The request failed due to failure of a previous request.")) val TooEarly = reg(c(425)("Too Early", "The server is unwilling to risk processing a request that might be replayed.")) // RFC 8470 diff --git a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/HostConnectionPoolSpec.scala b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/HostConnectionPoolSpec.scala index 3014c15c00..90fad6d37a 100644 --- a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/HostConnectionPoolSpec.scala +++ b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/HostConnectionPoolSpec.scala @@ -289,7 +289,7 @@ class HostConnectionPoolSpec extends PekkoSpecWithMaterializer( reqInProbe.expectUtf8EncodedString("test") // the server rejects the request before the request entity has been sent completely - conn1.pushResponse(HttpResponse(StatusCodes.PayloadTooLarge, entity = "too large")) + conn1.pushResponse(HttpResponse(StatusCodes.ContentTooLarge, entity = "too large")) expectResponseEntityAsString() shouldEqual "too large" // the rest of the request entity is not sent diff --git a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/pool/SlotStateSpec.scala b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/pool/SlotStateSpec.scala index ae9f76569e..a7fc692cc6 100644 --- a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/pool/SlotStateSpec.scala +++ b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/pool/SlotStateSpec.scala @@ -158,7 +158,7 @@ class SlotStateSpec extends PekkoSpec { } "close the connection right away after an early error response" in { - earlyResponseCompleted(new MockSlotContext(system.log), HttpResponse(StatusCodes.PayloadTooLarge)) should + earlyResponseCompleted(new MockSlotContext(system.log), HttpResponse(StatusCodes.ContentTooLarge)) should be(ToBeClosed) } diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/CodersSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/CodersSpec.scala index 576cb6ebb9..f14434d2b2 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/CodersSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/CodersSpec.scala @@ -17,7 +17,6 @@ package org.apache.pekko.http.scaladsl.coding -import scala.annotation.nowarn import scala.concurrent.duration._ import org.apache.pekko @@ -128,7 +127,6 @@ class CodersSpec extends AnyWordSpec with CodecSpecSupport { } "preserve custom stream decoders' explicit choice of a compatible codec" in { - @nowarn("msg=deprecated") val custom = new StreamDecoder { val encoding = HttpEncoding.custom("x-application-gzip") protected def newDecompressorStage(maxBytesPerChunk: Int) = () => new GzipDecompressor(maxBytesPerChunk) diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/DecoderSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/DecoderSpec.scala index 302503f8f8..ca292200aa 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/DecoderSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/DecoderSpec.scala @@ -13,7 +13,6 @@ package org.apache.pekko.http.scaladsl.coding -import scala.annotation.nowarn import scala.concurrent.duration._ import org.apache.pekko @@ -49,7 +48,6 @@ class DecoderSpec extends AnyWordSpec with CodecSpecSupport { def dummyDecompress(s: String): String = dummyDecompress(ByteString(s, "UTF8")).decodeString("UTF8") def dummyDecompress(bytes: ByteString): ByteString = DummyDecoder.decode(bytes).awaitResult(3.seconds.dilated) - @nowarn("msg=is internal API") case object DummyDecoder extends StreamDecoder { val encoding = HttpEncodings.compress diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/DeflateSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/DeflateSpec.scala index 4e99c03bcc..7cb5c4e05a 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/DeflateSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/DeflateSpec.scala @@ -18,7 +18,6 @@ import java.util.concurrent.{ CountDownLatch, TimeUnit } import java.util.concurrent.atomic.AtomicInteger import java.util.zip._ -import scala.annotation.nowarn import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.duration._ @@ -119,7 +118,6 @@ class DeflateSpec extends CoderSpec { private def decodeWith(inflater: TrackingInflater, bytes: ByteString): ByteString = decoderWith(inflater).decode(bytes)(SystemMaterializer(system).materializer).awaitResult(3.seconds.dilated) - @nowarn("msg=deprecated") private def encoderWith(tracking: TrackingDeflater): Deflate = new Deflate(Encoder.DefaultFilter) { override private[http] def newCompressor: DeflateCompressor = new DeflateCompressor() { @@ -127,7 +125,6 @@ class DeflateSpec extends CoderSpec { } } - @nowarn("msg=deprecated") private def decoderWith(inflater: TrackingInflater): StreamDecoder = new StreamDecoder { override val encoding = HttpEncodings.deflate @@ -168,7 +165,6 @@ class DeflateSpec extends CoderSpec { } private def encodeMessage(request: HttpRequest, compressionLevel: Int, noWrap: Boolean): HttpRequest = { - @nowarn("msg=deprecated .* is internal API") val deflaterWithoutWrapping = new Deflate(Encoder.DefaultFilter) { override def newCompressor = new DeflateCompressor(compressionLevel) { override lazy val deflater = new Deflater(compressionLevel, noWrap) diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/EncoderSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/EncoderSpec.scala index 36c129f2d0..df1e0df71b 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/EncoderSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/EncoderSpec.scala @@ -13,7 +13,6 @@ package org.apache.pekko.http.scaladsl.coding -import scala.annotation.nowarn import scala.concurrent.duration._ import org.apache.pekko @@ -51,7 +50,6 @@ class EncoderSpec extends AnyWordSpec with CodecSpecSupport { def newCompressor = DummyCompressor } - @nowarn("msg=is internal API") case object DummyCompressor extends Compressor { def compress(input: ByteString) = input ++ ByteString("compressed") def flush() = ByteString.empty diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/GzipSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/GzipSpec.scala index 1abccbdfdd..54c169a7f0 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/GzipSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/GzipSpec.scala @@ -19,7 +19,6 @@ import java.util.concurrent.{ CountDownLatch, TimeUnit } import java.util.concurrent.atomic.AtomicInteger import java.util.zip.{ GZIPInputStream, GZIPOutputStream, Inflater, ZipException } -import scala.annotation.nowarn import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.duration._ @@ -145,7 +144,6 @@ class GzipSpec extends CoderSpec { private def decodeWith(tracking: TrackingInflater, bytes: ByteString): ByteString = decoderWith(tracking).decode(bytes)(SystemMaterializer(system).materializer).awaitResult(3.seconds.dilated) - @nowarn("msg=deprecated") private def decoderWith(tracking: TrackingInflater): Gzip = new Gzip(Encoder.DefaultFilter) { override def newDecompressorStage(maxBytesPerChunk: Int) = @@ -155,7 +153,6 @@ class GzipSpec extends CoderSpec { } } - @nowarn("msg=deprecated") private def encoderWith(tracking: TrackingDeflater): Gzip = new Gzip(Encoder.DefaultFilter) { override private[http] def newCompressor: GzipCompressor = new GzipCompressor() { diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/ZstdSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/ZstdSpec.scala index a9e0931ef5..178ac3b52a 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/ZstdSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/ZstdSpec.scala @@ -19,7 +19,6 @@ package org.apache.pekko.http.scaladsl.coding import java.io.{ InputStream, OutputStream } -import scala.annotation.nowarn import scala.concurrent.duration._ import com.github.luben.zstd.{ ZstdInputStream, ZstdOutputStream } @@ -133,7 +132,6 @@ class ZstdSpec extends CoderSpec { windowBase + (windowBase / 8) * (windowDescriptor & 0x7) } - @nowarn("msg=deprecated") private def encoderWith(compressor: Compressor): Encoder = new Encoder { override def encoding: HttpEncoding = HttpEncodings.zstd diff --git a/http/src/main/java/org/apache/pekko/http/javadsl/coding/Coder.java b/http/src/main/java/org/apache/pekko/http/javadsl/coding/Coder.java index 23859ae28a..3d01f1b5fb 100644 --- a/http/src/main/java/org/apache/pekko/http/javadsl/coding/Coder.java +++ b/http/src/main/java/org/apache/pekko/http/javadsl/coding/Coder.java @@ -17,24 +17,21 @@ import org.apache.pekko.http.javadsl.model.HttpRequest; import org.apache.pekko.http.javadsl.model.HttpResponse; import org.apache.pekko.http.scaladsl.coding.Coders$; -import org.apache.pekko.http.scaladsl.coding.Deflate$; -import org.apache.pekko.http.scaladsl.coding.Gzip$; -import org.apache.pekko.http.scaladsl.coding.NoCoding$; +import org.apache.pekko.http.scaladsl.coding.Encoder$; import org.apache.pekko.http.scaladsl.coding.Zstd$; import org.apache.pekko.stream.Materializer; import org.apache.pekko.util.ByteString; import scala.jdk.javaapi.FutureConverters; /** A coder is an implementation of the predefined encoders/decoders defined for HTTP. */ -@SuppressWarnings("deprecation") public enum Coder { - NoCoding(NoCoding$.MODULE$), - Deflate(Deflate$.MODULE$), - Gzip(Gzip$.MODULE$), - DeflateLevel1(Deflate$.MODULE$.withLevel(1)), - DeflateLevel9(Deflate$.MODULE$.withLevel(9)), - GzipLevel1(Gzip$.MODULE$.withLevel(1)), - GzipLevel9(Gzip$.MODULE$.withLevel(9)), + NoCoding(Coders$.MODULE$.NoCoding()), + Deflate(Coders$.MODULE$.Deflate()), + Gzip(Coders$.MODULE$.Gzip()), + DeflateLevel1(Coders$.MODULE$.Deflate(Encoder$.MODULE$.DefaultFilter(), 1)), + DeflateLevel9(Coders$.MODULE$.Deflate(Encoder$.MODULE$.DefaultFilter(), 9)), + GzipLevel1(Coders$.MODULE$.Gzip(Encoder$.MODULE$.DefaultFilter(), 1)), + GzipLevel9(Coders$.MODULE$.Gzip(Encoder$.MODULE$.DefaultFilter(), 9)), /** * The 'zstd' encoding, which needs the optional {@code com.github.luben:zstd-jni} dependency on * the classpath. diff --git a/http/src/main/mima-filters/2.1.x.backwards.excludes/pre-2-deprecations.excludes b/http/src/main/mima-filters/2.1.x.backwards.excludes/pre-2-deprecations.excludes new file mode 100644 index 0000000000..173e98abd1 --- /dev/null +++ b/http/src/main/mima-filters/2.1.x.backwards.excludes/pre-2-deprecations.excludes @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Intentional removals of public APIs deprecated before 2.0; keep every other overload checked. +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.server.directives.BasicDirectives.extractStrictEntity(scala.concurrent.duration.FiniteDuration,java.util.function.Function)org.apache.pekko.http.javadsl.server.Route") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.server.directives.BasicDirectives.extractStrictEntity(scala.concurrent.duration.FiniteDuration,Long,java.util.function.Function)org.apache.pekko.http.javadsl.server.Route") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.server.directives.BasicDirectives.toStrictEntity(scala.concurrent.duration.FiniteDuration,java.util.function.Supplier)org.apache.pekko.http.javadsl.server.Route") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.server.directives.BasicDirectives.toStrictEntity(scala.concurrent.duration.FiniteDuration,Long,java.util.function.Supplier)org.apache.pekko.http.javadsl.server.Route") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.server.directives.TimeoutDirectives.withRequestTimeout(scala.concurrent.duration.Duration,java.util.function.Supplier)org.apache.pekko.http.javadsl.server.directives.RouteAdapter") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.server.directives.TimeoutDirectives.withRequestTimeout(scala.concurrent.duration.Duration,java.util.function.Function,java.util.function.Supplier)org.apache.pekko.http.javadsl.server.directives.RouteAdapter") diff --git a/http/src/main/mima-filters/binary-api b/http/src/main/mima-filters/binary-api new file mode 100644 index 0000000000..01a3e83cc1 --- /dev/null +++ b/http/src/main/mima-filters/binary-api @@ -0,0 +1,30 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# The legacy Scala coding implementations are package-internal but their JVM types still link. +# Keep checking those types and members instead of ignoring the visibility change. +BinaryApi.keep[ClassNoLongerCheckedProblem]("org.apache.pekko.http.scaladsl.coding.Compressor") +BinaryApi.keep[ClassNoLongerCheckedProblem]("org.apache.pekko.http.scaladsl.coding.Deflate") +BinaryApi.keep[ClassNoLongerCheckedProblem]("org.apache.pekko.http.scaladsl.coding.Deflate$") +BinaryApi.keep[ClassNoLongerCheckedProblem]("org.apache.pekko.http.scaladsl.coding.DeflateDecompressor") +BinaryApi.keep[ClassNoLongerCheckedProblem]("org.apache.pekko.http.scaladsl.coding.DeflateDecompressorBase") +BinaryApi.keep[ClassNoLongerCheckedProblem]("org.apache.pekko.http.scaladsl.coding.Gzip") +BinaryApi.keep[ClassNoLongerCheckedProblem]("org.apache.pekko.http.scaladsl.coding.Gzip$") +BinaryApi.keep[ClassNoLongerCheckedProblem]("org.apache.pekko.http.scaladsl.coding.GzipDecompressor") +BinaryApi.keep[ClassNoLongerCheckedProblem]("org.apache.pekko.http.scaladsl.coding.NoCoding") +BinaryApi.keep[ClassNoLongerCheckedProblem]("org.apache.pekko.http.scaladsl.coding.NoCoding$") +BinaryApi.keep[ClassNoLongerCheckedProblem]("org.apache.pekko.http.scaladsl.coding.StreamDecoder") diff --git a/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/BasicDirectives.scala b/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/BasicDirectives.scala index eb2097cacf..a3c8ff182e 100644 --- a/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/BasicDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/BasicDirectives.scala @@ -22,7 +22,6 @@ import java.util.function.Predicate import java.util.function.Supplier import scala.concurrent.{ ExecutionContext, ExecutionContextExecutor } -import scala.concurrent.duration.FiniteDuration import scala.jdk.DurationConverters._ import scala.jdk.FutureConverters._ @@ -337,25 +336,6 @@ abstract class BasicDirectives { */ def extractRequestEntity(inner: JFunction[RequestEntity, Route]): Route = extractEntity(inner) - /** - * WARNING: This will read the entire request entity into memory and effectively disable streaming. - * - * To help protect against excessive memory use, the request will be aborted if the request is larger - * than allowed by the `pekko.http.parsing.max-to-strict-bytes` configuration setting. - * - * Converts the HttpEntity from the [[pekko.http.javadsl.server.RequestContext]] into an - * [[pekko.http.javadsl.model.HttpEntity.Strict]] and extracts it, or fails the route if unable to drain the - * entire request body within the timeout. - * - * @param timeout The directive is failed if the stream isn't completed after the given timeout. - * @deprecated As of 1.3.0, use the overloaded method taking a `java.time.Duration` instead. - */ - @Deprecated(since = "1.3.0") - @deprecated("use the overloaded method taking a `java.time.Duration` instead.", "1.3.0") - def extractStrictEntity(timeout: FiniteDuration, inner: JFunction[HttpEntity.Strict, Route]): Route = RouteAdapter { - D.extractStrictEntity(timeout) { strict => inner.apply(strict).delegate } - } - /** * WARNING: This will read the entire request entity into memory and effectively disable streaming. * @@ -373,26 +353,6 @@ abstract class BasicDirectives { D.extractStrictEntity(timeout.toScala) { strict => inner.apply(strict).delegate } } - /** - * WARNING: This will read the entire request entity into memory and effectively disable streaming. - * - * To help protect against excessive memory use, the request will be aborted if the request is larger - * than allowed by the `pekko.http.parsing.max-to-strict-bytes` configuration setting. - * - * Converts the HttpEntity from the [[pekko.http.javadsl.server.RequestContext]] into an - * [[pekko.http.javadsl.model.HttpEntity.Strict]] and extracts it, or fails the route if unable to drain the - * entire request body within the timeout. - * - * @param timeout The directive is failed if the stream isn't completed after the given timeout. - * @deprecated As of 1.3.0, use the overloaded method taking a `java.time.Duration` instead. - */ - @Deprecated(since = "1.3.0") - @deprecated("use the overloaded method taking a `java.time.Duration` instead.", "1.3.0") - def extractStrictEntity(timeout: FiniteDuration, maxBytes: Long, inner: JFunction[HttpEntity.Strict, Route]): Route = - RouteAdapter { - D.extractStrictEntity(timeout, maxBytes) { strict => inner.apply(strict).delegate } - } - /** * WARNING: This will read the entire request entity into memory and effectively disable streaming. * @@ -411,24 +371,6 @@ abstract class BasicDirectives { D.extractStrictEntity(timeout.toScala, maxBytes) { strict => inner.apply(strict).delegate } } - /** - * WARNING: This will read the entire request entity into memory and effectively disable streaming. - * - * To help protect against excessive memory use, the request will be aborted if the request is larger - * than allowed by the `pekko.http.parsing.max-to-strict-bytes` configuration setting. - * - * Extracts the [[pekko.http.javadsl.server.RequestContext]] itself with the strict HTTP entity, - * or fails the route if unable to drain the entire request body within the timeout. - * - * @param timeout The directive is failed if the stream isn't completed after the given timeout. - * @deprecated As of 1.3.0, use the overloaded method taking a `java.time.Duration` instead. - */ - @Deprecated(since = "1.3.0") - @deprecated("use the overloaded method taking a `java.time.Duration` instead.", "1.3.0") - def toStrictEntity(timeout: FiniteDuration, inner: Supplier[Route]): Route = RouteAdapter { - D.toStrictEntity(timeout) { inner.get.delegate } - } - /** * WARNING: This will read the entire request entity into memory and effectively disable streaming. * @@ -445,24 +387,6 @@ abstract class BasicDirectives { D.toStrictEntity(timeout.toScala) { inner.get.delegate } } - /** - * WARNING: This will read the entire request entity into memory and effectively disable streaming. - * - * To help protect against excessive memory use, the request will be aborted if the request is larger - * than allowed by the `pekko.http.parsing.max-to-strict-bytes` configuration setting. - * - * Extracts the [[pekko.http.javadsl.server.RequestContext]] itself with the strict HTTP entity, - * or fails the route if unable to drain the entire request body within the timeout. - * - * @param timeout The directive is failed if the stream isn't completed after the given timeout. - * @deprecated As of 1.3.0, use the overloaded method taking a `java.time.Duration` instead. - */ - @Deprecated(since = "1.3.0") - @deprecated("use the overloaded method taking a `java.time.Duration` instead.", "1.3.0") - def toStrictEntity(timeout: FiniteDuration, maxBytes: Long, inner: Supplier[Route]): Route = RouteAdapter { - D.toStrictEntity(timeout, maxBytes) { inner.get.delegate } - } - /** * WARNING: This will read the entire request entity into memory and effectively disable streaming. * diff --git a/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/TimeoutDirectives.scala b/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/TimeoutDirectives.scala index 3b8abd0010..8adf2075f6 100644 --- a/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/TimeoutDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/TimeoutDirectives.scala @@ -40,20 +40,6 @@ abstract class TimeoutDirectives extends WebSocketDirectives { } } - /** - * Tries to set a new request timeout and handler (if provided) at the same time. - * - * Due to the inherent raciness it is not guaranteed that the update will be applied before - * the previously set timeout has expired! - * @deprecated As of 1.3.0, use the overloaded method taking a `java.time.Duration` instead. - */ - @Deprecated(since = "1.3.0") - @deprecated("use the overloaded method taking a `java.time.Duration` instead.", "1.3.0") - def withRequestTimeout(timeout: scala.concurrent.duration.Duration, inner: Supplier[Route]): RouteAdapter = - RouteAdapter { - D.withRequestTimeout(timeout) { inner.get.delegate } - } - /** * Tries to set a new request timeout and handler (if provided) at the same time. * @@ -66,21 +52,6 @@ abstract class TimeoutDirectives extends WebSocketDirectives { D.withRequestTimeout(timeout.toScala) { inner.get.delegate } } - /** - * Tries to set a new request timeout and handler (if provided) at the same time. - * - * Due to the inherent raciness it is not guaranteed that the update will be applied before - * the previously set timeout has expired! - * @deprecated As of 1.3.0, use the overloaded method taking a `java.time.Duration` instead. - */ - @Deprecated(since = "1.3.0") - @deprecated("use the overloaded method taking a `java.time.Duration` instead.", "1.3.0") - def withRequestTimeout(timeout: scala.concurrent.duration.Duration, - timeoutHandler: JFunction[HttpRequest, HttpResponse], - inner: Supplier[Route]): RouteAdapter = RouteAdapter { - D.withRequestTimeout(timeout, in => timeoutHandler(in.asJava).asScala) { inner.get.delegate } - } - /** * Tries to set a new request timeout and handler (if provided) at the same time. * diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Coders.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Coders.scala index d9c29765cf..274cae8c9f 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Coders.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Coders.scala @@ -13,8 +13,6 @@ package org.apache.pekko.http.scaladsl.coding -import scala.annotation.nowarn - import org.apache.pekko import pekko.http.impl.model.parser.CharacterClasses import pekko.http.scaladsl.model.{ HttpHeader, HttpMessage } @@ -22,7 +20,6 @@ import pekko.http.scaladsl.model.headers.{ `Content-Encoding`, HttpEncoding } import pekko.stream.scaladsl.Flow import pekko.util.ByteString -@nowarn("msg=in package coding is deprecated") object Coders { def Gzip: Coder = pekko.http.scaladsl.coding.Gzip def Gzip( diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Decoder.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Decoder.scala index 9c55c37e95..472883ba18 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Decoder.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Decoder.scala @@ -95,8 +95,7 @@ private[coding] trait BuiltInResponseDecoder extends Decoder { * A decoder that is implemented in terms of a `Stage` */ @InternalApi -@deprecated("StreamDecoder is internal API and will be moved or removed in the future", since = "Akka HTTP 10.2.0") -trait StreamDecoder extends Decoder { outer => +private[coding] trait StreamDecoder extends Decoder { outer => protected def newDecompressorStage(maxBytesPerChunk: Int): () => GraphStage[FlowShape[ByteString, ByteString]] def maxBytesPerChunk: Int = Decoder.MaxBytesPerChunkDefault diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Deflate.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Deflate.scala index 4c0afc4a29..a85da64fa8 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Deflate.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Deflate.scala @@ -18,9 +18,9 @@ import pekko.annotation.InternalApi import pekko.http.scaladsl.model._ import pekko.http.scaladsl.model.headers.HttpEncodings -@InternalApi // used by javadsl.coding.Coder -@deprecated("Actual implementation of Deflate is internal API, use Coders.Deflate instead", since = "Akka HTTP 10.2.0") -class Deflate private[http] (compressionLevel: Int, val messageFilter: HttpMessage => Boolean) extends Coder +@InternalApi +private[coding] class Deflate private[http] (compressionLevel: Int, val messageFilter: HttpMessage => Boolean) + extends Coder with StreamDecoder with BuiltInResponseDecoder { def this(messageFilter: HttpMessage => Boolean) = { this(DeflateCompressor.DefaultCompressionLevel, messageFilter) @@ -30,9 +30,8 @@ class Deflate private[http] (compressionLevel: Int, val messageFilter: HttpMessa private[http] def newCompressor: DeflateCompressor = new DeflateCompressor(compressionLevel) def newDecompressorStage(maxBytesPerChunk: Int) = () => new DeflateDecompressor(maxBytesPerChunk) - @InternalApi // used by javadsl.coding.Coder + @InternalApi private[http] def withLevel(level: Int): Deflate = new Deflate(level, messageFilter) } -@InternalApi // used by javadsl.coding.Coder -@deprecated("Actual implementation of Deflate is internal API, use Coders.Deflate instead", since = "Akka HTTP 10.2.0") -object Deflate extends Deflate(Encoder.DefaultFilter) +@InternalApi +private[coding] object Deflate extends Deflate(Encoder.DefaultFilter) diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Encoder.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Encoder.scala index f5b0470466..d3fb2b1d36 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Encoder.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Encoder.scala @@ -87,8 +87,7 @@ object Encoder { /** A stateful object representing ongoing compression. */ @InternalApi -@deprecated("Compressor is internal API and will be moved or removed in the future.", since = "Akka HTTP 10.2.0") -abstract class Compressor { +private[coding] abstract class Compressor { /** * Compresses the given input and returns compressed data. The implementation diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/FlowCoder.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/FlowCoder.scala index 2a969934de..98449a5685 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/FlowCoder.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/FlowCoder.scala @@ -17,7 +17,6 @@ package org.apache.pekko.http.scaladsl.coding -import scala.annotation.nowarn import scala.concurrent.Future import org.apache.pekko @@ -76,7 +75,6 @@ private[http] final class FlowCoder( new FlowCoder(encoding, messageFilter, encodingFlow, decodeWithChunkSize, size) // All encoding entry points above delegate to the supplied graph, not the legacy synchronous compressor. - @nowarn("msg=deprecated") private[http] override def newCompressor: Compressor = throw new UnsupportedOperationException("Flow-based coders do not provide a legacy compressor") } diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Gzip.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Gzip.scala index 79b0672ca4..860e8e8036 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Gzip.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Gzip.scala @@ -18,9 +18,9 @@ import pekko.annotation.InternalApi import pekko.http.scaladsl.model._ import pekko.http.scaladsl.model.headers.HttpEncodings -@InternalApi // used by javadsl.coding.Coder -@deprecated("Actual implementation of Gzip is internal, use Coders.Gzip instead", since = "Akka HTTP 10.2.0") -class Gzip private[http] (compressionLevel: Int, val messageFilter: HttpMessage => Boolean) extends Coder +@InternalApi +private[coding] class Gzip private[http] (compressionLevel: Int, val messageFilter: HttpMessage => Boolean) + extends Coder with StreamDecoder with BuiltInResponseDecoder { def this(messageFilter: HttpMessage => Boolean) = { this(GzipCompressor.DefaultCompressionLevel, messageFilter) @@ -30,15 +30,14 @@ class Gzip private[http] (compressionLevel: Int, val messageFilter: HttpMessage private[http] def newCompressor: GzipCompressor = new GzipCompressor(compressionLevel) def newDecompressorStage(maxBytesPerChunk: Int) = () => new GzipDecompressor(maxBytesPerChunk) - @InternalApi // used by javadsl.coding.Coder + @InternalApi private[http] def withLevel(level: Int): Gzip = new Gzip(level, messageFilter) } /** * An encoder and decoder for the HTTP 'gzip' encoding. */ -@InternalApi // used by javadsl.coding.Coder -@deprecated("Actual implementation of Gzip is internal API, use Coders.Gzip instead", since = "Akka HTTP 10.2.0") -object Gzip extends Gzip(Encoder.DefaultFilter) { +@InternalApi +private[coding] object Gzip extends Gzip(Encoder.DefaultFilter) { def apply(messageFilter: HttpMessage => Boolean) = new Gzip(messageFilter) } diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/NoCoding.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/NoCoding.scala index c816b1d601..f08acd0e6a 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/NoCoding.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/NoCoding.scala @@ -25,10 +25,8 @@ import pekko.util.ByteString /** * An encoder and decoder for the HTTP 'identity' encoding. */ -@InternalApi // used by javadsl.coding.Coder -@deprecated("Actual implementation of NoCoding is internal API, use Coders.NoCoding instead", - since = "Akka HTTP 10.2.0") -object NoCoding extends Coder with StreamDecoder with BuiltInResponseDecoder { +@InternalApi +private[coding] object NoCoding extends Coder with StreamDecoder with BuiltInResponseDecoder { val encoding = HttpEncodings.identity override def encodeData[T](t: T)(implicit mapper: DataMapper[T]): T = t diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Zstd.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Zstd.scala index 210eb26ebe..d897d5589b 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Zstd.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Zstd.scala @@ -17,8 +17,6 @@ package org.apache.pekko.http.scaladsl.coding -import scala.annotation.nowarn - import org.apache.pekko import pekko.NotUsed import pekko.annotation.InternalApi @@ -58,7 +56,6 @@ private[http] final class Zstd private[http] ( val encoding: HttpEncoding = HttpEncodings.zstd - @nowarn("msg=deprecated") private[http] def newCompressor: Compressor = new ZstdCompressor(compressionLevel, Zstd.windowLogFor(compressionLevel)) @@ -98,7 +95,6 @@ private[http] object Zstd { * only released by `cleanup`, and an encoder flow that is never materialized is never cleaned up. */ @InternalApi -@nowarn("msg=deprecated") private[coding] class ZstdCompressor(compressionLevel: Int, windowLog: Int) extends Compressor { private var underlyingCreated = false private lazy val underlying = {