From a564472a33e33e23f1785b9690ba6ccfdba67d34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=99=8E=E9=B8=A3?= Date: Sun, 5 Jul 2026 11:28:36 +0800 Subject: [PATCH] refactor: remove deprecated HttpMethod.custom 4-arg overload (since 1.4.0) Motivation: The 4-arg overload of HttpMethod.custom was deprecated since pekko-http 1.4.0 in favor of the 5-arg overload that includes contentLengthAllowed parameter. Modification: Removed deprecated HttpMethod.custom(name, safe, idempotent, requestEntityAcceptance) from both Scala and Java APIs. Also removed the private helper oldContentLengthCondition that was only used by the deprecated method. Added MiMa filters for binary compatibility exceptions. Result: Deprecated API removed. Users should use the 5-arg custom overload. --- .../pekko/http/javadsl/model/HttpMethods.java | 21 ------------------- .../remove-deprecated-methods.excludes | 4 ++++ .../http/scaladsl/model/HttpMethod.scala | 15 ------------- 3 files changed, 4 insertions(+), 36 deletions(-) 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/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes b/http-core/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes index 23ad02cc72..c5a62a5422 100644 --- a/http-core/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes +++ b/http-core/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes @@ -125,3 +125,7 @@ ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scalad ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.settings.ServerSettings.websocketRandomFactory") ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.settings.ServerSettings.getWebsocketRandomFactory") ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.settings.ServerSettings.withWebsocketRandomFactory") + +# Remove deprecated HttpMethod.custom 4-arg (since 1.4.0) +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.model.HttpMethod.custom") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.model.HttpMethods.custom") 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 d407986241..85655e3ddd 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 @@ -55,21 +55,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 = { - require(name.nonEmpty, "value must be non-empty") - require(!safe || idempotent, "An HTTP method cannot be safe without being idempotent") - apply(name, safe, idempotent, requestEntityAcceptance, oldContentLengthCondition) - } - /** * Create a custom method type. */