This is an automated email from the ASF dual-hosted git repository.
He-Pin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-http.git
The following commit(s) were added to refs/heads/main by this push:
new fad767889 Remove deprecated ParserSettings.apply/create (since Akka
HTTP 10.2.0) (#1126)
fad767889 is described below
commit fad7678899cf1ed36cc4921ecf0d421a69f980ae
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Sun Jul 5 17:00:05 2026 +0800
Remove deprecated ParserSettings.apply/create (since Akka HTTP 10.2.0)
(#1126)
* refactor: remove deprecated ParserSettings.apply/create (since Akka HTTP
10.2.0)
* fix: remove SettingsCompanion from ParserSettings companion objects
SettingsCompanion requires apply/create(config: Config) and
apply/create(configOverrides: String) which were removed as deprecated.
Replace with direct apply/create methods delegating to forServer.
* fix: update SettingsEqualitySpec to use ParserSettings.forServer
Motivation:
ParserSettings no longer extends SettingsCompanion, so the
apply(config: Config) method is no longer available.
Modification:
Replace ParserSettings(config) with ParserSettings.forServer,
which uses the implicit ActorSystem. Remove unused @nowarn
annotation and import.
Result:
Test compiles and runs correctly with the updated ParserSettings API.
* fix: update tests and MiMa filters for ParserSettings SettingsCompanion
removal
Motivation:
ParserSettings no longer extends SettingsCompanion, so
ParserSettings(system) now creates server-specific settings (via forServer).
Two tests relied on the old generic behavior. MiMa also reports
IncompatibleMethTypeProblem, IncompatibleResultTypeProblem, and
MissingTypesProblem from the SettingsCompanion removal.
Modification:
- ServerSettingsSpec: use ParserSettings.forClient to get client-specific
settings that correctly fail when used with ServerSettings
- ClientConnectionSettingsSpec: use ParserSettings.forServer explicitly
- Add MiMa filters for ParserSettings$ type changes
Result:
Tests pass with the updated ParserSettings API and MiMa checks succeed.
* fix: remove tests for generic ParserSettings that no longer exists
Motivation:
With SettingsCompanion removed from ParserSettings, there is no
longer a way to create 'generic' (non-scoped) parser settings.
The tests that verified early failure when using generic settings
with scoped settings objects are no longer applicable.
Modification:
Remove the 'fail early' tests from ClientConnectionSettingsSpec
and ServerSettingsSpec. Both forServer and forClient produce
complete settings with max-content-length defined.
Result:
Remaining tests pass without the inapplicable scenario.
* style: apply scalafmt to ClientConnectionSettingsSpec
---
.../remove-deprecated-methods.excludes | 10 ++++++++++
.../http/javadsl/settings/ParserSettings.scala | 23 ++--------------------
.../http/scaladsl/settings/ParserSettings.scala | 11 +++++------
.../http/javadsl/settings/ParserSettingsTest.java | 2 +-
.../settings/ClientConnectionSettingsSpec.scala | 20 +------------------
.../scaladsl/settings/ServerSettingsSpec.scala | 15 --------------
.../scaladsl/settings/SettingsEqualitySpec.scala | 9 +++++----
7 files changed, 24 insertions(+), 66 deletions(-)
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 ea3a74ede..a9beb95c1 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
@@ -126,6 +126,16 @@
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scalad
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.settings.ServerSettings.getWebsocketRandomFactory")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.settings.ServerSettings.withWebsocketRandomFactory")
+# Remove deprecated ParserSettings.apply/create (since Akka HTTP 10.2.0)
+ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.settings.ParserSettings.apply")
+ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.settings.ParserSettings.default")
+ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.settings.ParserSettings.create")
+ProblemFilters.exclude[MissingTypesProblem]("org.apache.pekko.http.scaladsl.settings.ParserSettings$")
+ProblemFilters.exclude[MissingTypesProblem]("org.apache.pekko.http.javadsl.settings.ParserSettings$")
+ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.pekko.http.scaladsl.settings.ParserSettings.apply")
+ProblemFilters.exclude[IncompatibleMethTypeProblem]("org.apache.pekko.http.scaladsl.settings.ParserSettings.apply")
+ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.pekko.http.scaladsl.settings.ParserSettings.default")
+ProblemFilters.exclude[IncompatibleMethTypeProblem]("org.apache.pekko.http.scaladsl.settings.ParserSettings.default")
# Remove deprecated ConnectionContext.defaultPort (since Akka HTTP 10.2.0)
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.ConnectionContext.defaultPort")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.HttpsConnectionContext.defaultPort")
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ParserSettings.scala
b/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ParserSettings.scala
index 4b889816e..c726c6597 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ParserSettings.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ParserSettings.scala
@@ -111,33 +111,14 @@ abstract class ParserSettings private[pekko] () extends
BodyPartParser.Settings
}
-object ParserSettings extends SettingsCompanion[ParserSettings] {
+object ParserSettings {
trait CookieParsingMode
trait ErrorLoggingVerbosity
trait IllegalResponseHeaderNameProcessingMode
trait IllegalResponseHeaderValueProcessingMode
trait ConflictingContentTypeHeaderProcessingMode
- /**
- * @deprecated Use forServer or forClient instead.
- */
- @Deprecated(since = "Akka HTTP 10.2.0")
- @deprecated("Use forServer or forClient instead", since = "Akka HTTP 10.2.0")
- override def create(config: Config): ParserSettings =
ParserSettingsImpl(config)
-
- /**
- * @deprecated Use forServer or forClient instead.
- */
- @Deprecated(since = "Akka HTTP 10.2.0")
- @deprecated("Use forServer or forClient instead", since = "Akka HTTP 10.2.0")
- override def create(configOverrides: String): ParserSettings =
ParserSettingsImpl(configOverrides)
-
- /**
- * @deprecated Use forServer or forClient instead.
- */
- @Deprecated(since = "Akka HTTP 10.2.0")
- @deprecated("Use forServer or forClient instead", since = "Akka HTTP 10.2.0")
- override def create(system: ActorSystem): ParserSettings =
create(system.settings.config)
+ def create(system: ActorSystem): ParserSettings = forServer(system)
def forServer(system: ClassicActorSystemProvider): ParserSettings =
pekko.http.scaladsl.settings.ParserSettings.forServer(system)
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ParserSettings.scala
b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ParserSettings.scala
index 04a658f8c..5f89fa48d 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ParserSettings.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ParserSettings.scala
@@ -19,7 +19,7 @@ import java.util.function.Function
import com.typesafe.config.Config
import org.apache.pekko
-import pekko.actor.ClassicActorSystemProvider
+import pekko.actor.{ ActorSystem, ClassicActorSystemProvider }
import pekko.annotation.DoNotInherit
import pekko.http.impl.settings.ParserSettingsImpl
import pekko.http.impl.util._
@@ -157,7 +157,7 @@ abstract class ParserSettings private[pekko] () extends
pekko.http.javadsl.setti
self.copy(conflictingContentTypeHeaderProcessingMode = newValue)
}
-object ParserSettings extends SettingsCompanion[ParserSettings] {
+object ParserSettings {
sealed trait CookieParsingMode extends
pekko.http.javadsl.settings.ParserSettings.CookieParsingMode
object CookieParsingMode {
case object RFC6265 extends CookieParsingMode
@@ -237,10 +237,9 @@ object ParserSettings extends
SettingsCompanion[ParserSettings] {
}
}
- @deprecated("Use forServer or forClient instead", "Akka HTTP 10.2.0")
- override def apply(config: Config): ParserSettings =
ParserSettingsImpl(config)
- @deprecated("Use forServer or forClient instead", "Akka HTTP 10.2.0")
- override def apply(configOverrides: String): ParserSettings =
ParserSettingsImpl(configOverrides)
+ def apply(system: ActorSystem): ParserSettings = forServer(system)
+ def apply(system: ClassicActorSystemProvider): ParserSettings =
forServer(system)
+ implicit def default(implicit system: ClassicActorSystemProvider):
ParserSettings = forServer(system)
def forServer(implicit system: ClassicActorSystemProvider): ParserSettings =
ParserSettingsImpl.forServer(system.classicSystem.settings.config)
diff --git
a/http-core/src/test/java/org/apache/pekko/http/javadsl/settings/ParserSettingsTest.java
b/http-core/src/test/java/org/apache/pekko/http/javadsl/settings/ParserSettingsTest.java
index 8fb2b5b29..4926e67f9 100644
---
a/http-core/src/test/java/org/apache/pekko/http/javadsl/settings/ParserSettingsTest.java
+++
b/http-core/src/test/java/org/apache/pekko/http/javadsl/settings/ParserSettingsTest.java
@@ -22,6 +22,6 @@ public class ParserSettingsTest {
@Test
public void testCreateWithActorSystem() {
ActorSystem sys = ActorSystem.create("test");
- ParserSettings settings = ParserSettings.create(sys);
+ ParserSettings settings = ParserSettings.forServer(sys);
}
}
diff --git
a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/ClientConnectionSettingsSpec.scala
b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/ClientConnectionSettingsSpec.scala
index 64965d231..a6eda2193 100644
---
a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/ClientConnectionSettingsSpec.scala
+++
b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/ClientConnectionSettingsSpec.scala
@@ -15,22 +15,4 @@ package org.apache.pekko.http.scaladsl.settings
import org.apache.pekko.testkit.PekkoSpec
-class ClientConnectionSettingsSpec extends PekkoSpec {
- "ClientConnectionSettings" should {
- "fail early when creating ClientConnectionSettings with incomplete
ParserSettings" in {
- // This creates 'generic' parserSettings, without client-specific (or
server-specific) values.
- val parserSettings = ParserSettings(system)
-
- // This includes ParserSettings, complete with client-specific settings
- val clientConnectionSettings = ClientConnectionSettings(system)
-
- // This would create 'defective' clientConnectionSettings, since these
- // parserSettings don't contain the client or server-specific values.
Notably,
- // max-content-length would not be set (and throw an exception on
access).
- val e = intercept[IllegalArgumentException] {
- clientConnectionSettings.withParserSettings(parserSettings)
- }
- e.getMessage should include("does not contain the client-specific
settings")
- }
- }
-}
+class ClientConnectionSettingsSpec extends PekkoSpec {}
diff --git
a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/ServerSettingsSpec.scala
b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/ServerSettingsSpec.scala
index 5ccd63ccc..f09bd9e92 100644
---
a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/ServerSettingsSpec.scala
+++
b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/ServerSettingsSpec.scala
@@ -18,21 +18,6 @@ import org.apache.pekko.testkit.PekkoSpec
class ServerSettingsSpec extends PekkoSpec {
"ServerSettings" should {
- "fail early when creating ServerSettings with incomplete ParserSettings"
in {
- // This creates 'generic' parserSettings, without server-specific (or
client-specific) values.
- val parserSettings = ParserSettings(system)
-
- // This includes ParserSettings, complete with server-specific settings
- val serverSettings = ServerSettings(system)
-
- // This would create 'defective' serverSettings, since these
- // parserSettings don't contain the server or client-specific values.
Notably,
- // max-content-length would not be set (and throw an exception on
access).
- val e = intercept[IllegalArgumentException] {
- serverSettings.withParserSettings(parserSettings)
- }
- e.getMessage should include("does not contain the server-specific
settings")
- }
"default enableHttp2 to true" in {
val serverSettings = ServerSettings(system)
serverSettings.enableHttp2 should ===(true)
diff --git
a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/SettingsEqualitySpec.scala
b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/SettingsEqualitySpec.scala
index b8910e077..b9dece997 100644
---
a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/SettingsEqualitySpec.scala
+++
b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/SettingsEqualitySpec.scala
@@ -13,14 +13,15 @@
package org.apache.pekko.http.scaladsl.settings
-import scala.annotation.nowarn
import com.typesafe.config.ConfigFactory
+import org.apache.pekko.actor.ActorSystem
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
class SettingsEqualitySpec extends AnyWordSpec with Matchers {
val config = ConfigFactory.load.resolve
+ implicit val system: ActorSystem = ActorSystem("test", config)
"equality" should {
"hold for ConnectionPoolSettings" in {
@@ -32,12 +33,12 @@ class SettingsEqualitySpec extends AnyWordSpec with
Matchers {
}
"hold for ParserSettings.forServer" in {
- val s1 = ParserSettings(config)
- val s2 = ParserSettings(config)
+ val s1 = ParserSettings.forServer
+ val s2 = ParserSettings.forServer
s1 shouldBe s2
s1.toString should startWith("ParserSettings(")
- }: @nowarn("msg=apply in object ParserSettings is deprecated")
+ }
"hold for ClientConnectionSettings" in {
val s1 = ClientConnectionSettings(config)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]