diff --git a/actor-tests/src/test/java/org/apache/pekko/actor/ActorCreationTest.java b/actor-tests/src/test/java/org/apache/pekko/actor/ActorCreationTest.java index 742e9f8123..0e7461c999 100644 --- a/actor-tests/src/test/java/org/apache/pekko/actor/ActorCreationTest.java +++ b/actor-tests/src/test/java/org/apache/pekko/actor/ActorCreationTest.java @@ -82,17 +82,12 @@ public class ActorCreationTest extends JUnitSuite { } public static class TestActor extends AbstractActor { - public static Props propsUsingLamda(Integer magicNumber) { + public static Props propsUsingLambda(Integer magicNumber) { // You need to specify the actual type of the returned actor // since Java 8 lambdas have some runtime type information erased return Props.create(TestActor.class, () -> new TestActor(magicNumber)); } - @Deprecated - public static Props propsUsingLamdaWithoutClass(Integer magicNumber) { - return Props.create(() -> new TestActor(magicNumber)); - } - @SuppressWarnings("unused") private final Integer magicNumber; @@ -202,40 +197,6 @@ public class ActorCreationTest extends JUnitSuite { exception.getMessage()); } - @Test - @SuppressWarnings("unchecked") - @Deprecated - public void testWrongErasedStaticCreator() { - IllegalArgumentException exception = - Assert.assertThrows(IllegalArgumentException.class, () -> Props.create(new G())); - assertEquals( - "erased Creator types (e.g. lambdas) are unsupported, use Props.create(actorClass, creator) instead", - exception.getMessage()); - Props.create(AbstractActor.class, new G()); - } - - @Deprecated - @Test - public void testRightStaticCreator() { - final Props p = Props.create(new C()); - assertEquals(AbstractActor.class, p.actorClass()); - } - - @Test - @Deprecated - public void testWrongAnonymousClassStaticCreator() { - IllegalArgumentException exception = - Assert.assertThrows( - "Should have detected this is not a real static class, and thrown", - IllegalArgumentException.class, - () -> { - Props.create(new C() {}); // has implicit reference to outer class - }); - assertEquals( - "cannot use non-static local Creator to create actors; make it static (e.g. local to a static method) or top-level", - exception.getMessage()); - } - @Test public void testRightTopLevelNonStaticCreator() { final Creator nonStatic = new NonStaticCreator(); @@ -243,27 +204,6 @@ public class ActorCreationTest extends JUnitSuite { assertEquals(UntypedAbstractActor.class, p.actorClass()); } - @Test - @Deprecated - public void testRightStaticParametricCreator() { - final Props p = Props.create(new D()); - assertEquals(Actor.class, p.actorClass()); - } - - @Test - @Deprecated - public void testRightStaticBoundedCreator() { - final Props p = Props.create(new E()); - assertEquals(AbstractActor.class, p.actorClass()); - } - - @Test - @Deprecated - public void testRightStaticSuperinterface() { - final Props p = Props.create(new F()); - assertEquals(AbstractActor.class, p.actorClass()); - } - @Test public void testWrongAbstractActorClass() { IllegalArgumentException exception = @@ -282,61 +222,12 @@ public class ActorCreationTest extends JUnitSuite { }; } - @Test - @Deprecated - public void testAnonymousClassCreatedInStaticMethodCreator() { - final Creator anonymousCreatorFromStaticMethod = - createAnonymousCreatorInStaticMethod(); - Props.create(anonymousCreatorFromStaticMethod); - } - - @Test - @Deprecated - public void testClassCreatorWithArguments() { - final Creator anonymousCreatorFromStaticMethod = new P("hello"); - Props.create(anonymousCreatorFromStaticMethod); - } - - @Test - @Deprecated - public void testAnonymousClassCreatorWithArguments() { - IllegalArgumentException exception = - Assert.assertThrows( - "Should have detected this is not a real static class, and thrown", - IllegalArgumentException.class, - () -> { - final Creator anonymousCreatorFromStaticMethod = new P("hello") { - // captures enclosing class - }; - Props.create(anonymousCreatorFromStaticMethod); - }); - assertEquals( - "cannot use non-static local Creator to create actors; make it static (e.g. local to a static method) or top-level", - exception.getMessage()); - } - @Test public void testRightPropsUsingLambda() { - final Props p = TestActor.propsUsingLamda(17); + final Props p = TestActor.propsUsingLambda(17); assertEquals(TestActor.class, p.actorClass()); } - @Test - @Deprecated - public void testWrongPropsUsingLambdaWithoutClass() { - final Props p = TestActor.propsUsingLamda(17); - assertEquals(TestActor.class, p.actorClass()); - - IllegalArgumentException exception = - Assert.assertThrows( - "Should have detected lambda erasure, and thrown", - IllegalArgumentException.class, - () -> TestActor.propsUsingLamdaWithoutClass(17)); - assertEquals( - "erased Creator types (e.g. lambdas) are unsupported, use Props.create(actorClass, creator) instead", - exception.getMessage()); - } - @Test public void testRightPropsUsingCreator() { final Props p = TestActor2.propsUsingCreator(17); diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/PropsCreationSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/PropsCreationSpec.scala index 9e9d4258e8..e659dbf0a1 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/PropsCreationSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/PropsCreationSpec.scala @@ -13,8 +13,6 @@ package org.apache.pekko.actor -import scala.annotation.nowarn - import org.apache.pekko import pekko.testkit.PekkoSpec import pekko.util.unused @@ -69,11 +67,6 @@ class PropsCreationSpec extends PekkoSpec(""" } "Props Java API" must { - "work with create(creator)" in { - @nowarn - val p = Props.create(OneParamActorCreator) - system.actorOf(p) - } "work with create(class, creator)" in { val p = Props.create(classOf[Actor], OneParamActorCreator) system.actorOf(p) diff --git a/actor-tests/src/test/scala/org/apache/pekko/event/jul/JavaLoggerSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/event/jul/JavaLoggerSpec.scala deleted file mode 100644 index 87625c2cf4..0000000000 --- a/actor-tests/src/test/scala/org/apache/pekko/event/jul/JavaLoggerSpec.scala +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * license agreements; and to You under the Apache License, version 2.0: - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * This file is part of the Apache Pekko project, which was derived from Akka. - */ - -/* - * Copyright (C) 2009-2022 Lightbend Inc. - */ - -package org.apache.pekko.event.jul - -import java.util.logging - -import scala.util.control.NoStackTrace - -import com.typesafe.config.ConfigFactory - -import org.apache.pekko -import pekko.actor.{ Actor, ActorLogging, Props } -import pekko.testkit.PekkoSpec - -@deprecated("Use SLF4J instead.", "Akka 2.6.0") -object JavaLoggerSpec { - - val config = ConfigFactory.parseString(""" - pekko { - loglevel = INFO - loggers = ["org.apache.pekko.event.jul.JavaLogger"] - logging-filter = "org.apache.pekko.event.jul.JavaLoggingFilter" - }""") - - class LogProducer extends Actor with ActorLogging { - def receive = { - case e: Exception => - log.error(e, e.getMessage) - case (s: String, x: Int) => - log.info(s, x) - } - } - - class SimulatedExc extends RuntimeException("Simulated error") with NoStackTrace -} - -@deprecated("Use SLF4J instead.", "Akka 2.6.0") -class JavaLoggerSpec extends PekkoSpec(JavaLoggerSpec.config) { - - val logger = logging.Logger.getLogger(classOf[JavaLoggerSpec.LogProducer].getName) - logger.setUseParentHandlers(false) // turn off output of test LogRecords - logger.addHandler(new logging.Handler { - def publish(record: logging.LogRecord): Unit = { - testActor ! record - } - - def flush(): Unit = {} - def close(): Unit = {} - }) - - val producer = system.actorOf(Props[JavaLoggerSpec.LogProducer](), name = "log") - - "JavaLogger" must { - - "log error with stackTrace" in { - producer ! new JavaLoggerSpec.SimulatedExc - - val record = expectMsgType[logging.LogRecord] - - record should not be null - record.getMillis should not be 0 - record.getThreadID should not be 0 - record.getLevel should ===(logging.Level.SEVERE) - record.getMessage should ===("Simulated error") - record.getThrown.getClass should ===(classOf[JavaLoggerSpec.SimulatedExc]) - record.getSourceClassName should ===(classOf[JavaLoggerSpec.LogProducer].getName) - record.getSourceMethodName should ===(null) - } - - "log info without stackTrace" in { - producer ! (("{} is the magic number", 3)) - - val record = expectMsgType[logging.LogRecord] - - record should not be null - record.getMillis should not be 0 - record.getThreadID should not be 0 - record.getLevel should ===(logging.Level.INFO) - record.getMessage should ===("3 is the magic number") - record.getThrown should ===(null) - record.getSourceClassName should ===(classOf[JavaLoggerSpec.LogProducer].getName) - record.getSourceMethodName should ===(null) - } - } - -} 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 new file mode 100644 index 0000000000..2838597a9f --- /dev/null +++ b/actor/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes @@ -0,0 +1,51 @@ +# 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 methods +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.actor.AbstractFSM.setTimer*") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.actor.AbstractSchedulerBase.schedule") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.actor.ActorSelection.resolveOneCS") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.actor.CoordinatedShutdown.run") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.actor.CoordinatedShutdown.runAll") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.actor.FSM.setTimer*") +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.Scheduler.schedule") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.actor.TimerScheduler.startPeriodicTimer") +ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.actor.package") +ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.actor.package$") +ProblemFilters.exclude[MissingFieldProblem]("org.apache.pekko.dispatch.ExecutionContexts.sameThreadExecutionContext") +ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.dispatch.ExecutionContexts$sameThreadExecutionContext$") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.event.LogMarker.extractFromMDC") +ProblemFilters.exclude[MissingTypesProblem]("org.apache.pekko.event.Logging$StandardOutLogger") +ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.event.jul.*") +ProblemFilters.exclude[MissingFieldProblem]("org.apache.pekko.io.Tcp.WriteFile") +ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.io.Tcp$WriteFile") +ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.io.Tcp$WriteFile$") +ProblemFilters.exclude[MissingTypesProblem]("org.apache.pekko.pattern.BackoffSupervisor") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.pattern.BackoffSupervisor.props") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.pattern.BackoffSupervisor.propsWithSupervisorStrategy") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.pattern.BackoffSupervisor.childProps") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.pattern.BackoffSupervisor.childName") +ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.pekko.pattern.BackoffSupervisor.reset") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.pattern.BackoffSupervisor.replyWhileStopped") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.pattern.BackoffSupervisor.finalStopMessage") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.pattern.BackoffSupervisor.this") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.pattern.CircuitBreaker.create") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.pattern.CircuitBreaker.this") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.serialization.Serialization.deserialize") diff --git a/actor/src/main/scala/org/apache/pekko/actor/AbstractActor.scala b/actor/src/main/scala/org/apache/pekko/actor/AbstractActor.scala index c57a959c14..a4f9201d96 100644 --- a/actor/src/main/scala/org/apache/pekko/actor/AbstractActor.scala +++ b/actor/src/main/scala/org/apache/pekko/actor/AbstractActor.scala @@ -15,12 +15,11 @@ package org.apache.pekko.actor import java.util.Optional +import scala.annotation.nowarn import scala.concurrent.ExecutionContextExecutor import scala.concurrent.duration.Duration import scala.runtime.BoxedUnit -import scala.annotation.nowarn - import org.apache.pekko import pekko.annotation.DoNotInherit import pekko.japi.pf.ReceiveBuilder diff --git a/actor/src/main/scala/org/apache/pekko/actor/AbstractFSM.scala b/actor/src/main/scala/org/apache/pekko/actor/AbstractFSM.scala index d9b63c6a3e..862e6d9be4 100644 --- a/actor/src/main/scala/org/apache/pekko/actor/AbstractFSM.scala +++ b/actor/src/main/scala/org/apache/pekko/actor/AbstractFSM.scala @@ -503,48 +503,6 @@ abstract class AbstractFSM[S, D] extends FSM[S, D] { def startSingleTimer(name: String, msg: Any, delay: java.time.Duration): Unit = startSingleTimer(name, msg, delay.asScala) - /** - * Schedule named timer to deliver message after given delay, possibly repeating. - * Any existing timer with the same name will automatically be canceled before - * adding the new timer. - * @param name identifier to be used with cancelTimer() - * @param msg message to be delivered - * @param timeout delay of first message delivery and between subsequent messages - */ - @deprecated("Use startSingleTimer instead.", since = "Akka 2.6.0") - final def setTimer(name: String, msg: Any, timeout: FiniteDuration): Unit = - setTimer(name, msg, timeout, repeat = false) - - /** - * Schedule named timer to deliver message after given delay, possibly repeating. - * Any existing timer with the same name will automatically be canceled before - * adding the new timer. - * @param name identifier to be used with cancelTimer() - * @param msg message to be delivered - * @param timeout delay of first message delivery and between subsequent messages - */ - @deprecated("Use startSingleTimer instead.", since = "Akka 2.6.0") - final def setTimer(name: String, msg: Any, timeout: java.time.Duration): Unit = { - setTimer(name, msg, timeout.asScala, false) - } - - /** - * Schedule named timer to deliver message after given delay, possibly repeating. - * Any existing timer with the same name will automatically be canceled before - * adding the new timer. - * @param name identifier to be used with cancelTimer() - * @param msg message to be delivered - * @param timeout delay of first message delivery and between subsequent messages - * @param repeat send once if false, scheduleAtFixedRate if true - */ - @deprecated( - "Use startSingleTimer, startTimerWithFixedDelay or startTimerAtFixedRate instead. This has the same semantics as " + - "startTimerAtFixedRate, but startTimerWithFixedDelay is often preferred.", - since = "Akka 2.6.0") - final def setTimer(name: String, msg: Any, timeout: java.time.Duration, repeat: Boolean): Unit = { - setTimer(name, msg, timeout.asScala, repeat) - } - /** * Default reason if calling `stop()`. */ diff --git a/actor/src/main/scala/org/apache/pekko/actor/AbstractProps.scala b/actor/src/main/scala/org/apache/pekko/actor/AbstractProps.scala index 628851f5d6..289d0d2c26 100644 --- a/actor/src/main/scala/org/apache/pekko/actor/AbstractProps.scala +++ b/actor/src/main/scala/org/apache/pekko/actor/AbstractProps.scala @@ -13,7 +13,7 @@ package org.apache.pekko.actor -import java.lang.reflect.{ Modifier, ParameterizedType, TypeVariable } +import java.lang.reflect.Modifier import java.lang.reflect.Constructor import scala.annotation.tailrec @@ -21,7 +21,6 @@ import scala.annotation.varargs import org.apache.pekko import pekko.japi.Creator -import pekko.util.Reflect /** * Java API: Factory for Props instances. @@ -48,39 +47,6 @@ private[pekko] trait AbstractProps { def create(clazz: Class[_], args: AnyRef*): Props = new Props(deploy = Props.defaultDeploy, clazz = clazz, args = args.toList) - /** - * Create new Props from the given [[pekko.japi.Creator]]. - * - * You can not use a Java 8 lambda with this method since the generated classes - * don't carry enough type information. - * - * Use the Props.create(actorClass, creator) instead. - */ - @deprecated("Use Props.create(actorClass, creator) instead, since this can't be used with Java 8 lambda.", - "Akka 2.5.18") - def create[T <: Actor](creator: Creator[T]): Props = { - val cc = creator.getClass - checkCreatorClosingOver(cc) - - val ac = classOf[Actor] - val coc = classOf[Creator[_]] - val actorClass = Reflect.findMarker(cc, coc) match { - case t: ParameterizedType => - t.getActualTypeArguments.head match { - case c: Class[_] => c // since T <: Actor - case v: TypeVariable[_] => - v.getBounds.collectFirst { case c: Class[_] if ac.isAssignableFrom(c) && c != ac => c }.getOrElse(ac) - case x => throw new IllegalArgumentException(s"unsupported type found in Creator argument [$x]") - } - case c: Class[_] if c == coc => - throw new IllegalArgumentException( - "erased Creator types (e.g. lambdas) are unsupported, use Props.create(actorClass, creator) instead") - case unexpected => - throw new IllegalArgumentException(s"unexpected type: $unexpected") - } - create(classOf[CreatorConsumer], actorClass, creator) - } - /** * Create new Props from the given [[pekko.japi.Creator]] with the type set to the given actorClass. */ diff --git a/actor/src/main/scala/org/apache/pekko/actor/ActorRef.scala b/actor/src/main/scala/org/apache/pekko/actor/ActorRef.scala index 312fb08765..6136981c08 100644 --- a/actor/src/main/scala/org/apache/pekko/actor/ActorRef.scala +++ b/actor/src/main/scala/org/apache/pekko/actor/ActorRef.scala @@ -16,7 +16,6 @@ package org.apache.pekko.actor import java.util.concurrent.ConcurrentHashMap import scala.annotation.tailrec -import scala.annotation.nowarn import scala.collection.immutable import scala.util.control.NonFatal @@ -114,7 +113,6 @@ object ActorRef { * about the exact actor incarnation you can use the ``ActorPath`` as key because * the unique id of the actor is not taken into account when comparing actor paths. */ -@nowarn("msg=deprecated") abstract class ActorRef extends java.lang.Comparable[ActorRef] with Serializable { scalaRef: InternalActorRef with ActorRefScope => @@ -190,31 +188,6 @@ abstract class ActorRef extends java.lang.Comparable[ActorRef] with Serializable else s"Actor[$path#${path.uid}]" } -/** - * This trait represents the Scala Actor API - * There are implicit conversions in package.scala - * from ActorRef -> ScalaActorRef and back - */ -@deprecated("tell method is now provided by ActorRef trait", "Akka 2.6.13") -trait ScalaActorRef { ref: ActorRef with InternalActorRef with ActorRefScope => - - /** - * Sends a one-way asynchronous message. E.g. fire-and-forget semantics. - *

- * - * If invoked from within an actor then the actor reference is implicitly passed on as the implicit 'sender' argument. - *

- * - * This actor 'sender' reference is then available in the receiving actor in the 'sender()' member variable, - * if invoked from within an Actor. If not then no sender is available. - *

-   *   actor ! message
-   * 
- *

- */ - def !(message: Any)(implicit sender: ActorRef = Actor.noSender): Unit -} - /** * All ActorRefs have a scope which describes where they live. Since it is * often necessary to distinguish between local and non-local references, this @@ -263,8 +236,7 @@ private[pekko] trait RepointableRef extends ActorRefScope { * * DO NOT USE THIS UNLESS INTERNALLY WITHIN AKKA! */ -@nowarn("msg=deprecated") -@InternalApi private[pekko] abstract class InternalActorRef extends ActorRef with ScalaActorRef { this: ActorRefScope => +@InternalApi private[pekko] abstract class InternalActorRef extends ActorRef { this: ActorRefScope => /* * Actor life-cycle management, invoked only internally (in response to user requests via ActorContext). */ diff --git a/actor/src/main/scala/org/apache/pekko/actor/ActorSelection.scala b/actor/src/main/scala/org/apache/pekko/actor/ActorSelection.scala index 1747c218bf..049d39b9ce 100644 --- a/actor/src/main/scala/org/apache/pekko/actor/ActorSelection.scala +++ b/actor/src/main/scala/org/apache/pekko/actor/ActorSelection.scala @@ -98,33 +98,6 @@ abstract class ActorSelection extends Serializable { */ def resolveOne(timeout: FiniteDuration): Future[ActorRef] = resolveOne()(timeout) - /** - * Java API for [[#resolveOne]] - * - * Resolve the [[ActorRef]] matching this selection. - * The result is returned as a CompletionStage that is completed with the [[ActorRef]] - * if such an actor exists. It is completed with failure [[ActorNotFound]] if - * no such actor exists or the identification didn't complete within the - * supplied `timeout`. - */ - @deprecated("Use the overloaded method resolveOne which accepts java.time.Duration instead.", since = "Akka 2.5.20") - def resolveOneCS(timeout: FiniteDuration): CompletionStage[ActorRef] = { - import FutureConverters._ - resolveOne(timeout).asJava - } - - /** - * Java API for [[#resolveOne]] - * - * Resolve the [[ActorRef]] matching this selection. - * The result is returned as a CompletionStage that is completed with the [[ActorRef]] - * if such an actor exists. It is completed with failure [[ActorNotFound]] if - * no such actor exists or the identification didn't complete within the - * supplied `timeout`. - */ - @deprecated("Use the overloaded method resolveOne which accepts java.time.Duration instead.", since = "Akka 2.5.20") - def resolveOneCS(timeout: java.time.Duration): CompletionStage[ActorRef] = resolveOne(timeout) - /** * Java API for [[#resolveOne]] * diff --git a/actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala b/actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala index d0505e309e..7a3d68e9a5 100644 --- a/actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala +++ b/actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala @@ -423,8 +423,6 @@ object ActorSystem { final val UnstartedPushTimeout: Timeout = Timeout(config.getMillisDuration("pekko.actor.unstarted-push-timeout")) final val AllowJavaSerialization: Boolean = getBoolean("pekko.actor.allow-java-serialization") - @deprecated("Always enabled from Akka 2.6.0", "Akka 2.6.0") - final val EnableAdditionalSerializationBindings: Boolean = true final val SerializeAllMessages: Boolean = getBoolean("pekko.actor.serialize-messages") final val SerializeAllCreators: Boolean = getBoolean("pekko.actor.serialize-creators") final val NoSerializationVerificationNeededClassPrefix: Set[String] = diff --git a/actor/src/main/scala/org/apache/pekko/actor/CoordinatedShutdown.scala b/actor/src/main/scala/org/apache/pekko/actor/CoordinatedShutdown.scala index b2d09e5cf5..088b212568 100644 --- a/actor/src/main/scala/org/apache/pekko/actor/CoordinatedShutdown.scala +++ b/actor/src/main/scala/org/apache/pekko/actor/CoordinatedShutdown.scala @@ -388,7 +388,7 @@ final class CoordinatedShutdown private[pekko] ( phases: Map[String, CoordinatedShutdown.Phase], jvmShutdownHooks: JVMShutdownHooks = JVMShutdownHooks) extends Extension { - import CoordinatedShutdown.{ Reason, UnknownReason } + import CoordinatedShutdown.Reason /** INTERNAL API */ private[pekko] val log = Logging(system, classOf[CoordinatedShutdown]) @@ -697,9 +697,6 @@ final class CoordinatedShutdown private[pekko] ( */ def run(reason: Reason): Future[Done] = run(reason, None) - @deprecated("Use the method with `reason` parameter instead", since = "Akka 2.5.8") - def run(): Future[Done] = run(UnknownReason) - /** * Java API: Run tasks of all phases. The returned * `CompletionStage` is completed when all tasks have been completed, @@ -709,9 +706,6 @@ final class CoordinatedShutdown private[pekko] ( */ def runAll(reason: Reason): CompletionStage[Done] = run(reason).asJava - @deprecated("Use the method with `reason` parameter instead", since = "Akka 2.5.8") - def runAll(): CompletionStage[Done] = runAll(UnknownReason) - /** * Scala API: Run tasks of all phases including and after the given phase. * The returned `Future` is completed when all such tasks have been completed, @@ -784,10 +778,6 @@ final class CoordinatedShutdown private[pekko] ( runPromise.future } - @deprecated("Use the method with `reason` parameter instead", since = "Akka 2.5.8") - def run(fromPhase: Option[String]): Future[Done] = - run(UnknownReason, fromPhase) - /** * Java API: Run tasks of all phases including and after the given phase. * The returned `CompletionStage` is completed when all such tasks have been completed, @@ -798,10 +788,6 @@ final class CoordinatedShutdown private[pekko] ( def run(reason: Reason, fromPhase: Optional[String]): CompletionStage[Done] = run(reason, fromPhase.toScala).asJava - @deprecated("Use the method with `reason` parameter instead", since = "Akka 2.5.8") - def run(fromPhase: Optional[String]): CompletionStage[Done] = - run(UnknownReason, fromPhase) - /** * The configured timeout for a given `phase`. * For example useful as timeout when actor `ask` requests diff --git a/actor/src/main/scala/org/apache/pekko/actor/FSM.scala b/actor/src/main/scala/org/apache/pekko/actor/FSM.scala index 856629aed7..e8a0ee4bae 100644 --- a/actor/src/main/scala/org/apache/pekko/actor/FSM.scala +++ b/actor/src/main/scala/org/apache/pekko/actor/FSM.scala @@ -593,25 +593,6 @@ trait FSM[S, D] extends Actor with Listeners with ActorLogging { def startSingleTimer(name: String, msg: Any, delay: FiniteDuration): Unit = startTimer(name, msg, delay, SingleMode) - /** - * Schedule named timer to deliver message after given delay, possibly repeating. - * Any existing timer with the same name will automatically be canceled before - * adding the new timer. - * @param name identifier to be used with cancelTimer() - * @param msg message to be delivered - * @param timeout delay of first message delivery and between subsequent messages - * @param repeat send once if false, scheduleAtFixedRate if true - */ - @deprecated( - "Use startSingleTimer, startTimerWithFixedDelay or startTimerAtFixedRate instead. This has the same semantics as " + - "startTimerAtFixedRate, but startTimerWithFixedDelay is often preferred.", - since = "Akka 2.6.0") - final def setTimer(name: String, msg: Any, timeout: FiniteDuration, repeat: Boolean = false): Unit = { - // repeat => FixedRateMode for compatibility - val mode = if (repeat) FixedRateMode else SingleMode - startTimer(name, msg, timeout, mode) - } - private def startTimer(name: String, msg: Any, timeout: FiniteDuration, mode: TimerMode): Unit = { if (debugEvent) log.debug("setting " + (if (mode.repeat) "repeating " else "") + "timer '" + name + "'/" + timeout + ": " + msg) 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 fc2cd09149..2ef65db11e 100644 --- a/actor/src/main/scala/org/apache/pekko/actor/Scheduler.scala +++ b/actor/src/main/scala/org/apache/pekko/actor/Scheduler.scala @@ -363,36 +363,6 @@ trait Scheduler { } }) - /** - * 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") - final def schedule( - initialDelay: java.time.Duration, - interval: java.time.Duration, - receiver: ActorRef, - message: Any, - executor: ExecutionContext, - sender: ActorRef): Cancellable = { - import JavaDurationConverters._ - schedule(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") - final def schedule(initialDelay: FiniteDuration, interval: FiniteDuration)(f: => Unit)( - implicit - executor: ExecutionContext): Cancellable = - schedule(initialDelay, interval, new Runnable { override def run(): Unit = f }) - /** * Deprecated API: See [[Scheduler#scheduleWithFixedDelay]] or [[Scheduler#scheduleAtFixedRate]]. */ @@ -403,19 +373,6 @@ trait Scheduler { def schedule(initialDelay: FiniteDuration, interval: FiniteDuration, runnable: Runnable)( implicit executor: ExecutionContext): Cancellable - /** - * 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: java.time.Duration, interval: java.time.Duration, runnable: Runnable)( - implicit executor: ExecutionContext): Cancellable = { - import JavaDurationConverters._ - schedule(initialDelay.asScala, interval.asScala, runnable) - } - /** * Scala API: Schedules a message to be sent once with a delay, i.e. a time period that has * to pass before the message is sent. diff --git a/actor/src/main/scala/org/apache/pekko/actor/Timers.scala b/actor/src/main/scala/org/apache/pekko/actor/Timers.scala index 7393eb097a..6a5eaae2c4 100644 --- a/actor/src/main/scala/org/apache/pekko/actor/Timers.scala +++ b/actor/src/main/scala/org/apache/pekko/actor/Timers.scala @@ -304,25 +304,6 @@ abstract class UntypedAbstractActorWithTimers extends UntypedAbstractActor with interval: java.time.Duration): Unit = startTimerAtFixedRate(key, msg, initialDelay.asScala, interval.asScala) - /** - * Deprecated API: See [[TimerScheduler#startTimerWithFixedDelay]] or [[TimerScheduler#startTimerAtFixedRate]]. - */ - @deprecated( - "Use startTimerWithFixedDelay or startTimerAtFixedRate instead. This has the same semantics as " + - "startTimerAtFixedRate, but startTimerWithFixedDelay is often preferred.", - since = "Akka 2.6.0") - def startPeriodicTimer(key: Any, msg: Any, interval: FiniteDuration): Unit - - /** - * Deprecated API: See [[TimerScheduler#startTimerWithFixedDelay]] or [[TimerScheduler#startTimerAtFixedRate]]. - */ - @deprecated( - "Use startTimerWithFixedDelay or startTimerAtFixedRate instead. This has the same semantics as " + - "startTimerAtFixedRate, but startTimerWithFixedDelay is often preferred.", - since = "Akka 2.6.0") - final def startPeriodicTimer(key: Any, msg: Any, interval: java.time.Duration): Unit = - startPeriodicTimer(key, msg, interval.asScala) - /** * Start a timer that will send `msg` once to the `self` actor after * the given `timeout`. diff --git a/actor/src/main/scala/org/apache/pekko/actor/dungeon/TimerSchedulerImpl.scala b/actor/src/main/scala/org/apache/pekko/actor/dungeon/TimerSchedulerImpl.scala index 0350996fee..f5a973ef63 100644 --- a/actor/src/main/scala/org/apache/pekko/actor/dungeon/TimerSchedulerImpl.scala +++ b/actor/src/main/scala/org/apache/pekko/actor/dungeon/TimerSchedulerImpl.scala @@ -79,9 +79,6 @@ import pekko.util.OptionVal override def startTimerWithFixedDelay(key: Any, msg: Any, initialDelay: FiniteDuration, delay: FiniteDuration): Unit = startTimer(key, msg, delay, FixedDelayMode(initialDelay)) - override def startPeriodicTimer(key: Any, msg: Any, interval: FiniteDuration): Unit = - startTimerAtFixedRate(key, msg, interval) - override def startSingleTimer(key: Any, msg: Any, timeout: FiniteDuration): Unit = startTimer(key, msg, timeout, SingleMode) diff --git a/actor/src/main/scala/org/apache/pekko/actor/package.scala b/actor/src/main/scala/org/apache/pekko/actor/package.scala deleted file mode 100644 index 6947d640d1..0000000000 --- a/actor/src/main/scala/org/apache/pekko/actor/package.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * license agreements; and to You under the Apache License, version 2.0: - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * This file is part of the Apache Pekko project, which was derived from Akka. - */ - -/* - * Copyright (C) 2009-2022 Lightbend Inc. - */ - -package org.apache.pekko - -import language.implicitConversions - -package object actor { - @deprecated("implicit conversion is obsolete", "Akka 2.6.13") - implicit final def actorRef2Scala(ref: ActorRef): ScalaActorRef = ref.asInstanceOf[ScalaActorRef] - @deprecated("implicit conversion is obsolete", "Akka 2.6.13") - implicit final def scala2ActorRef(ref: ScalaActorRef): ActorRef = ref.asInstanceOf[ActorRef] -} diff --git a/actor/src/main/scala/org/apache/pekko/dispatch/Future.scala b/actor/src/main/scala/org/apache/pekko/dispatch/Future.scala index 3099bcf6f9..a3e46c3966 100644 --- a/actor/src/main/scala/org/apache/pekko/dispatch/Future.scala +++ b/actor/src/main/scala/org/apache/pekko/dispatch/Future.scala @@ -23,10 +23,7 @@ import scala.concurrent.{ ExecutionContext, ExecutionContextExecutor, ExecutionC import scala.runtime.{ AbstractPartialFunction, BoxedUnit } import scala.util.{ Failure, Success, Try } -import scala.annotation.nowarn - import org.apache.pekko -import pekko.annotation.InternalApi import pekko.annotation.InternalStableApi import pekko.compat import pekko.dispatch.internal.SameThreadExecutionContext @@ -101,18 +98,6 @@ object ExecutionContexts { @InternalStableApi private[pekko] val parasitic: ExecutionContext = SameThreadExecutionContext() - /** - * INTERNAL API - */ - @InternalApi - @deprecated("Use ExecutionContexts.parasitic instead", "Akka 2.6.4") - private[pekko] object sameThreadExecutionContext extends ExecutionContext with BatchingExecutor { - override protected def unbatchedExecute(runnable: Runnable): Unit = parasitic.execute(runnable) - override protected def resubmitOnBlock: Boolean = false // No point since we execute on same thread - override def reportFailure(t: Throwable): Unit = - parasitic.reportFailure(t) - } - } /** @@ -226,8 +211,7 @@ object Futures { * This class contains bridge classes between Scala and Java. * Internal use only. */ -object japi { - @deprecated("Do not use this directly, use subclasses of this", "Akka 2.0") +private[dispatch] object japi { class CallbackBridge[-T] extends AbstractPartialFunction[T, BoxedUnit] { override final def isDefinedAt(t: T): Boolean = true override final def apply(t: T): BoxedUnit = { @@ -237,20 +221,17 @@ object japi { protected def internal(@unused result: T): Unit = () } - @deprecated("Do not use this directly, use 'Recover'", "Akka 2.0") class RecoverBridge[+T] extends AbstractPartialFunction[Throwable, T] { override final def isDefinedAt(t: Throwable): Boolean = true override final def apply(t: Throwable): T = internal(t) protected def internal(@unused result: Throwable): T = null.asInstanceOf[T] } - @deprecated("Do not use this directly, use subclasses of this", "Akka 2.0") class BooleanFunctionBridge[-T] extends scala.Function1[T, Boolean] { override final def apply(t: T): Boolean = internal(t) protected def internal(@unused result: T): Boolean = false } - @deprecated("Do not use this directly, use subclasses of this", "Akka 2.0") class UnitFunctionBridge[-T] extends (T => BoxedUnit) { final def apply$mcLJ$sp(l: Long): BoxedUnit = { internal(l.asInstanceOf[T]); BoxedUnit.UNIT } final def apply$mcLI$sp(i: Int): BoxedUnit = { internal(i.asInstanceOf[T]); BoxedUnit.UNIT } @@ -267,7 +248,6 @@ object japi { * * Java API */ -@nowarn("msg=deprecated") abstract class OnSuccess[-T] extends japi.CallbackBridge[T] { protected final override def internal(result: T) = onSuccess(result) @@ -285,7 +265,6 @@ abstract class OnSuccess[-T] extends japi.CallbackBridge[T] { * * Java API */ -@nowarn("msg=deprecated") abstract class OnFailure extends japi.CallbackBridge[Throwable] { protected final override def internal(failure: Throwable) = onFailure(failure) @@ -303,7 +282,6 @@ abstract class OnFailure extends japi.CallbackBridge[Throwable] { * * Java API */ -@nowarn("msg=deprecated") abstract class OnComplete[-T] extends japi.CallbackBridge[Try[T]] { protected final override def internal(value: Try[T]): Unit = value match { case Failure(t) => onComplete(t, null.asInstanceOf[T]) @@ -326,7 +304,6 @@ abstract class OnComplete[-T] extends japi.CallbackBridge[Try[T]] { * * Java API */ -@nowarn("msg=deprecated") abstract class Recover[+T] extends japi.RecoverBridge[T] { protected final override def internal(result: Throwable): T = recover(result) @@ -380,7 +357,6 @@ object Filter { * SAM (Single Abstract Method) class * Java API */ -@nowarn("msg=deprecated") abstract class Foreach[-T] extends japi.UnitFunctionBridge[T] { override final def internal(t: T): Unit = each(t) diff --git a/actor/src/main/scala/org/apache/pekko/event/Logging.scala b/actor/src/main/scala/org/apache/pekko/event/Logging.scala index c554a47929..e73e62da7b 100644 --- a/actor/src/main/scala/org/apache/pekko/event/Logging.scala +++ b/actor/src/main/scala/org/apache/pekko/event/Logging.scala @@ -1717,13 +1717,6 @@ object LogMarker { apply(name, properties.asScala.toMap) } - @deprecated("use org.apache.pekko.event.LogEventWithMarker#marker instead", since = "Akka 2.5.12") - def extractFromMDC(mdc: MDC): Option[String] = - mdc.get(MDCKey) match { - case Some(v) => Some(v.toString) - case None => None - } - private[pekko] final val Security = apply("SECURITY") /** diff --git a/actor/src/main/scala/org/apache/pekko/event/jul/JavaLogger.scala b/actor/src/main/scala/org/apache/pekko/event/jul/JavaLogger.scala deleted file mode 100644 index a89a26c234..0000000000 --- a/actor/src/main/scala/org/apache/pekko/event/jul/JavaLogger.scala +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * license agreements; and to You under the Apache License, version 2.0: - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * This file is part of the Apache Pekko project, which was derived from Akka. - */ - -/* - * Copyright (C) 2009-2022 Lightbend Inc. - */ - -package org.apache.pekko.event.jul - -import java.util.logging - -import org.apache.pekko -import pekko.actor.Actor -import pekko.actor.ActorSystem -import pekko.dispatch.RequiresMessageQueue -import pekko.event.DummyClassForStringSources -import pekko.event.EventStream -import pekko.event.LoggerMessageQueueSemantics -import pekko.event.Logging._ -import pekko.event.LoggingFilter -import pekko.util.unused - -/** - * `java.util.logging` logger. - */ -@deprecated("Use Slf4jLogger instead.", "Akka 2.6.0") -class JavaLogger extends Actor with RequiresMessageQueue[LoggerMessageQueueSemantics] { - import Logger.mapLevel - - def receive = { - case event @ Error(cause, _, _, _) => log(mapLevel(event.level), cause, event) - case event: Warning => log(mapLevel(event.level), null, event) - case event: Info => log(mapLevel(event.level), null, event) - case event: Debug => log(mapLevel(event.level), null, event) - case InitializeLogger(_) => - Logger(this.getClass.getName) - .warning(s"${getClass.getName} has been deprecated since Akka 2.6.0. Use SLF4J instead.") - sender() ! LoggerInitialized - } - - def log(level: logging.Level, cause: Throwable, event: LogEvent): Unit = { - val logger = Logger(event.logClass, event.logSource) - val record = new logging.LogRecord(level, String.valueOf(event.message)) - record.setLoggerName(logger.getName) - record.setThrown(cause) - record.setThreadID(event.thread.getId.toInt) - record.setSourceClassName(event.logClass.getName) - record.setSourceMethodName(null) // lost forever - logger.log(record) - } -} - -/** - * Base trait for all classes that wants to be able use the JUL logging infrastructure. - */ -@deprecated("Use SLF4J or direct java.util.logging instead.", "Akka 2.6.0") -trait JavaLogging { - @transient - lazy val log: logging.Logger = Logger(this.getClass.getName) -} - -/** - * Logger is a factory for obtaining JUL Loggers - */ -@deprecated("Use SLF4J or direct java.util.logging instead.", "Akka 2.6.0") -object Logger { - - /** - * @param logger - which logger - * @return a Logger that corresponds for the given logger name - */ - def apply(logger: String): logging.Logger = logging.Logger.getLogger(logger) - - /** - * @param logClass - the class to log for - * @param logSource - the textual representation of the source of this log stream - * @return a Logger for the specified parameters - */ - def apply(logClass: Class[_], logSource: String): logging.Logger = logClass match { - case c if c == classOf[DummyClassForStringSources] => apply(logSource) - case _ => logging.Logger.getLogger(logClass.getName) - } - - /** - * Returns the JUL Root Logger - */ - def root: logging.Logger = logging.Logger.getGlobal() - - def mapLevel(level: LogLevel): logging.Level = level.asInt match { - case InfoLevel.asInt => logging.Level.INFO - case DebugLevel.asInt => logging.Level.CONFIG - case WarningLevel.asInt => logging.Level.WARNING - case ErrorLevel.asInt => logging.Level.SEVERE - case _ => logging.Level.FINE - } -} - -/** - * [[pekko.event.LoggingFilter]] that uses the log level defined in the JUL - * backend configuration to filter log events before publishing - * the log events to the `eventStream`. - */ -@deprecated("Use Slf4jLoggingFilter instead.", "Akka 2.6.0") -class JavaLoggingFilter(@unused settings: ActorSystem.Settings, eventStream: EventStream) extends LoggingFilter { - import Logger.mapLevel - - def isErrorEnabled(logClass: Class[_], logSource: String) = - (eventStream.logLevel >= ErrorLevel) && Logger(logClass, logSource).isLoggable(mapLevel(ErrorLevel)) - def isWarningEnabled(logClass: Class[_], logSource: String) = - (eventStream.logLevel >= WarningLevel) && Logger(logClass, logSource).isLoggable(mapLevel(WarningLevel)) - def isInfoEnabled(logClass: Class[_], logSource: String) = - (eventStream.logLevel >= InfoLevel) && Logger(logClass, logSource).isLoggable(mapLevel(InfoLevel)) - def isDebugEnabled(logClass: Class[_], logSource: String) = - (eventStream.logLevel >= DebugLevel) && Logger(logClass, logSource).isLoggable(mapLevel(DebugLevel)) -} diff --git a/actor/src/main/scala/org/apache/pekko/io/DnsProvider.scala b/actor/src/main/scala/org/apache/pekko/io/DnsProvider.scala index 297f8e936c..864f1bbf40 100644 --- a/actor/src/main/scala/org/apache/pekko/io/DnsProvider.scala +++ b/actor/src/main/scala/org/apache/pekko/io/DnsProvider.scala @@ -15,16 +15,15 @@ package org.apache.pekko.io import org.apache.pekko import pekko.actor.Actor +import pekko.annotation.InternalApi /** * Where as it is possible to plug in alternative DNS implementations it is not recommended. * - * It is expected that this will be deprecated/removed in future Apache Pekko versions - * - * TODO make private and remove deprecated in v1.1.0 + * Internal API */ -@deprecated("Overriding the DNS implementation will be removed in future versions of Apache Pekko", "Akka 2.6.0") -trait DnsProvider { +@InternalApi +private[pekko] trait DnsProvider { /** * Cache implementation that can be accessed via Dns(system) to avoid asks to the resolver actors. diff --git a/actor/src/main/scala/org/apache/pekko/io/Tcp.scala b/actor/src/main/scala/org/apache/pekko/io/Tcp.scala index ca56d75ee4..d8ad5d52ff 100644 --- a/actor/src/main/scala/org/apache/pekko/io/Tcp.scala +++ b/actor/src/main/scala/org/apache/pekko/io/Tcp.scala @@ -366,15 +366,6 @@ object Tcp extends ExtensionId[TcpExt] with ExtensionIdProvider { if (data.isEmpty) empty else Write(data, NoAck) } - /** - * @see [[WritePath]] - */ - @deprecated("Use WritePath instead", "Akka 2.5.10") - final case class WriteFile(filePath: String, position: Long, count: Long, ack: Event) extends SimpleWriteCommand { - require(position >= 0, "WriteFile.position must be >= 0") - require(count > 0, "WriteFile.count must be > 0") - } - /** * Write `count` bytes starting at `position` from file at `filePath` to the connection. * The count must be > 0. The connection actor will reply with a [[CommandFailed]] diff --git a/actor/src/main/scala/org/apache/pekko/io/TcpConnection.scala b/actor/src/main/scala/org/apache/pekko/io/TcpConnection.scala index 3359eced6c..a9eb09fc5a 100644 --- a/actor/src/main/scala/org/apache/pekko/io/TcpConnection.scala +++ b/actor/src/main/scala/org/apache/pekko/io/TcpConnection.scala @@ -18,7 +18,7 @@ import java.net.{ InetSocketAddress, SocketException } import java.nio.ByteBuffer import java.nio.channels.{ FileChannel, SocketChannel } import java.nio.channels.SelectionKey._ -import java.nio.file.{ Path, Paths } +import java.nio.file.Path import scala.annotation.tailrec import scala.collection.immutable @@ -434,14 +434,11 @@ private[io] abstract class TcpConnection(val tcp: TcpExt, val channel: SocketCha override def postRestart(reason: Throwable): Unit = throw new IllegalStateException("Restarting not supported for connection actors.") - @nowarn("cat=deprecation") def PendingWrite(commander: ActorRef, write: WriteCommand): PendingWrite = { @tailrec def create(head: WriteCommand, tail: WriteCommand): PendingWrite = head match { case Write.empty => if (tail eq Write.empty) EmptyPendingWrite else create(tail, Write.empty) case Write(data, ack) if data.nonEmpty => PendingBufferWrite(commander, data, ack, tail) - case WriteFile(path, offset, count, ack) => - PendingWriteFile(commander, Paths.get(path), offset, count, ack, tail) case WritePath(path, offset, count, ack) => PendingWriteFile(commander, path, offset, count, ack, tail) case CompoundWrite(h, t) => create(h, t) diff --git a/actor/src/main/scala/org/apache/pekko/pattern/BackoffSupervisor.scala b/actor/src/main/scala/org/apache/pekko/pattern/BackoffSupervisor.scala index 4584692afe..ca1c9810ab 100644 --- a/actor/src/main/scala/org/apache/pekko/pattern/BackoffSupervisor.scala +++ b/actor/src/main/scala/org/apache/pekko/pattern/BackoffSupervisor.scala @@ -15,227 +15,12 @@ package org.apache.pekko.pattern import java.util.Optional -import scala.concurrent.duration.{ Duration, FiniteDuration } - import org.apache.pekko -import pekko.actor.{ ActorRef, DeadLetterSuppression, OneForOneStrategy, Props, SupervisorStrategy } +import pekko.actor.{ ActorRef, DeadLetterSuppression, Props } import pekko.annotation.InternalApi -import pekko.pattern.internal.BackoffOnStopSupervisor -import pekko.util.JavaDurationConverters._ object BackoffSupervisor { - /** - * Props for creating a `BackoffSupervisor` actor. - * - * Exceptions in the child are handled with the default supervision strategy, i.e. - * most exceptions will immediately restart the child. You can define another - * supervision strategy by using [[#propsWithSupervisorStrategy]]. - * - * @param childProps the [[pekko.actor.Props]] of the child actor that - * will be started and supervised - * @param childName name of the child actor - * @param minBackoff minimum (initial) duration until the child actor will - * started again, if it is terminated - * @param maxBackoff the exponential back-off is capped to this duration - * @param randomFactor after calculation of the exponential back-off an additional - * random delay based on this factor is added, e.g. `0.2` adds up to `20%` delay. - * In order to skip this additional delay pass in `0`. - */ - @deprecated("Use props with BackoffOpts instead", since = "Akka 2.5.22") - def props( - childProps: Props, - childName: String, - minBackoff: FiniteDuration, - maxBackoff: FiniteDuration, - randomFactor: Double): Props = { - propsWithSupervisorStrategy( - childProps, - childName, - minBackoff, - maxBackoff, - randomFactor, - SupervisorStrategy.defaultStrategy) - } - - /** - * Props for creating a `BackoffSupervisor` actor. - * - * Exceptions in the child are handled with the default supervision strategy, i.e. - * most exceptions will immediately restart the child. You can define another - * supervision strategy by using [[#propsWithSupervisorStrategy]]. - * - * @param childProps the [[pekko.actor.Props]] of the child actor that - * will be started and supervised - * @param childName name of the child actor - * @param minBackoff minimum (initial) duration until the child actor will - * started again, if it is terminated - * @param maxBackoff the exponential back-off is capped to this duration - * @param randomFactor after calculation of the exponential back-off an additional - * random delay based on this factor is added, e.g. `0.2` adds up to `20%` delay. - * In order to skip this additional delay pass in `0`. - * @param maxNrOfRetries maximum number of attempts to restart the child actor. - * The supervisor will terminate itself after the maxNoOfRetries is reached. - * In order to restart infinitely pass in `-1`. - */ - @deprecated("Use props with BackoffOpts instead", since = "Akka 2.5.22") - def props( - childProps: Props, - childName: String, - minBackoff: FiniteDuration, - maxBackoff: FiniteDuration, - randomFactor: Double, - maxNrOfRetries: Int): Props = { - val supervisionStrategy = SupervisorStrategy.defaultStrategy match { - case oneForOne: OneForOneStrategy => oneForOne.withMaxNrOfRetries(maxNrOfRetries) - case s => s - } - propsWithSupervisorStrategy(childProps, childName, minBackoff, maxBackoff, randomFactor, supervisionStrategy) - } - - /** - * Props for creating a `BackoffSupervisor` actor. - * - * Exceptions in the child are handled with the default supervision strategy, i.e. - * most exceptions will immediately restart the child. You can define another - * supervision strategy by using [[#propsWithSupervisorStrategy]]. - * - * @param childProps the [[pekko.actor.Props]] of the child actor that - * will be started and supervised - * @param childName name of the child actor - * @param minBackoff minimum (initial) duration until the child actor will - * started again, if it is terminated - * @param maxBackoff the exponential back-off is capped to this duration - * @param randomFactor after calculation of the exponential back-off an additional - * random delay based on this factor is added, e.g. `0.2` adds up to `20%` delay. - * In order to skip this additional delay pass in `0`. - */ - @deprecated("Use props with BackoffOpts instead", since = "Akka 2.5.22") - def props( - childProps: Props, - childName: String, - minBackoff: java.time.Duration, - maxBackoff: java.time.Duration, - randomFactor: Double): Props = { - props(childProps, childName, minBackoff.asScala, maxBackoff.asScala, randomFactor) - } - - /** - * Props for creating a `BackoffSupervisor` actor. - * - * Exceptions in the child are handled with the default supervision strategy, i.e. - * most exceptions will immediately restart the child. You can define another - * supervision strategy by using [[#propsWithSupervisorStrategy]]. - * - * @param childProps the [[pekko.actor.Props]] of the child actor that - * will be started and supervised - * @param childName name of the child actor - * @param minBackoff minimum (initial) duration until the child actor will - * started again, if it is terminated - * @param maxBackoff the exponential back-off is capped to this duration - * @param randomFactor after calculation of the exponential back-off an additional - * random delay based on this factor is added, e.g. `0.2` adds up to `20%` delay. - * In order to skip this additional delay pass in `0`. - * @param maxNrOfRetries maximum number of attempts to restart the child actor. - * The supervisor will terminate itself after the maxNoOfRetries is reached. - * In order to restart infinitely pass in `-1`. - */ - @deprecated("Use props with BackoffOpts instead", since = "Akka 2.5.22") - def props( - childProps: Props, - childName: String, - minBackoff: java.time.Duration, - maxBackoff: java.time.Duration, - randomFactor: Double, - maxNrOfRetries: Int): Props = { - props(childProps, childName, minBackoff.asScala, maxBackoff.asScala, randomFactor, maxNrOfRetries) - } - - /** - * Props for creating a `BackoffSupervisor` actor with a custom - * supervision strategy. - * - * Exceptions in the child are handled with the given `supervisionStrategy`. A - * `Restart` will perform a normal immediate restart of the child. A `Stop` will - * stop the child, but it will be started again after the back-off duration. - * - * @param childProps the [[pekko.actor.Props]] of the child actor that - * will be started and supervised - * @param childName name of the child actor - * @param minBackoff minimum (initial) duration until the child actor will - * started again, if it is terminated - * @param maxBackoff the exponential back-off is capped to this duration - * @param randomFactor after calculation of the exponential back-off an additional - * random delay based on this factor is added, e.g. `0.2` adds up to `20%` delay. - * In order to skip this additional delay pass in `0`. - * @param strategy the supervision strategy to use for handling exceptions - * in the child. As the BackoffSupervisor creates a separate actor to handle the - * backoff process, only a [[OneForOneStrategy]] makes sense here. - */ - @deprecated("Use props with BackoffOpts instead", since = "Akka 2.5.22") - def propsWithSupervisorStrategy( - childProps: Props, - childName: String, - minBackoff: FiniteDuration, - maxBackoff: FiniteDuration, - randomFactor: Double, - strategy: SupervisorStrategy): Props = { - require(minBackoff > Duration.Zero, "minBackoff must be > 0") - require(maxBackoff >= minBackoff, "maxBackoff must be >= minBackoff") - require(0.0 <= randomFactor && randomFactor <= 1.0, "randomFactor must be between 0.0 and 1.0") - Props( - new BackoffOnStopSupervisor( - childProps, - childName, - minBackoff, - maxBackoff, - AutoReset(minBackoff), - randomFactor, - strategy, - ForwardDeathLetters, - None)) - } - - /** - * Props for creating a `BackoffSupervisor` actor with a custom - * supervision strategy. - * - * Exceptions in the child are handled with the given `supervisionStrategy`. A - * `Restart` will perform a normal immediate restart of the child. A `Stop` will - * stop the child, but it will be started again after the back-off duration. - * - * @param childProps the [[pekko.actor.Props]] of the child actor that - * will be started and supervised - * @param childName name of the child actor - * @param minBackoff minimum (initial) duration until the child actor will - * started again, if it is terminated - * @param maxBackoff the exponential back-off is capped to this duration - * @param randomFactor after calculation of the exponential back-off an additional - * random delay based on this factor is added, e.g. `0.2` adds up to `20%` delay. - * In order to skip this additional delay pass in `0`. - * @param strategy the supervision strategy to use for handling exceptions - * in the child. As the BackoffSupervisor creates a separate actor to handle the - * backoff process, only a [[OneForOneStrategy]] makes sense here. - */ - @deprecated("Use props with BackoffOpts instead", since = "Akka 2.5.22") - def propsWithSupervisorStrategy( - childProps: Props, - childName: String, - minBackoff: java.time.Duration, - maxBackoff: java.time.Duration, - randomFactor: Double, - strategy: SupervisorStrategy): Props = { - propsWithSupervisorStrategy(childProps, childName, minBackoff.asScala, maxBackoff.asScala, randomFactor, strategy) - } - - /** - * Props for creating a `BackoffSupervisor` actor from [[BackoffOptions]]. - * - * @param options the [[BackoffOptions]] that specify how to construct a backoff-supervisor. - */ - @deprecated("Use new API from BackoffOpts object instead", since = "Akka 2.5.22") - def props(options: BackoffOptions): Props = options.props - /** * Props for creating a `BackoffSupervisor` actor from [[BackoffOnStopOptions]]. * @@ -312,68 +97,3 @@ object BackoffSupervisor { @InternalApi private[pekko] case class ResetRestartCount(current: Int) extends DeadLetterSuppression } - -final class BackoffSupervisor @deprecated("Use `BackoffSupervisor.props` method instead", since = "Akka 2.5.22") ( - override val childProps: Props, - override val childName: String, - minBackoff: FiniteDuration, - maxBackoff: FiniteDuration, - override val reset: BackoffReset, - randomFactor: Double, - strategy: SupervisorStrategy, - val replyWhileStopped: Option[Any], - val finalStopMessage: Option[Any => Boolean]) - extends BackoffOnStopSupervisor( - childProps, - childName, - minBackoff, - maxBackoff, - reset, - randomFactor, - strategy, - replyWhileStopped.map(msg => ReplyWith(msg)).getOrElse(ForwardDeathLetters), - finalStopMessage) { - - // for binary compatibility with 2.5.18 - @deprecated("Use `BackoffSupervisor.props` method instead", since = "Akka 2.5.22") - def this( - childProps: Props, - childName: String, - minBackoff: FiniteDuration, - maxBackoff: FiniteDuration, - reset: BackoffReset, - randomFactor: Double, - strategy: SupervisorStrategy, - replyWhileStopped: Option[Any]) = - this(childProps, childName, minBackoff, maxBackoff, reset, randomFactor, strategy, replyWhileStopped, None) - - // for binary compatibility with 2.4.1 - @deprecated("Use `BackoffSupervisor.props` method instead", since = "Akka 2.5.22") - def this( - childProps: Props, - childName: String, - minBackoff: FiniteDuration, - maxBackoff: FiniteDuration, - randomFactor: Double, - supervisorStrategy: SupervisorStrategy) = - this( - childProps, - childName, - minBackoff, - maxBackoff, - AutoReset(minBackoff), - randomFactor, - supervisorStrategy, - None, - None) - - // for binary compatibility with 2.4.0 - @deprecated("Use `BackoffSupervisor.props` method instead", since = "Akka 2.5.22") - def this( - childProps: Props, - childName: String, - minBackoff: FiniteDuration, - maxBackoff: FiniteDuration, - randomFactor: Double) = - this(childProps, childName, minBackoff, maxBackoff, randomFactor, SupervisorStrategy.defaultStrategy) -} diff --git a/actor/src/main/scala/org/apache/pekko/pattern/CircuitBreaker.scala b/actor/src/main/scala/org/apache/pekko/pattern/CircuitBreaker.scala index 00dcbeb260..cd4a130e6b 100644 --- a/actor/src/main/scala/org/apache/pekko/pattern/CircuitBreaker.scala +++ b/actor/src/main/scala/org/apache/pekko/pattern/CircuitBreaker.scala @@ -67,26 +67,6 @@ object CircuitBreaker { def apply(id: String)(implicit system: ExtendedActorSystem): CircuitBreaker = CircuitBreakersRegistry(system).get(id) - /** - * Java API: Create a new CircuitBreaker. - * - * Callbacks run in caller's thread when using withSyncCircuitBreaker, and in same ExecutionContext as the passed - * in Future when using withCircuitBreaker. To use another ExecutionContext for the callbacks you can specify the - * executor in the constructor. - * - * @param scheduler Reference to Pekko scheduler - * @param maxFailures Maximum number of failures before opening the circuit - * @param callTimeout [[scala.concurrent.duration.FiniteDuration]] of time after which to consider a call a failure - * @param resetTimeout [[scala.concurrent.duration.FiniteDuration]] of time after which to attempt to close the circuit - */ - @deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.12") - def create( - scheduler: Scheduler, - maxFailures: Int, - callTimeout: FiniteDuration, - resetTimeout: FiniteDuration): CircuitBreaker = - apply(scheduler, maxFailures, callTimeout, resetTimeout) - /** * Java API: Create a new CircuitBreaker. * @@ -183,23 +163,6 @@ class CircuitBreaker( CircuitBreakerNoopTelemetry)(executor) } - @deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.12") - def this( - executor: ExecutionContext, - scheduler: Scheduler, - maxFailures: Int, - callTimeout: FiniteDuration, - resetTimeout: FiniteDuration) = { - this( - scheduler, - maxFailures, - callTimeout, - resetTimeout, - maxResetTimeout = 36500.days, - exponentialBackoffFactor = 1.0, - randomFactor = 0.0)(executor) - } - def this( executor: ExecutionContext, scheduler: Scheduler, diff --git a/actor/src/main/scala/org/apache/pekko/serialization/Serialization.scala b/actor/src/main/scala/org/apache/pekko/serialization/Serialization.scala index 30609b7e79..bc24f0b14f 100644 --- a/actor/src/main/scala/org/apache/pekko/serialization/Serialization.scala +++ b/actor/src/main/scala/org/apache/pekko/serialization/Serialization.scala @@ -178,28 +178,6 @@ class Serialization(val system: ExtendedActorSystem) extends Extension { } } - /** - * Deserializes the given array of bytes using the specified serializer id, - * using the optional type hint to the Serializer. - * Returns either the resulting object or an Exception if one was thrown. - */ - @deprecated("Use deserialize that accepts the `manifest` as a class name.", since = "Akka 2.6.0") - def deserialize[T](bytes: Array[Byte], serializerId: Int, clazz: Option[Class[_ <: T]]): Try[T] = - Try { - val serializer = - try getSerializerById(serializerId) - catch { - case _: NoSuchElementException => - throw new NotSerializableException( - s"Cannot find serializer with id [$serializerId]${clazz.map(c => " (class [" + c.getName + "])").getOrElse("")}. " + - "The most probable reason is that the configuration entry " + - "pekko.actor.serializers is not in sync between the two systems.") - } - withTransportInformation { () => - serializer.fromBinary(bytes, clazz).asInstanceOf[T] - } - } - /** * Deserializes the given array of bytes using the specified serializer id, * using the optional type hint to the Serializer. diff --git a/cluster-tools/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes b/cluster-tools/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes new file mode 100644 index 0000000000..f6aeb0b6fb --- /dev/null +++ b/cluster-tools/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes @@ -0,0 +1,19 @@ +# 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 methods +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.cluster.singleton.ClusterSingletonManager.setTimer*") diff --git a/remote/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes b/remote/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes new file mode 100644 index 0000000000..3641a5f9d7 --- /dev/null +++ b/remote/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes @@ -0,0 +1,19 @@ +# 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 methods +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.remote.RemoteActorRefProvider#RemotingTerminator.setTimer*") 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 new file mode 100644 index 0000000000..42eb361b43 --- /dev/null +++ b/testkit/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.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 deprecated methods +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.ExplicitlyTriggeredScheduler.schedule") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.TestFSMRef.setTimer*") diff --git a/testkit/src/main/scala/org/apache/pekko/testkit/TestFSMRef.scala b/testkit/src/main/scala/org/apache/pekko/testkit/TestFSMRef.scala index 57ea08b0b0..50b5af67be 100644 --- a/testkit/src/main/scala/org/apache/pekko/testkit/TestFSMRef.scala +++ b/testkit/src/main/scala/org/apache/pekko/testkit/TestFSMRef.scala @@ -89,17 +89,6 @@ class TestFSMRef[S, D, T <: Actor](system: ActorSystem, props: Props, supervisor def startSingleTimer(name: String, msg: Any, delay: FiniteDuration): Unit = fsm.startSingleTimer(name, msg, delay) - /** - * Proxy for [[pekko.actor.FSM#setTimer]]. - */ - @deprecated( - "Use startTimerWithFixedDelay or startTimerAtFixedRate instead. This has the same semantics as " + - "startTimerAtFixedRate, but startTimerWithFixedDelay is often preferred.", - since = "Akka 2.6.0") - def setTimer(name: String, msg: Any, timeout: FiniteDuration, repeat: Boolean = false): Unit = { - fsm.setTimer(name, msg, timeout, repeat) - } - /** * Proxy for [[pekko.actor.FSM#cancelTimer]]. */