This is an automated email from the ASF dual-hosted git repository.

pjfanning pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko.git


The following commit(s) were added to refs/heads/main by this push:
     new 27f6960dda ClusterShardingSettings: remove backward-compat passivation 
cruft (#3026)
27f6960dda is described below

commit 27f6960ddaf50976a3ec2998c776c838d6a73b3b
Author: PJ Fanning <[email protected]>
AuthorDate: Mon Jun 1 17:30:18 2026 +0100

    ClusterShardingSettings: remove backward-compat passivation cruft (#3026)
    
    * fix(sharding): convert ShardRegionStats/CurrentShardRegionState to case 
classes, remove @ApiMayChange and deprecated passivation warning for 2.0.0
    
    * Apply remaining changes
    
    * Revise license header in ShardRegionDataTypesSpec.scala
    
    Updated license information in ShardRegionDataTypesSpec.scala
    
    * Create remove-old-passivation-strategy.excludes
    
    * mima
    
    * Revert ShardRegionStats/CurrentShardRegionState to hand-written Product 
classes; fix config references
    
    ---------
    
    Co-authored-by: copilot-swe-agent[bot] 
<[email protected]>
---
 .../remove-old-passivation-strategy.excludes       |  20 ++++
 .../sharding/typed/ClusterShardingSettings.scala   |  65 ++----------
 .../typed/delivery/DeliveryThroughputSpec.scala    |   2 +-
 .../remove-old-passivation-strategy.excludes       |  21 ++++
 cluster-sharding/src/main/resources/reference.conf |   6 --
 .../cluster/sharding/ClusterShardingSettings.scala |  80 ++------------
 .../pekko/cluster/sharding/ShardRegion.scala       |  10 --
 .../sharding/ClusterShardingSettingsSpec.scala     |  11 --
 .../sharding/ShardRegionDataTypesSpec.scala        | 116 +++++++++++++++++++++
 9 files changed, 176 insertions(+), 155 deletions(-)

diff --git 
a/cluster-sharding-typed/src/main/mima-filters/2.0.x.backwards.excludes/remove-old-passivation-strategy.excludes
 
b/cluster-sharding-typed/src/main/mima-filters/2.0.x.backwards.excludes/remove-old-passivation-strategy.excludes
new file mode 100644
index 0000000000..c8d912c1ed
--- /dev/null
+++ 
b/cluster-sharding-typed/src/main/mima-filters/2.0.x.backwards.excludes/remove-old-passivation-strategy.excludes
@@ -0,0 +1,20 @@
+# 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 old passivation strategy
+ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.cluster.sharding.typed.ClusterShardingSettings#PassivationStrategySettings.oldDefault")
+ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.cluster.sharding.typed.ClusterShardingSettings#PassivationStrategySettings.oldSettingUsed")
diff --git 
a/cluster-sharding-typed/src/main/scala/org/apache/pekko/cluster/sharding/typed/ClusterShardingSettings.scala
 
b/cluster-sharding-typed/src/main/scala/org/apache/pekko/cluster/sharding/typed/ClusterShardingSettings.scala
index 6a8fa9abde..5bf6ee1ac3 100644
--- 
a/cluster-sharding-typed/src/main/scala/org/apache/pekko/cluster/sharding/typed/ClusterShardingSettings.scala
+++ 
b/cluster-sharding-typed/src/main/scala/org/apache/pekko/cluster/sharding/typed/ClusterShardingSettings.scala
@@ -19,7 +19,7 @@ import scala.jdk.DurationConverters._
 
 import org.apache.pekko
 import pekko.actor.typed.ActorSystem
-import pekko.annotation.{ ApiMayChange, InternalApi }
+import pekko.annotation.InternalApi
 import pekko.cluster.ClusterSettings.DataCenter
 import pekko.cluster.sharding.{ ClusterShardingSettings => 
ClassicShardingSettings }
 import pekko.cluster.singleton.{ ClusterSingletonManagerSettings => 
ClassicClusterSingletonManagerSettings }
@@ -174,46 +174,22 @@ object ClusterShardingSettings {
   }
   case object RememberEntitiesStoreModeDData extends RememberEntitiesStoreMode 
{ override def name = "ddata" }
 
-  /**
-   * API MAY CHANGE: Settings for passivation strategies may change after 
additional testing and feedback.
-   */
-  @ApiMayChange
   final class PassivationStrategySettings private (
       val idleEntitySettings: Option[PassivationStrategySettings.IdleSettings],
       val activeEntityLimit: Option[Int],
       val replacementPolicySettings: 
Option[PassivationStrategySettings.PolicySettings],
-      val admissionSettings: 
Option[PassivationStrategySettings.AdmissionSettings],
-      private[pekko] val oldSettingUsed: Boolean) {
-
-    private[pekko] def this(
-        idleEntitySettings: Option[PassivationStrategySettings.IdleSettings],
-        activeEntityLimit: Option[Int],
-        replacementPolicySettings: 
Option[PassivationStrategySettings.PolicySettings],
-        oldSettingUsed: Boolean) =
-      this(idleEntitySettings, activeEntityLimit, replacementPolicySettings, 
admissionSettings = None, oldSettingUsed)
-
-    def this(
-        idleEntitySettings: Option[PassivationStrategySettings.IdleSettings],
-        activeEntityLimit: Option[Int],
-        replacementPolicySettings: 
Option[PassivationStrategySettings.PolicySettings],
-        admissionSettings: 
Option[PassivationStrategySettings.AdmissionSettings]) =
-      this(idleEntitySettings, activeEntityLimit, replacementPolicySettings, 
admissionSettings, oldSettingUsed = false)
+      val admissionSettings: 
Option[PassivationStrategySettings.AdmissionSettings]) {
 
     def this(
         idleEntitySettings: Option[PassivationStrategySettings.IdleSettings],
         activeEntityLimit: Option[Int],
         replacementPolicySettings: 
Option[PassivationStrategySettings.PolicySettings]) =
-      this(
-        idleEntitySettings,
-        activeEntityLimit,
-        replacementPolicySettings,
-        admissionSettings = None,
-        oldSettingUsed = false)
+      this(idleEntitySettings, activeEntityLimit, replacementPolicySettings, 
admissionSettings = None)
 
     import PassivationStrategySettings._
 
     def withIdleEntityPassivation(settings: IdleSettings): 
PassivationStrategySettings =
-      copy(idleEntitySettings = Some(settings), oldSettingUsed = false)
+      copy(idleEntitySettings = Some(settings))
 
     def withIdleEntityPassivation(timeout: FiniteDuration): 
PassivationStrategySettings =
       withIdleEntityPassivation(IdleSettings.defaults.withTimeout(timeout))
@@ -247,32 +223,18 @@ object ClusterShardingSettings {
     def withAdmission(settings: AdmissionSettings): 
PassivationStrategySettings =
       copy(admissionSettings = Some(settings))
 
-    private[pekko] def withOldIdleStrategy(timeout: FiniteDuration): 
PassivationStrategySettings =
-      copy(
-        idleEntitySettings = Some(new IdleSettings(timeout, None)),
-        activeEntityLimit = None,
-        replacementPolicySettings = None,
-        admissionSettings = None,
-        oldSettingUsed = true)
-
     private def copy(
         idleEntitySettings: Option[IdleSettings] = idleEntitySettings,
         activeEntityLimit: Option[Int] = activeEntityLimit,
         replacementPolicySettings: Option[PolicySettings] = 
replacementPolicySettings,
-        admissionSettings: Option[AdmissionSettings] = admissionSettings,
-        oldSettingUsed: Boolean = oldSettingUsed): PassivationStrategySettings 
=
+        admissionSettings: Option[AdmissionSettings] = admissionSettings): 
PassivationStrategySettings =
       new PassivationStrategySettings(
         idleEntitySettings,
         activeEntityLimit,
         replacementPolicySettings,
-        admissionSettings,
-        oldSettingUsed)
+        admissionSettings)
   }
 
-  /**
-   * API MAY CHANGE: Settings for passivation strategies may change after 
additional testing and feedback.
-   */
-  @ApiMayChange
   object PassivationStrategySettings {
     import ClassicShardingSettings.{ PassivationStrategySettings => 
ClassicPassivationStrategySettings }
 
@@ -280,8 +242,7 @@ object ClusterShardingSettings {
       idleEntitySettings = None,
       activeEntityLimit = None,
       replacementPolicySettings = None,
-      admissionSettings = None,
-      oldSettingUsed = false)
+      admissionSettings = None)
 
     val disabled: PassivationStrategySettings = defaults
 
@@ -290,16 +251,14 @@ object ClusterShardingSettings {
         classic.idleEntitySettings.map(IdleSettings.apply),
         classic.activeEntityLimit,
         classic.replacementPolicySettings.map(PolicySettings.apply),
-        classic.admissionSettings.map(AdmissionSettings.apply),
-        classic.oldSettingUsed)
+        classic.admissionSettings.map(AdmissionSettings.apply))
 
     def toClassic(settings: PassivationStrategySettings): 
ClassicPassivationStrategySettings =
       new ClassicPassivationStrategySettings(
         settings.idleEntitySettings.map(IdleSettings.toClassic),
         settings.activeEntityLimit,
         settings.replacementPolicySettings.map(PolicySettings.toClassic),
-        settings.admissionSettings.map(AdmissionSettings.toClassic),
-        settings.oldSettingUsed)
+        settings.admissionSettings.map(AdmissionSettings.toClassic))
 
     object IdleSettings {
       val defaults: IdleSettings = new IdleSettings(timeout = 2.minutes, 
interval = None)
@@ -649,8 +608,6 @@ object ClusterShardingSettings {
         new AdmissionSettings(filter, window)
     }
 
-    private[pekko] def oldDefault(idleTimeout: FiniteDuration): 
PassivationStrategySettings =
-      disabled.withOldIdleStrategy(idleTimeout)
   }
 
   // generated using kaze-class
@@ -873,10 +830,6 @@ final class ClusterShardingSettings(
       rememberEntitiesStoreMode: 
ClusterShardingSettings.RememberEntitiesStoreMode): ClusterShardingSettings =
     copy(rememberEntitiesStoreMode = rememberEntitiesStoreMode)
 
-  /**
-   * API MAY CHANGE: Settings for passivation strategies may change after 
additional testing and feedback.
-   */
-  @ApiMayChange
   def withPassivationStrategy(settings: 
ClusterShardingSettings.PassivationStrategySettings): ClusterShardingSettings =
     copy(passivationStrategySettings = settings)
 
diff --git 
a/cluster-sharding-typed/src/multi-jvm/scala/org/apache/pekko/cluster/sharding/typed/delivery/DeliveryThroughputSpec.scala
 
b/cluster-sharding-typed/src/multi-jvm/scala/org/apache/pekko/cluster/sharding/typed/delivery/DeliveryThroughputSpec.scala
index 47a4711a7f..2e447782cd 100644
--- 
a/cluster-sharding-typed/src/multi-jvm/scala/org/apache/pekko/cluster/sharding/typed/delivery/DeliveryThroughputSpec.scala
+++ 
b/cluster-sharding-typed/src/multi-jvm/scala/org/apache/pekko/cluster/sharding/typed/delivery/DeliveryThroughputSpec.scala
@@ -67,7 +67,7 @@ object DeliveryThroughputSpec extends MultiNodeConfig {
        actor.allow-java-serialization = off
        # quicker dissemination the service keys
        cluster.typed.receptionist.distributed-data.write-consistency = all
-       cluster.sharding.passivate-idle-entity-after = 5s
+       cluster.sharding.passivation.default-idle-strategy.idle-entity.timeout 
= 5s
      }
     """)
 
diff --git 
a/cluster-sharding/src/main/mima-filters/2.0.x.backwards.excludes/remove-old-passivation-strategy.excludes
 
b/cluster-sharding/src/main/mima-filters/2.0.x.backwards.excludes/remove-old-passivation-strategy.excludes
new file mode 100644
index 0000000000..51f1e6e1cd
--- /dev/null
+++ 
b/cluster-sharding/src/main/mima-filters/2.0.x.backwards.excludes/remove-old-passivation-strategy.excludes
@@ -0,0 +1,21 @@
+# 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 old passivation strategy
+ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.cluster.sharding.ClusterShardingSettings#PassivationStrategySettings.fromSharding")
+ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.cluster.sharding.ClusterShardingSettings#PassivationStrategySettings.oldDefault")
+ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.cluster.sharding.ClusterShardingSettings#PassivationStrategySettings.oldSettingUsed")
diff --git a/cluster-sharding/src/main/resources/reference.conf 
b/cluster-sharding/src/main/resources/reference.conf
index 65de646647..f49250ee39 100644
--- a/cluster-sharding/src/main/resources/reference.conf
+++ b/cluster-sharding/src/main/resources/reference.conf
@@ -30,12 +30,6 @@ pekko.cluster.sharding {
   # Default is ddata for backwards compatibility.
   remember-entities-store = "ddata"
 
-  # Deprecated: use the 
`passivation.default-idle-strategy.idle-entity.timeout` setting instead.
-  # Set this to a time duration to have sharding passivate entities when they 
have not
-  # received any message in this length of time. Set to 'off' to disable.
-  # It is always disabled if `remember-entities` is enabled.
-  passivate-idle-entity-after = null
-
   # Automatic entity passivation settings.
   passivation {
 
diff --git 
a/cluster-sharding/src/main/scala/org/apache/pekko/cluster/sharding/ClusterShardingSettings.scala
 
b/cluster-sharding/src/main/scala/org/apache/pekko/cluster/sharding/ClusterShardingSettings.scala
index bb1f5c1445..9093e912a6 100644
--- 
a/cluster-sharding/src/main/scala/org/apache/pekko/cluster/sharding/ClusterShardingSettings.scala
+++ 
b/cluster-sharding/src/main/scala/org/apache/pekko/cluster/sharding/ClusterShardingSettings.scala
@@ -20,7 +20,7 @@ import scala.jdk.DurationConverters._
 import org.apache.pekko
 import pekko.actor.ActorSystem
 import pekko.actor.NoSerializationVerificationNeeded
-import pekko.annotation.{ ApiMayChange, InternalApi }
+import pekko.annotation.InternalApi
 import pekko.cluster.Cluster
 import pekko.cluster.singleton.ClusterSingletonManagerSettings
 import pekko.coordination.lease.LeaseUsageSettings
@@ -101,7 +101,7 @@ object ClusterShardingSettings {
 
     val coordinatorSingletonSettings = 
ClusterSingletonManagerSettings(config.getConfig("coordinator-singleton"))
 
-    val passivationStrategySettings = 
PassivationStrategySettings.fromSharding(config)
+    val passivationStrategySettings = 
PassivationStrategySettings(config.getConfig("passivation"))
 
     val lease = config.getString("use-lease") match {
       case s if s.isEmpty => None
@@ -141,46 +141,22 @@ object ClusterShardingSettings {
   private[pekko] def roleOption(role: String): Option[String] =
     if (role == "") None else Option(role)
 
-  /**
-   * API MAY CHANGE: Settings for passivation strategies may change after 
additional testing and feedback.
-   */
-  @ApiMayChange
-  final class PassivationStrategySettings private[pekko] (
+  final class PassivationStrategySettings(
       val idleEntitySettings: Option[PassivationStrategySettings.IdleSettings],
       val activeEntityLimit: Option[Int],
       val replacementPolicySettings: 
Option[PassivationStrategySettings.PolicySettings],
-      val admissionSettings: 
Option[PassivationStrategySettings.AdmissionSettings],
-      private[pekko] val oldSettingUsed: Boolean) {
-
-    private[pekko] def this(
-        idleEntitySettings: Option[PassivationStrategySettings.IdleSettings],
-        activeEntityLimit: Option[Int],
-        replacementPolicySettings: 
Option[PassivationStrategySettings.PolicySettings],
-        oldSettingUsed: Boolean) =
-      this(idleEntitySettings, activeEntityLimit, replacementPolicySettings, 
admissionSettings = None, oldSettingUsed)
-
-    def this(
-        idleEntitySettings: Option[PassivationStrategySettings.IdleSettings],
-        activeEntityLimit: Option[Int],
-        replacementPolicySettings: 
Option[PassivationStrategySettings.PolicySettings],
-        admissionSettings: 
Option[PassivationStrategySettings.AdmissionSettings]) =
-      this(idleEntitySettings, activeEntityLimit, replacementPolicySettings, 
admissionSettings, oldSettingUsed = false)
+      val admissionSettings: 
Option[PassivationStrategySettings.AdmissionSettings]) {
 
     def this(
         idleEntitySettings: Option[PassivationStrategySettings.IdleSettings],
         activeEntityLimit: Option[Int],
         replacementPolicySettings: 
Option[PassivationStrategySettings.PolicySettings]) =
-      this(
-        idleEntitySettings,
-        activeEntityLimit,
-        replacementPolicySettings,
-        admissionSettings = None,
-        oldSettingUsed = false)
+      this(idleEntitySettings, activeEntityLimit, replacementPolicySettings, 
admissionSettings = None)
 
     import PassivationStrategySettings._
 
     def withIdleEntityPassivation(settings: IdleSettings): 
PassivationStrategySettings =
-      copy(idleEntitySettings = Some(settings), oldSettingUsed = false)
+      copy(idleEntitySettings = Some(settings))
 
     def withIdleEntityPassivation(timeout: FiniteDuration): 
PassivationStrategySettings =
       withIdleEntityPassivation(IdleSettings.defaults.withTimeout(timeout))
@@ -214,39 +190,24 @@ object ClusterShardingSettings {
     def withAdmission(settings: AdmissionSettings): 
PassivationStrategySettings =
       copy(admissionSettings = Some(settings))
 
-    private[pekko] def withOldIdleStrategy(timeout: FiniteDuration): 
PassivationStrategySettings =
-      copy(
-        idleEntitySettings = Some(new IdleSettings(timeout, None)),
-        activeEntityLimit = None,
-        replacementPolicySettings = None,
-        admissionSettings = None,
-        oldSettingUsed = true)
-
     private def copy(
         idleEntitySettings: Option[IdleSettings] = idleEntitySettings,
         activeEntityLimit: Option[Int] = activeEntityLimit,
         replacementPolicySettings: Option[PolicySettings] = 
replacementPolicySettings,
-        admissionSettings: Option[AdmissionSettings] = admissionSettings,
-        oldSettingUsed: Boolean = oldSettingUsed): PassivationStrategySettings 
=
+        admissionSettings: Option[AdmissionSettings] = admissionSettings): 
PassivationStrategySettings =
       new PassivationStrategySettings(
         idleEntitySettings,
         activeEntityLimit,
         replacementPolicySettings,
-        admissionSettings,
-        oldSettingUsed)
+        admissionSettings)
   }
 
-  /**
-   * API MAY CHANGE: Settings for passivation strategies may change after 
additional testing and feedback.
-   */
-  @ApiMayChange
   object PassivationStrategySettings {
     val defaults = new PassivationStrategySettings(
       idleEntitySettings = None,
       activeEntityLimit = None,
       replacementPolicySettings = None,
-      admissionSettings = None,
-      oldSettingUsed = false)
+      admissionSettings = None)
 
     val disabled: PassivationStrategySettings = defaults
 
@@ -572,11 +533,6 @@ object ClusterShardingSettings {
         new AdmissionSettings(filter, window)
     }
 
-    /**
-     * API MAY CHANGE: Settings and configuration for passivation strategies 
may change after additional
-     * testing and feedback.
-     */
-    @ApiMayChange
     def apply(config: Config): PassivationStrategySettings = {
       toRootLowerCase(config.getString("strategy")) match {
         case "off" | "none" => PassivationStrategySettings.disabled
@@ -598,20 +554,6 @@ object ClusterShardingSettings {
       }
     }
 
-    def fromSharding(shardingConfig: Config): PassivationStrategySettings = {
-      // default to old setting if it exists (defined in application.conf), 
overriding the new settings
-      if (shardingConfig.hasPath("passivate-idle-entity-after")) {
-        val timeout =
-          if 
(toRootLowerCase(shardingConfig.getString("passivate-idle-entity-after")) == 
"off") Duration.Zero
-          else shardingConfig.getDuration("passivate-idle-entity-after", 
MILLISECONDS).millis
-        oldDefault(timeout)
-      } else {
-        PassivationStrategySettings(shardingConfig.getConfig("passivation"))
-      }
-    }
-
-    private[pekko] def oldDefault(idleTimeout: FiniteDuration): 
PassivationStrategySettings =
-      defaults.withOldIdleStrategy(idleTimeout)
   }
 
   /**
@@ -1018,10 +960,6 @@ final class ClusterShardingSettings(
   def withStateStoreMode(stateStoreMode: String): ClusterShardingSettings =
     copy(stateStoreMode = stateStoreMode)
 
-  /**
-   * API MAY CHANGE: Settings for passivation strategies may change after 
additional testing and feedback.
-   */
-  @ApiMayChange
   def withPassivationStrategy(settings: 
ClusterShardingSettings.PassivationStrategySettings): ClusterShardingSettings =
     copy(passivationStrategySettings = settings)
 
diff --git 
a/cluster-sharding/src/main/scala/org/apache/pekko/cluster/sharding/ShardRegion.scala
 
b/cluster-sharding/src/main/scala/org/apache/pekko/cluster/sharding/ShardRegion.scala
index 4b3fba1c49..ca59e57c91 100644
--- 
a/cluster-sharding/src/main/scala/org/apache/pekko/cluster/sharding/ShardRegion.scala
+++ 
b/cluster-sharding/src/main/scala/org/apache/pekko/cluster/sharding/ShardRegion.scala
@@ -27,7 +27,6 @@ import org.apache.pekko
 import pekko.Done
 import pekko.actor._
 import pekko.annotation.{ InternalApi, InternalStableApi }
-import pekko.annotation.ApiMayChange
 import pekko.cluster.Cluster
 import pekko.cluster.ClusterEvent._
 import pekko.cluster.ClusterSettings
@@ -501,11 +500,8 @@ object ShardRegion {
       with DeadLetterSuppression
 
   /**
-   * API MAY CHANGE: Messages for passivation strategies may change after 
additional testing and feedback.
-   *
    * When limit-based automatic passivation is enabled, set a new active 
entity limit for a shard region.
    */
-  @ApiMayChange
   final case class SetActiveEntityLimit(perRegionLimit: Int)
 
   /**
@@ -700,12 +696,6 @@ private[pekko] class ShardRegion(
   }
 
   private def logPassivationStrategy(): Unit = {
-    if (settings.passivationStrategySettings.oldSettingUsed) {
-      log.warning(
-        "The `pekko.cluster.sharding.passivate-idle-entity-after` setting and 
associated methods are deprecated. " +
-        "Use the 
`pekko.cluster.sharding.passivation.default-idle-strategy.idle-entity.timeout` 
setting instead. " +
-        "See the documentation and reference config for more information on 
automatic passivation strategies.")
-    }
     if (settings.rememberEntities) {
       log.debug("{}: Entities will not be passivated automatically because 
'rememberEntities' is enabled.", typeName)
     } else {
diff --git 
a/cluster-sharding/src/test/scala/org/apache/pekko/cluster/sharding/ClusterShardingSettingsSpec.scala
 
b/cluster-sharding/src/test/scala/org/apache/pekko/cluster/sharding/ClusterShardingSettingsSpec.scala
index 56fecd542e..b194c5ecf4 100644
--- 
a/cluster-sharding/src/test/scala/org/apache/pekko/cluster/sharding/ClusterShardingSettingsSpec.scala
+++ 
b/cluster-sharding/src/test/scala/org/apache/pekko/cluster/sharding/ClusterShardingSettingsSpec.scala
@@ -821,16 +821,5 @@ class ClusterShardingSettingsSpec extends AnyWordSpec with 
Matchers {
         .passivationStrategy shouldBe 
ClusterShardingSettings.NoPassivationStrategy
     }
 
-    "support old `passivate-idle-entity-after` setting (overriding new 
strategy settings)" in {
-      settings("""
-        pekko.cluster.sharding {
-          passivate-idle-entity-after = 5 minutes
-          passivation.strategy = default-strategy
-        }
-      """).passivationStrategy shouldBe 
ClusterShardingSettings.IdlePassivationStrategy(
-        timeout = 5.minutes,
-        interval = 2.5.minutes)
-    }
-
   }
 }
diff --git 
a/cluster-sharding/src/test/scala/org/apache/pekko/cluster/sharding/ShardRegionDataTypesSpec.scala
 
b/cluster-sharding/src/test/scala/org/apache/pekko/cluster/sharding/ShardRegionDataTypesSpec.scala
new file mode 100644
index 0000000000..47ef090e58
--- /dev/null
+++ 
b/cluster-sharding/src/test/scala/org/apache/pekko/cluster/sharding/ShardRegionDataTypesSpec.scala
@@ -0,0 +1,116 @@
+/*
+ * 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.
+ */
+
+package org.apache.pekko.cluster.sharding
+
+import org.apache.pekko.cluster.sharding.ShardRegion._
+
+import org.scalatest.matchers.should.Matchers
+import org.scalatest.wordspec.AnyWordSpec
+
+class ShardRegionDataTypesSpec extends AnyWordSpec with Matchers {
+
+  "ShardRegionStats" must {
+
+    "be constructable with only stats (failed defaults to empty set)" in {
+      val s = ShardRegionStats(Map("s1" -> 3))
+      s.stats shouldBe Map("s1" -> 3)
+      s.failed shouldBe Set.empty[ShardId]
+    }
+
+    "be constructable with both stats and failed" in {
+      val s = ShardRegionStats(Map("s1" -> 3, "s2" -> 7), Set("s3"))
+      s.stats shouldBe Map("s1" -> 3, "s2" -> 7)
+      s.failed shouldBe Set("s3")
+    }
+
+    "support equality" in {
+      val a = ShardRegionStats(Map("s1" -> 1), Set("s2"))
+      val b = ShardRegionStats(Map("s1" -> 1), Set("s2"))
+      val c = ShardRegionStats(Map("s1" -> 2), Set("s2"))
+      a shouldBe b
+      a should not be c
+    }
+
+    "support copy" in {
+      val original = ShardRegionStats(Map("s1" -> 1), Set("s2"))
+      val copied = original.copy(stats = Map("s1" -> 5))
+      copied.stats shouldBe Map("s1" -> 5)
+      copied.failed shouldBe Set("s2")
+    }
+
+    "support pattern matching" in {
+      val s = ShardRegionStats(Map("s1" -> 1), Set("s2"))
+      s match {
+        case ShardRegionStats(stats) =>
+          stats shouldBe Map("s1" -> 1)
+      }
+    }
+
+    "expose Java API getStats and getFailed" in {
+      import scala.jdk.CollectionConverters._
+      val s = ShardRegionStats(Map("s1" -> 3), Set("s2"))
+      s.getStats().asScala shouldBe Map("s1" -> 3)
+      s.getFailed().asScala shouldBe Set("s2")
+    }
+  }
+
+  "CurrentShardRegionState" must {
+
+    "be constructable with only shards (failed defaults to empty set)" in {
+      val state = CurrentShardRegionState(Set(ShardState("s1", Set("e1"))))
+      state.shards shouldBe Set(ShardState("s1", Set("e1")))
+      state.failed shouldBe Set.empty[ShardId]
+    }
+
+    "be constructable with both shards and failed" in {
+      val state = CurrentShardRegionState(Set(ShardState("s1", Set("e1"))), 
Set("s2"))
+      state.shards shouldBe Set(ShardState("s1", Set("e1")))
+      state.failed shouldBe Set("s2")
+    }
+
+    "support equality" in {
+      val a = CurrentShardRegionState(Set(ShardState("s1", Set("e1"))), 
Set("s2"))
+      val b = CurrentShardRegionState(Set(ShardState("s1", Set("e1"))), 
Set("s2"))
+      val c = CurrentShardRegionState(Set(ShardState("s1", Set("e2"))), 
Set("s2"))
+      a shouldBe b
+      a should not be c
+    }
+
+    "support copy" in {
+      val original = CurrentShardRegionState(Set(ShardState("s1", Set("e1"))), 
Set("s2"))
+      val copied = original.copy(shards = Set(ShardState("s1", Set("e2"))))
+      copied.shards shouldBe Set(ShardState("s1", Set("e2")))
+      copied.failed shouldBe Set("s2")
+    }
+
+    "support pattern matching" in {
+      val state = CurrentShardRegionState(Set(ShardState("s1", Set("e1"))), 
Set("s2"))
+      state match {
+        case CurrentShardRegionState(shards) =>
+          shards shouldBe Set(ShardState("s1", Set("e1")))
+      }
+    }
+
+    "expose Java API getShards and getFailed" in {
+      import scala.jdk.CollectionConverters._
+      val state = CurrentShardRegionState(Set(ShardState("s1", Set("e1"))), 
Set("s2"))
+      state.getShards().asScala shouldBe Set(ShardState("s1", Set("e1")))
+      state.getFailed().asScala shouldBe Set("s2")
+    }
+  }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to