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

fanningpj 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 40dfb57c90 Scheduler: remove more deprecated methods (#2037)
40dfb57c90 is described below

commit 40dfb57c9086d0d09885c66f0c26983072c196c0
Author: PJ Fanning <[email protected]>
AuthorDate: Fri Aug 22 16:24:15 2025 +0100

    Scheduler: remove more deprecated methods (#2037)
    
    * try to remove remaining deprecations in scheduler
    
    * Update Scheduler.scala
    
    * Update Cluster.scala
    
    * mima
---
 .../remove-deprecated-methods.excludes             |  3 ++
 .../pekko/actor/LightArrayRevolverScheduler.scala  |  2 +-
 .../scala/org/apache/pekko/actor/Scheduler.scala   | 47 +++++-----------------
 .../scala/org/apache/pekko/cluster/Cluster.scala   |  5 +--
 .../remove-deprecated-methods.excludes             |  1 +
 5 files changed, 17 insertions(+), 41 deletions(-)

diff --git 
a/actor/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes
 
b/actor/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes
index d0ad462cd9..a82b50ce13 100644
--- 
a/actor/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes
+++ 
b/actor/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes
@@ -27,6 +27,9 @@ 
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.actor.FSM.s
 
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.actor.LightArrayRevolverScheduler.schedule")
 
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.actor.Props.create")
 
ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.actor.ScalaActorRef")
+ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.actor.AbstractSchedulerBase.schedule$*")
+ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.actor.LightArrayRevolverScheduler.schedule$*")
+ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.actor.Scheduler.schedule$*")
 
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.actor.Scheduler.schedule")
 
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.actor.TimerScheduler.startPeriodicTimer")
 
ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.actor.TypedActor*")
diff --git 
a/actor/src/main/scala/org/apache/pekko/actor/LightArrayRevolverScheduler.scala 
b/actor/src/main/scala/org/apache/pekko/actor/LightArrayRevolverScheduler.scala
index eaed5aaea0..912ef5512c 100644
--- 
a/actor/src/main/scala/org/apache/pekko/actor/LightArrayRevolverScheduler.scala
+++ 
b/actor/src/main/scala/org/apache/pekko/actor/LightArrayRevolverScheduler.scala
@@ -131,7 +131,7 @@ class LightArrayRevolverScheduler(config: Config, log: 
LoggingAdapter, threadFac
     super.scheduleWithFixedDelay(initialDelay, delay)(runnable)
   }
 
-  override def schedule(initialDelay: FiniteDuration, delay: FiniteDuration, 
runnable: Runnable)(
+  override protected def schedule(initialDelay: FiniteDuration, delay: 
FiniteDuration, runnable: Runnable)(
       implicit executor: ExecutionContext): Cancellable = {
     checkPeriod(delay)
     checkMaxDelay(roundUp(delay).toNanos)
diff --git a/actor/src/main/scala/org/apache/pekko/actor/Scheduler.scala 
b/actor/src/main/scala/org/apache/pekko/actor/Scheduler.scala
index 707d4c0952..89e44bbc59 100644
--- a/actor/src/main/scala/org/apache/pekko/actor/Scheduler.scala
+++ b/actor/src/main/scala/org/apache/pekko/actor/Scheduler.scala
@@ -15,7 +15,6 @@ package org.apache.pekko.actor
 
 import java.util.concurrent.atomic.AtomicReference
 
-import scala.annotation.nowarn
 import scala.annotation.tailrec
 import scala.concurrent.ExecutionContext
 import scala.concurrent.duration._
@@ -150,7 +149,6 @@ trait Scheduler {
    *
    * Note: For scheduling within actors `with Timers` should be preferred.
    */
-  @nowarn("msg=deprecated")
   final def scheduleWithFixedDelay(
       initialDelay: FiniteDuration,
       delay: FiniteDuration,
@@ -225,7 +223,6 @@ trait Scheduler {
    *
    * Note: For scheduling within actors `with Timers` should be preferred.
    */
-  @nowarn("msg=deprecated")
   final def scheduleAtFixedRate(initialDelay: FiniteDuration, interval: 
FiniteDuration)(runnable: Runnable)(
       implicit executor: ExecutionContext): Cancellable =
     schedule(initialDelay, interval, runnable)(executor)
@@ -294,7 +291,6 @@ trait Scheduler {
    *
    * Note: For scheduling within actors `with Timers` should be preferred.
    */
-  @nowarn("msg=deprecated")
   final def scheduleAtFixedRate(
       initialDelay: FiniteDuration,
       interval: FiniteDuration,
@@ -303,7 +299,16 @@ trait Scheduler {
       implicit
       executor: ExecutionContext,
       sender: ActorRef = Actor.noSender): Cancellable =
-    schedule(initialDelay, interval, receiver, message)
+    schedule(
+      initialDelay,
+      interval,
+      new Runnable {
+        def run(): Unit = {
+          receiver ! message
+          if (receiver.isTerminated)
+            throw SchedulerException("timer active for terminated actor")
+        }
+      })
 
   /**
    * Java API: Schedules a message to be sent repeatedly with an initial delay 
and
@@ -340,37 +345,7 @@ trait Scheduler {
     scheduleAtFixedRate(initialDelay.asScala, interval.asScala, receiver, 
message)(executor, sender)
   }
 
-  /**
-   * Deprecated API: See [[Scheduler#scheduleWithFixedDelay]] or 
[[Scheduler#scheduleAtFixedRate]].
-   */
-  @deprecated(
-    "Use scheduleWithFixedDelay or scheduleAtFixedRate instead. This has the 
same semantics as " +
-    "scheduleAtFixedRate, but scheduleWithFixedDelay is often preferred.",
-    since = "Akka 2.6.0")
-  @nowarn("msg=deprecated")
-  final def schedule(initialDelay: FiniteDuration, interval: FiniteDuration, 
receiver: ActorRef, message: Any)(
-      implicit
-      executor: ExecutionContext,
-      sender: ActorRef = Actor.noSender): Cancellable =
-    schedule(
-      initialDelay,
-      interval,
-      new Runnable {
-        def run(): Unit = {
-          receiver ! message
-          if (receiver.isTerminated)
-            throw SchedulerException("timer active for terminated actor")
-        }
-      })
-
-  /**
-   * Deprecated API: See [[Scheduler#scheduleWithFixedDelay]] or 
[[Scheduler#scheduleAtFixedRate]].
-   */
-  @deprecated(
-    "Use scheduleWithFixedDelay or scheduleAtFixedRate instead. This has the 
same semantics as " +
-    "scheduleAtFixedRate, but scheduleWithFixedDelay is often preferred.",
-    since = "Akka 2.6.0")
-  def schedule(initialDelay: FiniteDuration, interval: FiniteDuration, 
runnable: Runnable)(
+  protected def schedule(initialDelay: FiniteDuration, interval: 
FiniteDuration, runnable: Runnable)(
       implicit executor: ExecutionContext): Cancellable
 
   /**
diff --git a/cluster/src/main/scala/org/apache/pekko/cluster/Cluster.scala 
b/cluster/src/main/scala/org/apache/pekko/cluster/Cluster.scala
index b094f2c35a..2acb1b4f44 100644
--- a/cluster/src/main/scala/org/apache/pekko/cluster/Cluster.scala
+++ b/cluster/src/main/scala/org/apache/pekko/cluster/Cluster.scala
@@ -23,7 +23,6 @@ import scala.concurrent.{ Await, ExecutionContext }
 import scala.concurrent.duration._
 import scala.util.control.NonFatal
 
-import scala.annotation.nowarn
 import com.typesafe.config.{ Config, ConfigFactory }
 
 import org.apache.pekko
@@ -110,7 +109,6 @@ class Cluster(val system: ExtendedActorSystem) extends 
Extension {
   /**
    * Java API: roles that this member has
    */
-  @nowarn("msg=deprecated")
   def getSelfRoles: java.util.Set[String] = {
     import pekko.util.ccompat.JavaConverters._
     selfRoles.asJava
@@ -191,10 +189,9 @@ class Cluster(val system: ExtendedActorSystem) extends 
Extension {
 
         override def maxFrequency: Double = systemScheduler.maxFrequency
 
-        @nowarn("msg=deprecated")
         override def schedule(initialDelay: FiniteDuration, interval: 
FiniteDuration, runnable: Runnable)(
             implicit executor: ExecutionContext): Cancellable =
-          systemScheduler.schedule(initialDelay, interval, runnable)
+          systemScheduler.scheduleAtFixedRate(initialDelay, interval)(runnable)
 
         override def scheduleOnce(delay: FiniteDuration, runnable: Runnable)(
             implicit executor: ExecutionContext): Cancellable =
diff --git 
a/testkit/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes
 
b/testkit/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes
index dc5c8a572d..69578fb7da 100644
--- 
a/testkit/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes
+++ 
b/testkit/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes
@@ -17,6 +17,7 @@
 
 # Remove deprecated methods
 
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.ExplicitlyTriggeredScheduler.schedule")
+ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.ExplicitlyTriggeredScheduler.schedule$*")
 
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.TestFSMRef.setTimer*")
 
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.TestKit.expectNoMsg")
 
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.TestKitBase.expectNoMsg")


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

Reply via email to