From 6c7d2f332c51fd1c59cac9fa9b6637baf195ca23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=99=8E=E9=B8=A3?= Date: Sun, 5 Jul 2026 04:30:30 +0800 Subject: [PATCH] refactor: remove deprecated DurableStateUpdateStore.deleteObject(persistenceId) (since Akka 2.6.20) Motivation: The single-argument deleteObject(persistenceId) was deprecated since Akka 2.6.20 in favor of the overload that takes a revision parameter for optimistic locking. Modification: Remove the deprecated abstract method from both scaladsl and javadsl DurableStateUpdateStore traits. Remove the corresponding TCK test. Result: Only the revision-aware deleteObject(persistenceId, revision) remains. Implementation projects (r2dbc, jdbc, cassandra, dynamodb) will need to remove their overrides of the deleted method. Tests: Not run - trait method removal with TCK test cleanup References: None - deprecated API cleanup --- .../persistence/state/MyJavaStateStore.java | 7 ------ .../docs/persistence/state/MyStateStore.scala | 5 ----- .../pekko/persistence/CapabilityFlags.scala | 6 ----- .../state/JavaDurableStateStoreSpec.scala | 2 -- .../state/DurableStateStoreSpec.scala | 15 ------------- .../PersistenceTestKitDurableStateStore.scala | 4 +--- .../PersistenceTestKitDurableStateStore.scala | 2 -- ...urableStateBehaviorStashOverflowSpec.scala | 2 -- .../remove-deprecated-deleteObject.excludes | 22 +++++++++++++++++++ .../remove-deprecated-deleteObject.excludes | 22 +++++++++++++++++++ .../javadsl/DurableStateUpdateStore.scala | 10 --------- .../scaladsl/DurableStateUpdateStore.scala | 10 --------- 12 files changed, 45 insertions(+), 62 deletions(-) create mode 100644 persistence/src/main/mima-filters/1.1.x.backwards.excludes/remove-deprecated-deleteObject.excludes create mode 100644 persistence/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-deleteObject.excludes diff --git a/docs/src/main/java/docs/persistence/state/MyJavaStateStore.java b/docs/src/main/java/docs/persistence/state/MyJavaStateStore.java index 399cb9eeab6..d54f8633202 100644 --- a/docs/src/main/java/docs/persistence/state/MyJavaStateStore.java +++ b/docs/src/main/java/docs/persistence/state/MyJavaStateStore.java @@ -58,13 +58,6 @@ public CompletionStage upsertObject( return null; } - /** Deprecated. Use the deleteObject overload with revision instead. */ - @SuppressWarnings("deprecation") - @Override - public CompletionStage deleteObject(String persistenceId) { - return deleteObject(persistenceId, 0); - } - /** * Will delete the state by setting it to the empty state and the revision number will be * incremented by 1. diff --git a/docs/src/main/scala/docs/persistence/state/MyStateStore.scala b/docs/src/main/scala/docs/persistence/state/MyStateStore.scala index 30b378f7324..54dea6858ae 100644 --- a/docs/src/main/scala/docs/persistence/state/MyStateStore.scala +++ b/docs/src/main/scala/docs/persistence/state/MyStateStore.scala @@ -53,11 +53,6 @@ class MyStateStore[A](system: ExtendedActorSystem, config: Config, cfgPath: Stri */ override def upsertObject(persistenceId: String, revision: Long, value: A, tag: String): Future[Done] = ??? - /** - * Deprecated. Use the deleteObject overload with revision instead. - */ - override def deleteObject(persistenceId: String): Future[Done] = deleteObject(persistenceId, 0) - /** * Will delete the state by setting it to the empty state and the revision number will be incremented by 1. */ diff --git a/persistence-tck/src/main/scala/org/apache/pekko/persistence/CapabilityFlags.scala b/persistence-tck/src/main/scala/org/apache/pekko/persistence/CapabilityFlags.scala index a09441740f4..7eecc2969c9 100644 --- a/persistence-tck/src/main/scala/org/apache/pekko/persistence/CapabilityFlags.scala +++ b/persistence-tck/src/main/scala/org/apache/pekko/persistence/CapabilityFlags.scala @@ -118,11 +118,5 @@ trait DurableStateStoreCapabilityFlags extends CapabilityFlags { * and deserializes values via the configured Pekko serializer infrastructure. */ protected def supportsSerialization: CapabilityFlag - - /** - * When `true` enables tests which check the deprecated single-argument `deleteObject(persistenceId)` - * overload, which deletes regardless of the current revision. - */ - protected def supportsSoftDelete: CapabilityFlag } //#durable-state-store-flags diff --git a/persistence-tck/src/main/scala/org/apache/pekko/persistence/japi/state/JavaDurableStateStoreSpec.scala b/persistence-tck/src/main/scala/org/apache/pekko/persistence/japi/state/JavaDurableStateStoreSpec.scala index 42801a31c64..44cb46c8ddb 100644 --- a/persistence-tck/src/main/scala/org/apache/pekko/persistence/japi/state/JavaDurableStateStoreSpec.scala +++ b/persistence-tck/src/main/scala/org/apache/pekko/persistence/japi/state/JavaDurableStateStoreSpec.scala @@ -40,8 +40,6 @@ class JavaDurableStateStoreSpec(config: Config) extends DurableStateStoreSpec(co override protected def supportsUpsertWithRevisionCheck: CapabilityFlag = CapabilityFlag.off() - override protected def supportsSoftDelete: CapabilityFlag = CapabilityFlag.off() - override def runTests(testName: Option[String], args: Args): Status = super.runTests(testName, args) diff --git a/persistence-tck/src/main/scala/org/apache/pekko/persistence/state/DurableStateStoreSpec.scala b/persistence-tck/src/main/scala/org/apache/pekko/persistence/state/DurableStateStoreSpec.scala index 8ebbaf0fef8..4e61da90387 100644 --- a/persistence-tck/src/main/scala/org/apache/pekko/persistence/state/DurableStateStoreSpec.scala +++ b/persistence-tck/src/main/scala/org/apache/pekko/persistence/state/DurableStateStoreSpec.scala @@ -67,8 +67,6 @@ abstract class DurableStateStoreSpec(config: Config) override protected def supportsSerialization: CapabilityFlag = CapabilityFlag.on() - override protected def supportsSoftDelete: CapabilityFlag = CapabilityFlag.off() - override protected def beforeEach(): Unit = { super.beforeEach() preparePersistenceId(pid) @@ -199,18 +197,5 @@ abstract class DurableStateStoreSpec(config: Config) result.revision shouldBe 1L } } - - optional(flag = supportsSoftDelete) { - "delete a state via the deprecated deleteObject overload" in { - val store = durableStateStore() - val value = s"state-${pid}" - Await.result(store.upsertObject(pid, 1L, value, "test-tag"), timeout) - @nowarn("cat=deprecation") - val deleteResult = store.deleteObject(pid) - Await.result(deleteResult, timeout) - val result = Await.result(store.getObject(pid), timeout) - result.value shouldBe None - } - } } } diff --git a/persistence-testkit/src/main/scala/org/apache/pekko/persistence/testkit/state/javadsl/PersistenceTestKitDurableStateStore.scala b/persistence-testkit/src/main/scala/org/apache/pekko/persistence/testkit/state/javadsl/PersistenceTestKitDurableStateStore.scala index 51513600b9d..31426b627a1 100644 --- a/persistence-testkit/src/main/scala/org/apache/pekko/persistence/testkit/state/javadsl/PersistenceTestKitDurableStateStore.scala +++ b/persistence-testkit/src/main/scala/org/apache/pekko/persistence/testkit/state/javadsl/PersistenceTestKitDurableStateStore.scala @@ -14,7 +14,7 @@ package org.apache.pekko.persistence.testkit.state.javadsl import java.util.Optional -import java.util.concurrent.{ CompletableFuture, CompletionStage } +import java.util.concurrent.CompletionStage import scala.jdk.FutureConverters._ import scala.jdk.OptionConverters._ @@ -47,8 +47,6 @@ class PersistenceTestKitDurableStateStore[A](stateStore: SStore[A]) def upsertObject(persistenceId: String, seqNr: Long, value: A, tag: String): CompletionStage[Done] = stateStore.upsertObject(persistenceId, seqNr, value, tag).asJava - def deleteObject(persistenceId: String): CompletionStage[Done] = CompletableFuture.completedFuture(Done) - def deleteObject(persistenceId: String, revision: Long): CompletionStage[Done] = stateStore.deleteObject(persistenceId, revision).asJava diff --git a/persistence-testkit/src/main/scala/org/apache/pekko/persistence/testkit/state/scaladsl/PersistenceTestKitDurableStateStore.scala b/persistence-testkit/src/main/scala/org/apache/pekko/persistence/testkit/state/scaladsl/PersistenceTestKitDurableStateStore.scala index 414a9f19628..6e9e818d306 100644 --- a/persistence-testkit/src/main/scala/org/apache/pekko/persistence/testkit/state/scaladsl/PersistenceTestKitDurableStateStore.scala +++ b/persistence-testkit/src/main/scala/org/apache/pekko/persistence/testkit/state/scaladsl/PersistenceTestKitDurableStateStore.scala @@ -80,8 +80,6 @@ class PersistenceTestKitDurableStateStore[A](val system: ExtendedActorSystem) Future.successful(Done) } - override def deleteObject(persistenceId: String): Future[Done] = Future.successful(Done) - override def deleteObject(persistenceId: String, revision: Long): Future[Done] = this.synchronized { store.get(persistenceId) match { case Some(record) => diff --git a/persistence-typed-tests/src/test/scala/org/apache/pekko/persistence/typed/state/scaladsl/DurableStateBehaviorStashOverflowSpec.scala b/persistence-typed-tests/src/test/scala/org/apache/pekko/persistence/typed/state/scaladsl/DurableStateBehaviorStashOverflowSpec.scala index 64866b40c85..023b9b2fe4f 100644 --- a/persistence-typed-tests/src/test/scala/org/apache/pekko/persistence/typed/state/scaladsl/DurableStateBehaviorStashOverflowSpec.scala +++ b/persistence-typed-tests/src/test/scala/org/apache/pekko/persistence/typed/state/scaladsl/DurableStateBehaviorStashOverflowSpec.scala @@ -60,8 +60,6 @@ object DurableStateBehaviorStashOverflowSpec { def completeUpsertFuture(): Unit = promise.success(Done) - override def deleteObject(persistenceId: String): Future[Done] = Future.successful(Done) - override def deleteObject(persistenceId: String, revision: Long): Future[Done] = Future.successful(Done) } diff --git a/persistence/src/main/mima-filters/1.1.x.backwards.excludes/remove-deprecated-deleteObject.excludes b/persistence/src/main/mima-filters/1.1.x.backwards.excludes/remove-deprecated-deleteObject.excludes new file mode 100644 index 00000000000..1f67cc654aa --- /dev/null +++ b/persistence/src/main/mima-filters/1.1.x.backwards.excludes/remove-deprecated-deleteObject.excludes @@ -0,0 +1,22 @@ +# 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. + +# Remove deprecated deleteObject(persistenceId) overload (deprecated since Akka 2.6.20) +ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.pekko.persistence.state.javadsl.DurableStateUpdateStore.deleteObject") +ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.pekko.persistence.state.scaladsl.DurableStateUpdateStore.deleteObject") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.persistence.state.javadsl.DurableStateUpdateStore.deleteObject") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.persistence.state.scaladsl.DurableStateUpdateStore.deleteObject") diff --git a/persistence/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-deleteObject.excludes b/persistence/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-deleteObject.excludes new file mode 100644 index 00000000000..1f67cc654aa --- /dev/null +++ b/persistence/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-deleteObject.excludes @@ -0,0 +1,22 @@ +# 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. + +# Remove deprecated deleteObject(persistenceId) overload (deprecated since Akka 2.6.20) +ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.pekko.persistence.state.javadsl.DurableStateUpdateStore.deleteObject") +ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.pekko.persistence.state.scaladsl.DurableStateUpdateStore.deleteObject") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.persistence.state.javadsl.DurableStateUpdateStore.deleteObject") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.persistence.state.scaladsl.DurableStateUpdateStore.deleteObject") diff --git a/persistence/src/main/scala/org/apache/pekko/persistence/state/javadsl/DurableStateUpdateStore.scala b/persistence/src/main/scala/org/apache/pekko/persistence/state/javadsl/DurableStateUpdateStore.scala index 6fc15902c6e..64ea5e81b05 100644 --- a/persistence/src/main/scala/org/apache/pekko/persistence/state/javadsl/DurableStateUpdateStore.scala +++ b/persistence/src/main/scala/org/apache/pekko/persistence/state/javadsl/DurableStateUpdateStore.scala @@ -36,16 +36,6 @@ trait DurableStateUpdateStore[A] extends DurableStateStore[A] { */ def upsertObject(persistenceId: String, revision: Long, value: A, tag: String): CompletionStage[Done] - /** - * Delete the object with the given `persistenceId`. This deprecated - * function ignores whether the object is deleted or not. - * - * @param persistenceId the persistenceId of the object to delete - * @return a CompletionStage that completes when the object has been deleted - */ - @deprecated(message = "Use the deleteObject overload with revision instead.", since = "Akka 2.6.20") - def deleteObject(persistenceId: String): CompletionStage[Done] - /** * Delete the object with the given `persistenceId` and `revision`. * diff --git a/persistence/src/main/scala/org/apache/pekko/persistence/state/scaladsl/DurableStateUpdateStore.scala b/persistence/src/main/scala/org/apache/pekko/persistence/state/scaladsl/DurableStateUpdateStore.scala index c0aa6c95253..b55ba1b2637 100644 --- a/persistence/src/main/scala/org/apache/pekko/persistence/state/scaladsl/DurableStateUpdateStore.scala +++ b/persistence/src/main/scala/org/apache/pekko/persistence/state/scaladsl/DurableStateUpdateStore.scala @@ -36,16 +36,6 @@ trait DurableStateUpdateStore[A] extends DurableStateStore[A] { */ def upsertObject(persistenceId: String, revision: Long, value: A, tag: String): Future[Done] - /** - * Delete the object with the given `persistenceId`. This deprecated - * function ignores whether the object is deleted or not. - * - * @param persistenceId the persistenceId of the object to delete - * @return a Future that completes when the object has been deleted - */ - @deprecated(message = "Use the deleteObject overload with revision instead.", since = "Akka 2.6.20") - def deleteObject(persistenceId: String): Future[Done] - /** * Delete the object with the given `persistenceId` and `revision`. *