From 5b2aab6f7a68f190dc022007ec24d1b22cc59438 Mon Sep 17 00:00:00 2001 From: "scala-steward-asf[bot]" <147768647+scala-steward-asf[bot]@users.noreply.github.com> Date: Sat, 18 Jan 2025 10:36:38 +0800 Subject: [PATCH] Update scalafmt-core to 3.8.4 (#1717) * Update scalafmt-core to 3.8.4 * Reformat with scalafmt 3.8.4 Executed command: scalafmt --non-interactive * Add 'Reformat with scalafmt 3.8.4' to .git-blame-ignore-revs * remove postfixOps imports Assuming we want to keep the default `rewrite.avoidInfix.excludePostfix = false` - otherwise we can drop this commit --------- Co-authored-by: scala-steward-asf[bot] <147768647+scala-steward-asf[bot]@users.noreply.github.com> Co-authored-by: Arnout Engelen --- .git-blame-ignore-revs | 3 + .scalafmt.conf | 2 +- .../ActorConfigurationVerificationSpec.scala | 3 +- .../pekko/actor/ActorCreationPerfSpec.scala | 11 ++- .../org/apache/pekko/actor/ActorRefSpec.scala | 8 +-- .../apache/pekko/actor/ActorSystemSpec.scala | 15 ++-- .../actor/ActorWithBoundedStashSpec.scala | 5 +- .../pekko/actor/ActorWithStashSpec.scala | 9 ++- .../apache/pekko/actor/ConsistencySpec.scala | 4 +- .../apache/pekko/actor/DeathWatchSpec.scala | 7 +- .../org/apache/pekko/actor/DeployerSpec.scala | 5 +- .../org/apache/pekko/actor/FSMActorSpec.scala | 37 +++++----- .../apache/pekko/actor/FSMTimingSpec.scala | 46 ++++++------ .../pekko/actor/FSMTransitionSpec.scala | 13 ++-- .../apache/pekko/actor/ForwardActorSpec.scala | 8 +-- .../actor/LocalActorRefProviderSpec.scala | 5 +- .../pekko/actor/ReceiveTimeoutSpec.scala | 22 +++--- .../pekko/actor/RestartStrategySpec.scala | 43 ++++++----- .../apache/pekko/actor/SchedulerSpec.scala | 23 +++--- .../pekko/actor/SupervisorHierarchySpec.scala | 13 ++-- .../pekko/actor/SupervisorMiscSpec.scala | 3 +- .../apache/pekko/actor/SupervisorSpec.scala | 19 +++-- .../pekko/actor/SupervisorTreeSpec.scala | 8 +-- .../apache/pekko/actor/Ticket669Spec.scala | 3 +- .../apache/pekko/actor/TypedActorSpec.scala | 33 +++++---- .../pekko/actor/dispatch/ActorModelSpec.scala | 7 +- .../actor/dispatch/DispatcherActorSpec.scala | 4 +- .../apache/pekko/dataflow/Future2Actor.scala | 8 +-- .../pekko/dispatch/MailboxConfigSpec.scala | 15 ++-- .../dispatch/PriorityDispatcherSpec.scala | 5 +- .../StablePriorityDispatcherSpec.scala | 7 +- .../pekko/event/LoggingReceiveSpec.scala | 13 ++-- .../apache/pekko/io/TcpIntegrationSpec.scala | 3 +- .../org/apache/pekko/pattern/AskSpec.scala | 68 +++++++++--------- .../BackoffOnRestartSupervisorSpec.scala | 27 ++++--- .../pekko/pattern/CircuitBreakerSpec.scala | 3 +- .../apache/pekko/pattern/PatternSpec.scala | 16 ++--- .../org/apache/pekko/pattern/RetrySpec.scala | 38 +++++----- .../routing/ConfiguredLocalRoutingSpec.scala | 13 ++-- .../org/apache/pekko/routing/RandomSpec.scala | 12 ++-- .../apache/pekko/routing/ResizerSpec.scala | 15 ++-- .../apache/pekko/routing/RoundRobinSpec.scala | 14 ++-- .../apache/pekko/routing/RoutingSpec.scala | 3 +- .../pekko/serialization/SerializeSpec.scala | 3 +- .../org/apache/pekko/util/DurationSpec.scala | 14 ++-- .../actor/typed/delivery/TestConsumer.scala | 3 +- .../pekko/io/DirectByteBufferPool.scala | 4 +- .../pekko/cluster/metrics/Provision.scala | 3 +- .../metrics/ClusterMetricsExtensionSpec.scala | 5 +- .../metrics/ClusterMetricsRoutingSpec.scala | 3 +- .../metrics/sample/StatsSampleSpec.scala | 7 +- .../metrics/ClusterMetricsExtensionSpec.scala | 5 +- .../metrics/ClusterMetricsSettingsSpec.scala | 9 ++- .../metrics/MetricsCollectorSpec.scala | 3 +- .../pekko/cluster/metrics/TestUtil.scala | 4 +- ...ndomizedBrainResolverIntegrationSpec.scala | 4 +- .../sharding/ClusterShardingSpec.scala | 49 +++++++------ .../cluster/client/ClusterClientSpec.scala | 13 ++-- .../DistributedPubSubMediatorSpec.scala | 31 ++++---- .../pubsub/DistributedPubSubRestartSpec.scala | 5 +- .../ClusterSingletonManagerChaosSpec.scala | 5 +- .../ClusterSingletonManagerSpec.scala | 17 +++-- .../apache/pekko/cluster/ClusterEvent.scala | 7 +- .../org/apache/pekko/cluster/Member.scala | 3 +- .../cluster/sbr/SplitBrainResolver.scala | 3 +- .../pekko/cluster/ClusterDeathWatchSpec.scala | 9 ++- .../pekko/cluster/ConvergenceSpec.scala | 3 +- .../pekko/cluster/InitialHeartbeatSpec.scala | 7 +- ...aderDowningNodeThatIsUnreachableSpec.scala | 3 +- .../pekko/cluster/LeaderElectionSpec.scala | 6 +- .../org/apache/pekko/cluster/MBeanSpec.scala | 7 +- .../pekko/cluster/MemberWeaklyUpSpec.scala | 7 +- .../cluster/RestartFirstSeedNodeSpec.scala | 5 +- .../apache/pekko/cluster/SplitBrainSpec.scala | 3 +- .../org/apache/pekko/cluster/StressSpec.scala | 3 +- .../UnreachableNodeJoinsAgainSpec.scala | 13 ++-- .../routing/ClusterRoundRobinSpec.scala | 3 +- .../cluster/routing/UseRoleIgnoredSpec.scala | 3 +- .../pekko/cluster/ClusterConfigSpec.scala | 25 ++++--- .../test/scala/docs/actor/ActorDocSpec.scala | 21 +++--- .../test/scala/docs/actor/FSMDocSpec.scala | 8 +-- .../docs/actor/FaultHandlingDocSample.scala | 12 ++-- .../docs/actor/FaultHandlingDocSpec.scala | 7 +- .../scala/docs/actor/SchedulerDocSpec.scala | 8 +-- .../actor/SharedMutableStateDocSpec.scala | 1 - .../docs/cluster/TransformationBackend.scala | 1 - .../docs/cluster/TransformationFrontend.scala | 1 - .../docs/dispatcher/DispatcherDocSpec.scala | 2 - .../src/test/scala/docs/duration/Sample.scala | 4 +- .../scala/docs/future/FutureDocSpec.scala | 57 ++++++++------- .../docs/persistence/PersistenceDocSpec.scala | 1 - .../operators/sourceorflow/FoldAsync.scala | 3 +- .../scala/docs/testkit/TestKitUsageSpec.scala | 12 ++-- .../scala/docs/testkit/TestkitDocSpec.scala | 15 ++-- .../remote/testconductor/Conductor.scala | 3 +- .../javadsl/CommandHandlerWithReply.scala | 3 +- .../AtLeastOnceDeliveryFailureSpec.scala | 3 +- .../SnapshotFailureRobustnessSpec.scala | 3 +- .../persistence/fsm/PersistentFSMSpec.scala | 37 +++++----- .../pekko/remote/NewRemoteActorSpec.scala | 3 +- .../pekko/remote/RemoteDeliverySpec.scala | 3 +- .../RemoteDeploymentDeathWatchSpec.scala | 3 +- .../remote/RemoteNodeDeathWatchSpec.scala | 71 +++++++++---------- .../RemoteRestartedQuarantinedSpec.scala | 3 +- .../RemoteNodeShutdownAndComesBackSpec.scala | 3 +- .../remote/routing/RemoteRoundRobinSpec.scala | 7 +- .../testconductor/TestConductorSpec.scala | 11 ++- .../remote/testconductor/BarrierSpec.scala | 48 ++++++------- .../pekko/remote/RemoteConfigSpec.scala | 32 ++++----- .../remote/artery/RemoteWatcherSpec.scala | 69 +++++++++--------- .../remote/classic/RemoteInitErrorSpec.scala | 3 +- .../remote/classic/RemoteWatcherSpec.scala | 69 +++++++++--------- .../pekko/event/slf4j/Slf4jLoggerSpec.scala | 29 ++++---- .../stream/scaladsl/GraphZipLatestSpec.scala | 7 +- .../scaladsl/GraphZipLatestWithSpec.scala | 5 +- .../scaladsl/SinkForeachAsyncSpec.scala | 7 +- .../stream/MapAsyncPartitionedSpec.scala | 37 +++++----- .../apache/pekko/stream/javadsl/Flow.scala | 3 +- .../apache/pekko/stream/javadsl/Source.scala | 3 +- .../testkit/CallingThreadDispatcher.scala | 3 +- .../org/apache/pekko/testkit/TestKit.scala | 3 +- .../org/apache/pekko/testkit/PekkoSpec.scala | 3 +- .../apache/pekko/testkit/PekkoSpecSpec.scala | 9 ++- .../pekko/testkit/TestActorRefSpec.scala | 5 +- .../apache/pekko/testkit/TestFSMRefSpec.scala | 8 +-- .../apache/pekko/testkit/TestProbeSpec.scala | 23 +++--- 126 files changed, 728 insertions(+), 860 deletions(-) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 63318f3144b..83812707181 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -76,3 +76,6 @@ c44c0b7cbdab11d85176cfe062288fdcba16c56a # Scala Steward: Reformat with scalafmt 3.8.2 38b03829b4e38e983521f3efd7e589d315658f18 + +# Scala Steward: Reformat with scalafmt 3.8.4 +f48453e60a8d11f74acc7a10d3a9da90b8acd4af diff --git a/.scalafmt.conf b/.scalafmt.conf index 83b7c741385..3cc1a455736 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = 3.8.3 +version = 3.8.4 runner.dialect = scala213 project.git = true style = defaultWithAlign diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/ActorConfigurationVerificationSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/ActorConfigurationVerificationSpec.scala index 5e5546324e2..6bcd2a1c44e 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/ActorConfigurationVerificationSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/ActorConfigurationVerificationSpec.scala @@ -15,7 +15,6 @@ package org.apache.pekko.actor import scala.concurrent.duration._ -import language.postfixOps import org.scalatest.BeforeAndAfterEach import org.apache.pekko @@ -79,7 +78,7 @@ class ActorConfigurationVerificationSpec "fail verification with a ConfigurationException if also configured with a ScatterGatherFirstCompletedPool" in { intercept[ConfigurationException] { system.actorOf( - ScatterGatherFirstCompletedPool(nrOfInstances = 2, within = 2 seconds) + ScatterGatherFirstCompletedPool(nrOfInstances = 2, within = 2.seconds) .withDispatcher("balancing-dispatcher") .props(Props[TestActor]())) } diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/ActorCreationPerfSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/ActorCreationPerfSpec.scala index 140a821f02c..d09e9221913 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/ActorCreationPerfSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/ActorCreationPerfSpec.scala @@ -14,7 +14,6 @@ package org.apache.pekko.actor import scala.concurrent.duration._ -import scala.language.postfixOps import com.codahale.metrics.Histogram import com.typesafe.config.ConfigFactory @@ -153,10 +152,10 @@ class ActorCreationPerfSpec expectMsg(Alive) driver ! Create(number, propsCreator) - expectMsgPF(15 seconds, s"$scenarioName waiting for Created") { case Created => } + expectMsgPF(15.seconds, s"$scenarioName waiting for Created") { case Created => } driver ! WaitForChildren - expectMsgPF(15 seconds, s"$scenarioName waiting for Waited") { case Waited => } + expectMsgPF(15.seconds, s"$scenarioName waiting for Waited") { case Waited => } driver ! PoisonPill watch(driver) @@ -175,10 +174,10 @@ class ActorCreationPerfSpec val before = mem.getHeapSnapshot driver ! Create(number, propsCreator) - expectMsgPF(15 seconds, s"$scenarioName waiting for Created") { case Created => } + expectMsgPF(15.seconds, s"$scenarioName waiting for Created") { case Created => } driver ! WaitForChildren - expectMsgPF(15 seconds, s"$scenarioName waiting for Waited") { case Waited => } + expectMsgPF(15.seconds, s"$scenarioName waiting for Waited") { case Waited => } gc() val after = mem.getHeapSnapshot @@ -252,5 +251,5 @@ class ActorCreationPerfSpec override def afterTermination() = shutdownMetrics() - override def expectedTestDuration = 5 minutes + override def expectedTestDuration = 5.minutes } diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/ActorRefSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/ActorRefSpec.scala index ebf47bed86d..171de70270e 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/ActorRefSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/ActorRefSpec.scala @@ -19,8 +19,6 @@ import scala.concurrent.Await import scala.concurrent.Promise import scala.concurrent.duration._ -import language.postfixOps - import org.apache.pekko import pekko.pattern.ask import pekko.serialization.JavaSerializer @@ -141,7 +139,7 @@ class ActorRefSpec extends PekkoSpec(""" def wrap[T](f: Promise[Actor] => T): T = { val result = Promise[Actor]() val r = f(result) - Await.result(result.future, 1 minute) + Await.result(result.future, 1.minute) r } @@ -448,7 +446,7 @@ class ActorRefSpec extends PekkoSpec(""" val boss = system.actorOf(Props(new Actor { override val supervisorStrategy = - OneForOneStrategy(maxNrOfRetries = 2, withinTimeRange = 1 second)(List(classOf[Throwable])) + OneForOneStrategy(maxNrOfRetries = 2, withinTimeRange = 1.second)(List(classOf[Throwable])) val ref = context.actorOf(Props(new Actor { def receive = { case _ => } @@ -460,7 +458,7 @@ class ActorRefSpec extends PekkoSpec(""" })) boss ! "sendKill" - Await.ready(latch, 5 seconds) + Await.ready(latch, 5.seconds) } } diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/ActorSystemSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/ActorSystemSpec.scala index c8af272fa9a..0e9f7e29f76 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/ActorSystemSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/ActorSystemSpec.scala @@ -18,7 +18,6 @@ import java.util.concurrent.atomic.AtomicInteger import scala.concurrent.{ Await, Future } import scala.concurrent.duration._ -import scala.language.postfixOps import scala.annotation.nowarn import com.typesafe.config.{ Config, ConfigFactory } @@ -224,7 +223,7 @@ class ActorSystemSpec extends PekkoSpec(ActorSystemSpec.config) with ImplicitSen } system2.terminate() - Await.ready(latch, 5 seconds) + Await.ready(latch, 5.seconds) val expected = (for (i <- 1 to count) yield i).reverse @@ -243,7 +242,7 @@ class ActorSystemSpec extends PekkoSpec(ActorSystemSpec.config) with ImplicitSen import system.dispatcher system2.scheduler.scheduleOnce(200.millis.dilated) { system2.terminate() } - Await.ready(system2.whenTerminated, 5 seconds) + Await.ready(system2.whenTerminated, 5.seconds) callbackWasRun should ===(true) } @@ -252,17 +251,17 @@ class ActorSystemSpec extends PekkoSpec(ActorSystemSpec.config) with ImplicitSen val wt = system.whenTerminated wt.isCompleted should ===(false) val f = system.terminate() - val terminated = Await.result(wt, 10 seconds) + val terminated = Await.result(wt, 10.seconds) system.whenTerminated.isCompleted should ===(true) terminated.actor should ===(system.provider.rootGuardian) terminated.addressTerminated should ===(true) terminated.existenceConfirmed should ===(true) - (terminated should be).theSameInstanceAs(Await.result(f, 10 seconds)) + (terminated should be).theSameInstanceAs(Await.result(f, 10.seconds)) } "throw RejectedExecutionException when shutdown" in { val system2 = ActorSystem("RejectedExecution-1", PekkoSpec.testConf) - Await.ready(system2.terminate(), 10 seconds) + Await.ready(system2.terminate(), 10.seconds) intercept[RejectedExecutionException] { system2.registerOnTermination { println("IF YOU SEE THIS THEN THERE'S A BUG HERE") } @@ -287,7 +286,7 @@ class ActorSystemSpec extends PekkoSpec(ActorSystemSpec.config) with ImplicitSen "reliably create waves of actors" in { import system.dispatcher - implicit val timeout: Timeout = Timeout((20 seconds).dilated) + implicit val timeout: Timeout = Timeout(20.seconds.dilated) val waves = for (_ <- 1 to 3) yield system.actorOf(Props[ActorSystemSpec.Waves]()) ? 50000 Await.result(Future.sequence(waves), timeout.duration + 5.seconds) should ===(Vector("done", "done", "done")) } @@ -300,7 +299,7 @@ class ActorSystemSpec extends PekkoSpec(ActorSystemSpec.config) with ImplicitSen "reliable deny creation of actors while shutting down" in { val system = ActorSystem() import system.dispatcher - system.scheduler.scheduleOnce(100 millis) { system.terminate() } + system.scheduler.scheduleOnce(100.millis) { system.terminate() } var failing = false var created = Vector.empty[ActorRef] while (!system.whenTerminated.isCompleted) { diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/ActorWithBoundedStashSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/ActorWithBoundedStashSpec.scala index e8a1ec7d2dd..f179d807d3b 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/ActorWithBoundedStashSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/ActorWithBoundedStashSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.actor import scala.concurrent.duration._ import com.typesafe.config.{ Config, ConfigFactory } -import language.postfixOps import org.scalatest.BeforeAndAfterEach import org.apache.pekko @@ -67,9 +66,9 @@ object ActorWithBoundedStashSpec { } // bounded deque-based mailbox with capacity 10 - class Bounded10(@unused settings: Settings, @unused config: Config) extends BoundedDequeBasedMailbox(10, 500 millis) + class Bounded10(@unused settings: Settings, @unused config: Config) extends BoundedDequeBasedMailbox(10, 500.millis) - class Bounded100(@unused settings: Settings, @unused config: Config) extends BoundedDequeBasedMailbox(100, 500 millis) + class Bounded100(@unused settings: Settings, @unused config: Config) extends BoundedDequeBasedMailbox(100, 500.millis) val dispatcherId1 = "my-dispatcher-1" val dispatcherId2 = "my-dispatcher-2" diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/ActorWithStashSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/ActorWithStashSpec.scala index 636117cd85c..25526c80b5b 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/ActorWithStashSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/ActorWithStashSpec.scala @@ -17,7 +17,6 @@ import scala.concurrent.Await import scala.concurrent.duration._ import scala.annotation.nowarn -import language.postfixOps import org.scalatest.BeforeAndAfterEach import org.apache.pekko @@ -144,13 +143,13 @@ class ActorWithStashSpec extends PekkoSpec with DefaultTimeout with BeforeAndAft val stasher = system.actorOf(Props[StashingTwiceActor]()) stasher ! "hello" stasher ! "hello" - Await.ready(state.expectedException, 10 seconds) + Await.ready(state.expectedException, 10.seconds) } "process stashed messages after restart" in { val boss = system.actorOf( Props( - new Supervisor(OneForOneStrategy(maxNrOfRetries = 2, withinTimeRange = 1 second)(List(classOf[Throwable]))))) + new Supervisor(OneForOneStrategy(maxNrOfRetries = 2, withinTimeRange = 1.second)(List(classOf[Throwable]))))) val restartLatch = new TestLatch val hasMsgLatch = new TestLatch @@ -180,8 +179,8 @@ class ActorWithStashSpec extends PekkoSpec with DefaultTimeout with BeforeAndAft employee ! "hello" employee ! "crash" - Await.ready(restartLatch, 10 seconds) - Await.ready(hasMsgLatch, 10 seconds) + Await.ready(restartLatch, 10.seconds) + Await.ready(hasMsgLatch, 10.seconds) } "re-receive unstashed Terminated messages" in { diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/ConsistencySpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/ConsistencySpec.scala index b4777152a32..42f67440ae0 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/ConsistencySpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/ConsistencySpec.scala @@ -15,8 +15,6 @@ package org.apache.pekko.actor import scala.concurrent.duration._ -import language.postfixOps - import org.apache.pekko import pekko.dispatch.ThreadPoolConfig import pekko.testkit.PekkoSpec @@ -80,7 +78,7 @@ class ConsistencySpec extends PekkoSpec(ConsistencySpec.config) { for (a <- actors) { a.tell("done", testActor) } - for (_ <- actors) expectMsg(5 minutes, "done") + for (_ <- actors) expectMsg(5.minutes, "done") } } } diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/DeathWatchSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/DeathWatchSpec.scala index 6c25147c31b..20f45fd36cf 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/DeathWatchSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/DeathWatchSpec.scala @@ -17,7 +17,6 @@ import scala.concurrent.Await import scala.concurrent.duration._ import scala.annotation.nowarn -import language.postfixOps import org.apache.pekko import pekko.actor.Props.EmptyActor @@ -125,11 +124,11 @@ trait DeathWatchSpec { this: PekkoSpec with ImplicitSender with DefaultTimeout = lazy val supervisor = system.actorOf(Props(classOf[Supervisor], SupervisorStrategy.defaultStrategy), "watchers") def startWatching(target: ActorRef) = - Await.result((supervisor ? Watcher.props(target, testActor)).mapTo[ActorRef], 3 seconds) + Await.result((supervisor ? Watcher.props(target, testActor)).mapTo[ActorRef], 3.seconds) "The Death Watch" must { def expectTerminationOf(actorRef: ActorRef) = - expectMsgPF(5 seconds, "" + actorRef + ": Stopped or Already terminated when linking") { + expectMsgPF(5.seconds, "" + actorRef + ": Stopped or Already terminated when linking") { case WrappedTerminated(Terminated(`actorRef`)) => true } @@ -236,7 +235,7 @@ trait DeathWatchSpec { this: PekkoSpec with ImplicitSender with DefaultTimeout = startWatching(brother) failed ! Kill - val result = receiveWhile(3 seconds, messages = 3) { + val result = receiveWhile(3.seconds, messages = 3) { case FF(Failed(_, _: ActorKilledException, _)) if lastSender eq failed => 1 case FF(Failed(_, DeathPactException(`failed`), _)) if lastSender eq brother => 2 case WrappedTerminated(Terminated(`brother`)) => 3 diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/DeployerSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/DeployerSpec.scala index e19dedaabc3..1a49950f885 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/DeployerSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/DeployerSpec.scala @@ -17,7 +17,6 @@ import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory import com.typesafe.config.ConfigParseOptions -import language.postfixOps import org.apache.pekko import pekko.routing._ @@ -201,7 +200,7 @@ class DeployerSpec extends PekkoSpec(DeployerSpec.deployerConf) { "be able to parse 'pekko.actor.deployment._' with scatter-gather router" in { assertRouting( "/service-scatter-gather", - ScatterGatherFirstCompletedPool(nrOfInstances = 1, within = 2 seconds), + ScatterGatherFirstCompletedPool(nrOfInstances = 1, within = 2.seconds), "/service-scatter-gather") } @@ -218,7 +217,7 @@ class DeployerSpec extends PekkoSpec(DeployerSpec.deployerConf) { assertRouting("/some/wildcardmatch", RandomPool(1), "/some/*") assertRouting( "/somewildcardmatch/some", - ScatterGatherFirstCompletedPool(nrOfInstances = 1, within = 2 seconds), + ScatterGatherFirstCompletedPool(nrOfInstances = 1, within = 2.seconds), "/*/some") } diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/FSMActorSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/FSMActorSpec.scala index 5138864c2c3..e04ebdaa4e2 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/FSMActorSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/FSMActorSpec.scala @@ -17,7 +17,6 @@ import scala.concurrent.Await import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import org.apache.pekko import pekko.event._ @@ -113,7 +112,7 @@ object FSMActorSpec { class FSMActorSpec extends PekkoSpec(Map("pekko.actor.debug.fsm" -> true)) with ImplicitSender { import FSMActorSpec._ - val timeout = Timeout(2 seconds) + val timeout = Timeout(2.seconds) "An FSM Actor" must { @@ -125,7 +124,7 @@ class FSMActorSpec extends PekkoSpec(Map("pekko.actor.debug.fsm" -> true)) with import latches._ // lock that locked after being open for 1 sec - val lock = system.actorOf(Props(new Lock("33221", 1 second, latches))) + val lock = system.actorOf(Props(new Lock("33221", 1.second, latches))) val transitionTester = system.actorOf(Props(new Actor { def receive = { @@ -179,7 +178,7 @@ class FSMActorSpec extends PekkoSpec(Map("pekko.actor.debug.fsm" -> true)) with EventFilter.error("Next state 2 does not exist", occurrences = 1).intercept { system.eventStream.subscribe(testActor, classOf[Logging.Error]) fsm ! "go" - expectMsgPF(1 second, hint = "Next state 2 does not exist") { + expectMsgPF(1.second, hint = "Next state 2 does not exist") { case Logging.Error(_, `name`, _, "Next state 2 does not exist") => true } system.eventStream.unsubscribe(testActor) @@ -203,7 +202,7 @@ class FSMActorSpec extends PekkoSpec(Map("pekko.actor.debug.fsm" -> true)) with val ref = system.actorOf(Props(fsm)) Await.ready(started, timeout.duration) system.stop(ref) - expectMsg(1 second, fsm.StopEvent(FSM.Shutdown, 1, null)) + expectMsg(1.second, fsm.StopEvent(FSM.Shutdown, 1, null)) } "run onTermination with updated state upon stop(reason, stateData)" in { @@ -230,12 +229,12 @@ class FSMActorSpec extends PekkoSpec(Map("pekko.actor.debug.fsm" -> true)) with when("not-started") { case Event("start", _) => goto("started").replying("starting") } - when("started", stateTimeout = 10 seconds) { + when("started", stateTimeout = 10.seconds) { case Event("stop", _) => stop() } onTransition { case "not-started" -> "started" => - for (timerName <- timerNames) startSingleTimer(timerName, (), 10 seconds) + for (timerName <- timerNames) startSingleTimer(timerName, (), 10.seconds) } onTermination { case _ => { @@ -253,11 +252,11 @@ class FSMActorSpec extends PekkoSpec(Map("pekko.actor.debug.fsm" -> true)) with checkTimersActive(false) fsmref ! "start" - expectMsg(1 second, "starting") + expectMsg(1.second, "starting") checkTimersActive(true) fsmref ! "stop" - expectMsg(1 second, "stopped") + expectMsg(1.second, "stopped") } "log events and transitions if asked to do so" in { @@ -273,7 +272,7 @@ class FSMActorSpec extends PekkoSpec(Map("pekko.actor.debug.fsm" -> true)) with startWith(1, null) when(1) { case Event("go", _) => - startSingleTimer("t", FSM.Shutdown, 1.5 seconds) + startSingleTimer("t", FSM.Shutdown, 1.5.seconds) goto(2) } when(2) { @@ -289,21 +288,21 @@ class FSMActorSpec extends PekkoSpec(Map("pekko.actor.debug.fsm" -> true)) with val fsmClass = fsm.underlyingActor.getClass system.eventStream.subscribe(testActor, classOf[Logging.Debug]) fsm ! "go" - expectMsgPF(1 second, hint = "processing Event(go,null)") { + expectMsgPF(1.second, hint = "processing Event(go,null)") { case Logging.Debug(`name`, `fsmClass`, s: String) if s.startsWith("processing Event(go,null) from Actor[") => true } - expectMsg(1 second, Logging.Debug(name, fsmClass, "setting timer 't'/1500 milliseconds: Shutdown")) - expectMsg(1 second, Logging.Debug(name, fsmClass, "transition 1 -> 2")) + expectMsg(1.second, Logging.Debug(name, fsmClass, "setting timer 't'/1500 milliseconds: Shutdown")) + expectMsg(1.second, Logging.Debug(name, fsmClass, "transition 1 -> 2")) fsm ! "stop" - expectMsgPF(1 second, hint = "processing Event(stop,null)") { + expectMsgPF(1.second, hint = "processing Event(stop,null)") { case Logging.Debug(`name`, `fsmClass`, s: String) if s.startsWith("processing Event(stop,null) from Actor[") => true } - expectMsgAllOf(1 second, Logging.Debug(name, fsmClass, "canceling timer 't'"), FSM.Normal) - expectNoMessage(1 second) + expectMsgAllOf(1.second, Logging.Debug(name, fsmClass, "canceling timer 't'"), FSM.Normal) + expectNoMessage(1.second) system.eventStream.unsubscribe(testActor) } } @@ -323,13 +322,13 @@ class FSMActorSpec extends PekkoSpec(Map("pekko.actor.debug.fsm" -> true)) with }) fsmref ! "log" import FSM.LogEntry - expectMsg(1 second, IndexedSeq(LogEntry(1, 0, "log"))) + expectMsg(1.second, IndexedSeq(LogEntry(1, 0, "log"))) fsmref ! "count" fsmref ! "log" - expectMsg(1 second, IndexedSeq(LogEntry(1, 0, "log"), LogEntry(1, 0, "count"), LogEntry(1, 1, "log"))) + expectMsg(1.second, IndexedSeq(LogEntry(1, 0, "log"), LogEntry(1, 0, "count"), LogEntry(1, 1, "log"))) fsmref ! "count" fsmref ! "log" - expectMsg(1 second, IndexedSeq(LogEntry(1, 1, "log"), LogEntry(1, 1, "count"), LogEntry(1, 2, "log"))) + expectMsg(1.second, IndexedSeq(LogEntry(1, 1, "log"), LogEntry(1, 1, "count"), LogEntry(1, 2, "log"))) } "allow transforming of state results" in { diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/FSMTimingSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/FSMTimingSpec.scala index 3e032627ba1..ada5681144e 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/FSMTimingSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/FSMTimingSpec.scala @@ -13,8 +13,6 @@ package org.apache.pekko.actor -import language.postfixOps - import org.apache.pekko.testkit._ import scala.concurrent.duration._ @@ -24,7 +22,7 @@ class FSMTimingSpec extends PekkoSpec with ImplicitSender { val fsm = system.actorOf(Props(new StateMachine(testActor))) fsm ! SubscribeTransitionCallBack(testActor) - expectMsg(1 second, CurrentState(fsm, Initial)) + expectMsg(1.second, CurrentState(fsm, Initial)) ignoreMsg { case Transition(_, bs: FSMTimingSpec.State, _) if bs eq Initial => true // SI-5900 workaround @@ -33,8 +31,8 @@ class FSMTimingSpec extends PekkoSpec with ImplicitSender { "A Finite State Machine" must { "receive StateTimeout" taggedAs TimingTest in { - within(2 seconds) { - within(500 millis, 2 seconds) { + within(2.seconds) { + within(500.millis, 2.seconds) { fsm ! TestStateTimeout expectMsg(Transition(fsm, TestStateTimeout, Initial)) } @@ -43,7 +41,7 @@ class FSMTimingSpec extends PekkoSpec with ImplicitSender { } "cancel a StateTimeout" taggedAs TimingTest in { - within(1 second) { + within(1.second) { fsm ! TestStateTimeout fsm ! Cancel expectMsg(Cancel) @@ -56,18 +54,18 @@ class FSMTimingSpec extends PekkoSpec with ImplicitSender { val stoppingActor = system.actorOf(Props[StoppingActor]()) system.eventStream.subscribe(testActor, classOf[DeadLetter]) stoppingActor ! TestStoppingActorStateTimeout - within(400 millis) { + within(400.millis) { expectNoMessage(remainingOrDefault) } } "allow StateTimeout override" taggedAs TimingTest in { // the timeout in state TestStateTimeout is 800 ms, then it will change to Initial - within(400 millis) { + within(400.millis) { fsm ! TestStateTimeoutOverride expectNoMessage() } - within(1 second) { + within(1.second) { fsm ! Cancel expectMsg(Cancel) expectMsg(Transition(fsm, TestStateTimeout, Initial)) @@ -75,8 +73,8 @@ class FSMTimingSpec extends PekkoSpec with ImplicitSender { } "receive single-shot timer" taggedAs TimingTest in { - within(2 seconds) { - within(500 millis, 1 second) { + within(2.seconds) { + within(500.millis, 1.second) { fsm ! TestSingleTimer expectMsg(Tick) expectMsg(Transition(fsm, TestSingleTimer, Initial)) @@ -86,12 +84,12 @@ class FSMTimingSpec extends PekkoSpec with ImplicitSender { } "resubmit single-shot timer" taggedAs TimingTest in { - within(2.5 seconds) { - within(500 millis, 1 second) { + within(2.5.seconds) { + within(500.millis, 1.second) { fsm ! TestSingleTimerResubmit expectMsg(Tick) } - within(1 second) { + within(1.second) { expectMsg(Tock) expectMsg(Transition(fsm, TestSingleTimerResubmit, Initial)) } @@ -101,28 +99,28 @@ class FSMTimingSpec extends PekkoSpec with ImplicitSender { "correctly cancel a named timer" taggedAs TimingTest in { fsm ! TestCancelTimer - within(500 millis) { + within(500.millis) { fsm ! Tick expectMsg(Tick) } - within(300 millis, 1 second) { + within(300.millis, 1.second) { expectMsg(Tock) } fsm ! Cancel - expectMsg(1 second, Transition(fsm, TestCancelTimer, Initial)) + expectMsg(1.second, Transition(fsm, TestCancelTimer, Initial)) } "not get confused between named and state timers" taggedAs TimingTest in { fsm ! TestCancelStateTimerInNamedTimerMessage fsm ! Tick - expectMsg(500 millis, Tick) + expectMsg(500.millis, Tick) Thread.sleep(200) // this is ugly: need to wait for StateTimeout to be queued resume(fsm) expectMsg( - 500 millis, + 500.millis, Transition(fsm, TestCancelStateTimerInNamedTimerMessage, TestCancelStateTimerInNamedTimerMessage2)) fsm ! Cancel - within(500 millis) { + within(500.millis) { expectMsg(Cancel) // if this is not received, that means StateTimeout was not properly discarded expectMsg(Transition(fsm, TestCancelStateTimerInNamedTimerMessage2, Initial)) } @@ -130,11 +128,11 @@ class FSMTimingSpec extends PekkoSpec with ImplicitSender { "receive and cancel a repeated timer" taggedAs TimingTest in { fsm ! TestRepeatedTimer - val seq = receiveWhile(2 seconds) { + val seq = receiveWhile(2.seconds) { case Tick => Tick } (seq should have).length(5) - within(500 millis) { + within(500.millis) { expectMsg(Transition(fsm, TestRepeatedTimer, Initial)) } } @@ -147,7 +145,7 @@ class FSMTimingSpec extends PekkoSpec with ImplicitSender { source = fsm.path.toString, occurrences = 1)) { fsm ! TestUnhandled - within(3 second) { + within(3.second) { fsm ! Tick fsm ! SetHandler fsm ! Tick @@ -292,7 +290,7 @@ object FSMTimingSpec { class StoppingActor extends Actor with FSM[State, Int] { startWith(Initial, 0) - when(Initial, 200 millis) { + when(Initial, 200.millis) { case Event(TestStoppingActorStateTimeout, _) => context.stop(self) stay() diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/FSMTransitionSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/FSMTransitionSpec.scala index 35c092e0406..aaca6064a3d 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/FSMTransitionSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/FSMTransitionSpec.scala @@ -14,7 +14,6 @@ package org.apache.pekko.actor import scala.concurrent.duration._ -import scala.language.postfixOps import org.apache.pekko import pekko.testkit._ @@ -91,7 +90,7 @@ class FSMTransitionSpec extends PekkoSpec with ImplicitSender { import FSM.{ CurrentState, SubscribeTransitionCallBack, Transition } val fsm = system.actorOf(Props(new MyFSM(testActor))) - within(1 second) { + within(1.second) { fsm ! SubscribeTransitionCallBack(testActor) expectMsg(CurrentState(fsm, 0)) fsm ! "tick" @@ -105,10 +104,10 @@ class FSMTransitionSpec extends PekkoSpec with ImplicitSender { val forward = system.actorOf(Props(new Forwarder(testActor))) val fsm = system.actorOf(Props(new MyFSM(testActor))) - within(1 second) { + within(1.second) { fsm ! FSM.SubscribeTransitionCallBack(forward) expectMsg(FSM.CurrentState(fsm, 0)) - pekko.pattern.gracefulStop(forward, 5 seconds) + pekko.pattern.gracefulStop(forward, 5.seconds) fsm ! "tick" expectNoMessage() } @@ -119,7 +118,7 @@ class FSMTransitionSpec extends PekkoSpec with ImplicitSender { "make previous and next state data available in onTransition" in { val fsm = system.actorOf(Props(new OtherFSM(testActor))) - within(1 second) { + within(1.second) { fsm ! "tick" expectMsg((0, 1)) } @@ -130,7 +129,7 @@ class FSMTransitionSpec extends PekkoSpec with ImplicitSender { val forward = system.actorOf(Props(new Forwarder(testActor))) val fsm = system.actorOf(Props(new OtherFSM(testActor))) - within(1 second) { + within(1.second) { fsm ! FSM.SubscribeTransitionCallBack(forward) expectMsg(FSM.CurrentState(fsm, 0)) fsm ! "tick" @@ -146,7 +145,7 @@ class FSMTransitionSpec extends PekkoSpec with ImplicitSender { val forward = system.actorOf(Props(new Forwarder(testActor))) val fsm = system.actorOf(Props(new OtherFSM(testActor))) - within(1 second) { + within(1.second) { fsm ! FSM.SubscribeTransitionCallBack(forward) expectMsg(FSM.CurrentState(fsm, 0)) fsm ! "stay" diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/ForwardActorSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/ForwardActorSpec.scala index e7f1efa3c12..d6f03c44e62 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/ForwardActorSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/ForwardActorSpec.scala @@ -16,8 +16,6 @@ package org.apache.pekko.actor import scala.concurrent.ExecutionContextExecutor import scala.concurrent.duration._ -import language.postfixOps - import org.apache.pekko import pekko.pattern.{ ask, pipe } import pekko.testkit._ @@ -52,13 +50,13 @@ class ForwardActorSpec extends PekkoSpec { val chain = createForwardingChain(system) chain.tell(ExpectedMessage, replyTo) - expectMsg(5 seconds, ExpectedMessage) + expectMsg(5.seconds, ExpectedMessage) } "forward actor reference when invoking forward on ask" in { val chain = createForwardingChain(system) - chain.ask(ExpectedMessage)(5 seconds).pipeTo(testActor) - expectMsg(5 seconds, ExpectedMessage) + chain.ask(ExpectedMessage)(5.seconds).pipeTo(testActor) + expectMsg(5.seconds, ExpectedMessage) } } } diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/LocalActorRefProviderSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/LocalActorRefProviderSpec.scala index 7073d1989d8..58767473856 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/LocalActorRefProviderSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/LocalActorRefProviderSpec.scala @@ -20,7 +20,6 @@ import scala.util.Failure import scala.util.Success import scala.annotation.nowarn -import language.postfixOps import org.apache.pekko import pekko.testkit._ @@ -126,7 +125,7 @@ class LocalActorRefProviderSpec extends PekkoSpec(LocalActorRefProviderSpec.conf val childProps2 = child.asInstanceOf[LocalActorRef].underlying.props childProps2 should not be theSameInstanceAs(childProps1) (childProps2 should be).theSameInstanceAs(ActorCell.terminatedProps) - }, 1 second) + }, 1.second) } } @@ -140,7 +139,7 @@ class LocalActorRefProviderSpec extends PekkoSpec(LocalActorRefProviderSpec.conf for (i <- 0 until 100) { val address = "new-actor" + i - implicit val timeout: Timeout = Timeout(5 seconds) + implicit val timeout: Timeout = Timeout(5.seconds) val actors = for (_ <- 1 to 4) yield Future(system.actorOf(Props(new Actor { def receive = { case _ => } }), address)) diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/ReceiveTimeoutSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/ReceiveTimeoutSpec.scala index e00687a9007..236edc19c9d 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/ReceiveTimeoutSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/ReceiveTimeoutSpec.scala @@ -20,8 +20,6 @@ import java.util.concurrent.atomic.AtomicInteger import scala.concurrent.Await import scala.concurrent.duration._ -import language.postfixOps - import org.apache.pekko.testkit._ object ReceiveTimeoutSpec { @@ -85,7 +83,7 @@ class ReceiveTimeoutSpec extends PekkoSpec() { val timeoutLatch = TestLatch() val timeoutActor = system.actorOf(Props(new Actor { - context.setReceiveTimeout(500 milliseconds) + context.setReceiveTimeout(500.milliseconds) def receive = { case ReceiveTimeout => timeoutLatch.open() @@ -100,7 +98,7 @@ class ReceiveTimeoutSpec extends PekkoSpec() { val timeoutLatch = TestLatch() val timeoutActor = system.actorOf(Props(new Actor { - context.setReceiveTimeout(500 milliseconds) + context.setReceiveTimeout(500.milliseconds) def receive = { case Tick => () @@ -119,7 +117,7 @@ class ReceiveTimeoutSpec extends PekkoSpec() { val timeoutLatch = TestLatch() val timeoutActor = system.actorOf(Props(new Actor { - context.setReceiveTimeout(500 milliseconds) + context.setReceiveTimeout(500.milliseconds) def receive = { case Tick => () @@ -146,7 +144,7 @@ class ReceiveTimeoutSpec extends PekkoSpec() { } })) - intercept[TimeoutException] { Await.ready(timeoutLatch, 1 second) } + intercept[TimeoutException] { Await.ready(timeoutLatch, 1.second) } system.stop(timeoutActor) } @@ -154,7 +152,7 @@ class ReceiveTimeoutSpec extends PekkoSpec() { val timeoutLatch = TestLatch() val timeoutActor = system.actorOf(Props(new Actor { - context.setReceiveTimeout(1 second) + context.setReceiveTimeout(1.second) def receive = { case ReceiveTimeout => timeoutLatch.open() @@ -176,7 +174,7 @@ class ReceiveTimeoutSpec extends PekkoSpec() { val timeoutLatch = TestLatch(2) val timeoutActor = system.actorOf(Props(new Actor { - context.setReceiveTimeout(1 second) + context.setReceiveTimeout(1.second) def receive = { case ReceiveTimeout => @@ -198,7 +196,7 @@ class ReceiveTimeoutSpec extends PekkoSpec() { timers.startTimerWithFixedDelay("transparentTick", TransparentTick, 100.millis) timers.startTimerWithFixedDelay("identifyTick", Identify(None), 100.millis) - context.setReceiveTimeout(1 second) + context.setReceiveTimeout(1.second) def receive: Receive = { case ReceiveTimeout => timeoutLatch.open() @@ -219,7 +217,7 @@ class ReceiveTimeoutSpec extends PekkoSpec() { val timeoutActor = system.actorOf(Props(new Actor { def receive = { - case TransparentTick => context.setReceiveTimeout(500 milliseconds) + case TransparentTick => context.setReceiveTimeout(500.milliseconds) case ReceiveTimeout => timeoutLatch.open() } })) @@ -234,7 +232,7 @@ class ReceiveTimeoutSpec extends PekkoSpec() { val timeoutLatch = TestLatch() val timeoutActor = system.actorOf(Props(new Actor { - context.setReceiveTimeout(500 milliseconds) + context.setReceiveTimeout(500.milliseconds) def receive = { case TransparentTick => context.setReceiveTimeout(Duration.Inf) @@ -244,7 +242,7 @@ class ReceiveTimeoutSpec extends PekkoSpec() { timeoutActor ! TransparentTick - intercept[TimeoutException] { Await.ready(timeoutLatch, 1 second) } + intercept[TimeoutException] { Await.ready(timeoutLatch, 1.second) } system.stop(timeoutActor) } diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/RestartStrategySpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/RestartStrategySpec.scala index 0e7dec918f9..3fd012f5548 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/RestartStrategySpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/RestartStrategySpec.scala @@ -19,7 +19,6 @@ import scala.concurrent.Await import scala.concurrent.duration._ import scala.annotation.nowarn -import language.postfixOps import org.apache.pekko import pekko.pattern.ask @@ -44,7 +43,7 @@ class RestartStrategySpec extends PekkoSpec with DefaultTimeout { "ensure that employee stays dead after max restarts within time range" in { val boss = system.actorOf( Props( - new Supervisor(OneForOneStrategy(maxNrOfRetries = 2, withinTimeRange = 1 second)(List(classOf[Throwable]))))) + new Supervisor(OneForOneStrategy(maxNrOfRetries = 2, withinTimeRange = 1.second)(List(classOf[Throwable]))))) val restartLatch = new TestLatch val secondRestartLatch = new TestLatch @@ -76,17 +75,17 @@ class RestartStrategySpec extends PekkoSpec with DefaultTimeout { employee ! Ping // test restart and post restart ping - Await.ready(restartLatch, 10 seconds) + Await.ready(restartLatch, 10.seconds) // now crash again... should not restart employee ! Crash employee ! Ping - Await.ready(secondRestartLatch, 10 seconds) - Await.ready(countDownLatch, 10 seconds) + Await.ready(secondRestartLatch, 10.seconds) + Await.ready(countDownLatch, 10.seconds) employee ! Crash - Await.ready(stopLatch, 10 seconds) + Await.ready(stopLatch, 10.seconds) } "ensure that employee is immortal without max restarts and time range" in { @@ -109,13 +108,13 @@ class RestartStrategySpec extends PekkoSpec with DefaultTimeout { (1 to 100).foreach { _ => employee ! Crash } - Await.ready(countDownLatch, 2 minutes) + Await.ready(countDownLatch, 2.minutes) assert(!employee.isTerminated) } "ensure that employee restarts after number of crashes not within time range" in { val boss = system.actorOf(Props( - new Supervisor(OneForOneStrategy(maxNrOfRetries = 2, withinTimeRange = 500 millis)(List(classOf[Throwable]))))) + new Supervisor(OneForOneStrategy(maxNrOfRetries = 2, withinTimeRange = 500.millis)(List(classOf[Throwable]))))) val restartLatch = new TestLatch val secondRestartLatch = new TestLatch @@ -150,14 +149,14 @@ class RestartStrategySpec extends PekkoSpec with DefaultTimeout { employee ! Ping employee ! Crash - Await.ready(restartLatch, 10 seconds) - Await.ready(pingLatch, 10 seconds) + Await.ready(restartLatch, 10.seconds) + Await.ready(pingLatch, 10.seconds) employee ! Ping employee ! Crash - Await.ready(secondRestartLatch, 10 seconds) - Await.ready(secondPingLatch, 10 seconds) + Await.ready(secondRestartLatch, 10.seconds) + Await.ready(secondPingLatch, 10.seconds) // sleep to go out of the restart strategy's time range sleep(700L) @@ -166,7 +165,7 @@ class RestartStrategySpec extends PekkoSpec with DefaultTimeout { employee ! Crash employee ! Ping - Await.ready(thirdRestartLatch, 1 second) + Await.ready(thirdRestartLatch, 1.second) assert(!employee.isTerminated) } @@ -203,7 +202,7 @@ class RestartStrategySpec extends PekkoSpec with DefaultTimeout { employee ! Ping // test restart and post restart ping - Await.ready(restartLatch, 10 seconds) + Await.ready(restartLatch, 10.seconds) assert(!employee.isTerminated) @@ -211,13 +210,13 @@ class RestartStrategySpec extends PekkoSpec with DefaultTimeout { employee ! Crash employee ! Ping - Await.ready(secondRestartLatch, 10 seconds) - Await.ready(countDownLatch, 10 seconds) + Await.ready(secondRestartLatch, 10.seconds) + Await.ready(countDownLatch, 10.seconds) sleep(700L) employee ! Crash - Await.ready(stopLatch, 10 seconds) + Await.ready(stopLatch, 10.seconds) sleep(500L) assert(employee.isTerminated) } @@ -227,7 +226,7 @@ class RestartStrategySpec extends PekkoSpec with DefaultTimeout { val countDownLatch = new TestLatch(2) val boss = system.actorOf(Props(new Actor { - override val supervisorStrategy = OneForOneStrategy(withinTimeRange = 1 second)(List(classOf[Throwable])) + override val supervisorStrategy = OneForOneStrategy(withinTimeRange = 1.second)(List(classOf[Throwable])) def receive = { case p: Props => sender() ! context.watch(context.actorOf(p)) case _: Terminated => maxNoOfRestartsLatch.open() @@ -256,7 +255,7 @@ class RestartStrategySpec extends PekkoSpec with DefaultTimeout { employee ! Ping // test restart and post restart ping - Await.ready(restartLatch, 10 seconds) + Await.ready(restartLatch, 10.seconds) assert(!employee.isTerminated) @@ -265,14 +264,14 @@ class RestartStrategySpec extends PekkoSpec with DefaultTimeout { // may not be running employee ! Ping - Await.ready(countDownLatch, 10 seconds) + Await.ready(countDownLatch, 10.seconds) // may not be running employee ! Crash - Await.ready(stopLatch, 10 seconds) + Await.ready(stopLatch, 10.seconds) - Await.ready(maxNoOfRestartsLatch, 10 seconds) + Await.ready(maxNoOfRestartsLatch, 10.seconds) sleep(500L) assert(employee.isTerminated) } diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/SchedulerSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/SchedulerSpec.scala index cb1fd0b9bc9..e39227e02a9 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/SchedulerSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/SchedulerSpec.scala @@ -27,7 +27,6 @@ import atomic.{ AtomicInteger, AtomicReference } import scala.annotation.nowarn import com.typesafe.config.{ Config, ConfigFactory } -import language.postfixOps import org.scalatest.BeforeAndAfterEach import org.apache.pekko import pekko.pattern.ask @@ -118,13 +117,13 @@ trait SchedulerSpec extends BeforeAndAfterEach with DefaultTimeout with Implicit * ticket #372 */ "be cancellable" taggedAs TimingTest in { - for (_ <- 1 to 10) system.scheduler.scheduleOnce(1 second, testActor, "fail").cancel() + for (_ <- 1 to 10) system.scheduler.scheduleOnce(1.second, testActor, "fail").cancel() - expectNoMessage(2 seconds) + expectNoMessage(2.seconds) } "be canceled if cancel is performed before execution" taggedAs TimingTest in { - val task = collectCancellable(system.scheduler.scheduleOnce(10 seconds)(())) + val task = collectCancellable(system.scheduler.scheduleOnce(10.seconds)(())) task.cancel() should ===(true) task.isCancelled should ===(true) task.cancel() should ===(false) @@ -133,7 +132,7 @@ trait SchedulerSpec extends BeforeAndAfterEach with DefaultTimeout with Implicit "notify callback if cancel is performed before execution" taggedAs TimingTest in { val latch = new CountDownLatch(1) - val task = system.scheduler.scheduleOnce(100 millis, + val task = system.scheduler.scheduleOnce(100.millis, new SchedulerTask { override def run(): Unit = () override def cancelled(): Unit = latch.countDown() @@ -172,7 +171,7 @@ trait SchedulerSpec extends BeforeAndAfterEach with DefaultTimeout with Implicit Thread.sleep(5) } - Await.ready(ticks, 3 seconds) + Await.ready(ticks, 3.seconds) } "handle timeouts equal to multiple of wheel period" taggedAs TimingTest in { @@ -374,7 +373,7 @@ trait SchedulerSpec extends BeforeAndAfterEach with DefaultTimeout with Implicit val pingLatch = new TestLatch(6) val supervisor = - system.actorOf(Props(new Supervisor(AllForOneStrategy(3, 1 second)(List(classOf[Exception]))))) + system.actorOf(Props(new Supervisor(AllForOneStrategy(3, 1.second)(List(classOf[Exception]))))) val props = Props(new Actor { def receive = { case Ping => pingLatch.countDown() @@ -391,9 +390,9 @@ trait SchedulerSpec extends BeforeAndAfterEach with DefaultTimeout with Implicit collectCancellable(system.scheduler.scheduleOnce(1000.millis, actor, Crash)) } - Await.ready(restartLatch, 2 seconds) + Await.ready(restartLatch, 2.seconds) // should be enough time for the ping countdown to recover and reach 6 pings - Await.ready(pingLatch, 5 seconds) + Await.ready(pingLatch, 5.seconds) } "schedule with different initial delay and frequency" taggedAs TimingTest in { @@ -406,8 +405,8 @@ trait SchedulerSpec extends BeforeAndAfterEach with DefaultTimeout with Implicit })) val startTime = System.nanoTime() - collectCancellable(scheduleAdapter.schedule(1 second, 300.millis, actor, Msg)) - Await.ready(ticks, 3 seconds) + collectCancellable(scheduleAdapter.schedule(1.second, 300.millis, actor, Msg)) + Await.ready(ticks, 3.seconds) // LARS is a bit more aggressive in scheduling recurring tasks at the right // frequency and may execute them a little earlier; the actual expected timing @@ -810,7 +809,7 @@ class LightArrayRevolverSchedulerSpec extends PekkoSpec(SchedulerSpec.testConfRe time } - override protected def getShutdownTimeout: FiniteDuration = (10 seconds).dilated + override protected def getShutdownTimeout: FiniteDuration = 10.seconds.dilated override protected def waitNanos(ns: Long): Unit = { // println(s"waiting $ns") diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/SupervisorHierarchySpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/SupervisorHierarchySpec.scala index 2ed576a222e..bf8bfa79701 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/SupervisorHierarchySpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/SupervisorHierarchySpec.scala @@ -27,7 +27,6 @@ import scala.util.control.NoStackTrace import SupervisorStrategy.{ Directive, Restart, Resume, Stop } import scala.annotation.nowarn import com.typesafe.config.{ Config, ConfigFactory } -import language.postfixOps import org.apache.pekko import pekko.actor.SupervisorStrategy.seqThrowable2Decider @@ -240,7 +239,7 @@ object SupervisorHierarchySpec { case (_, x) => log :+= Event("unhandled exception from " + sender() + Logging.stackTraceFor(x), identityHashCode(this)) sender() ! Dump(0) - context.system.scheduler.scheduleOnce(1 second, self, Dump(0))(context.dispatcher) + context.system.scheduler.scheduleOnce(1.second, self, Dump(0))(context.dispatcher) Resume }) @@ -477,7 +476,7 @@ object SupervisorHierarchySpec { case this.Event(Init, _) => hierarchy = context.watch( context.actorOf(Props(new Hierarchy(size, breadth, self, 0, random)).withDispatcher("hierarchy"), "head")) - startSingleTimer("phase", StateTimeout, 5 seconds) + startSingleTimer("phase", StateTimeout, 5.seconds) goto(Init) } @@ -646,7 +645,7 @@ object SupervisorHierarchySpec { goto(Failed) } - when(GC, stateTimeout = 10 seconds) { + when(GC, stateTimeout = 10.seconds) { case this.Event(GCcheck(weak), _) => val next = weak.filter(_.get ne null) if (next.nonEmpty) { @@ -793,7 +792,7 @@ class SupervisorHierarchySpec extends PekkoSpec(SupervisorHierarchySpec.config) val countDownMax = new CountDownLatch(1) val boss = system.actorOf(Props(new Actor { override val supervisorStrategy = - OneForOneStrategy(maxNrOfRetries = 1, withinTimeRange = 5 seconds)(List(classOf[Throwable])) + OneForOneStrategy(maxNrOfRetries = 1, withinTimeRange = 5.seconds)(List(classOf[Throwable])) val crasher = context.watch( context.actorOf(Props(new CountDownActor(countDownMessages, SupervisorStrategy.defaultStrategy)))) @@ -853,7 +852,7 @@ class SupervisorHierarchySpec extends PekkoSpec(SupervisorHierarchySpec.config) boss ! "fail" awaitCond(worker.asInstanceOf[LocalActorRef].underlying.mailbox.isSuspended) worker ! "ping" - expectNoMessage(2 seconds) + expectNoMessage(2.seconds) latch.countDown() } expectMsg("pong") @@ -935,7 +934,7 @@ class SupervisorHierarchySpec extends PekkoSpec(SupervisorHierarchySpec.config) fsm ! Init - expectMsg(110 seconds, "stressTestSuccessful") + expectMsg(110.seconds, "stressTestSuccessful") expectMsg("stressTestStopped") } } diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/SupervisorMiscSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/SupervisorMiscSpec.scala index cb6941f62da..e115f4a10bf 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/SupervisorMiscSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/SupervisorMiscSpec.scala @@ -20,7 +20,6 @@ import scala.concurrent.duration._ import scala.util.control.NonFatal import scala.annotation.nowarn -import language.postfixOps import org.apache.pekko import pekko.pattern.ask @@ -49,7 +48,7 @@ class SupervisorMiscSpec extends PekkoSpec(SupervisorMiscSpec.config) with Defau val countDownLatch = new CountDownLatch(4) val supervisor = system.actorOf(Props( - new Supervisor(OneForOneStrategy(maxNrOfRetries = 3, withinTimeRange = 5 seconds)(List(classOf[Exception]))))) + new Supervisor(OneForOneStrategy(maxNrOfRetries = 3, withinTimeRange = 5.seconds)(List(classOf[Exception]))))) val workerProps = Props(new Actor { override def postRestart(cause: Throwable): Unit = { countDownLatch.countDown() } diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/SupervisorSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/SupervisorSpec.scala index 22801ed2e1d..cfbf1950d18 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/SupervisorSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/SupervisorSpec.scala @@ -20,7 +20,6 @@ import scala.concurrent.duration._ import com.typesafe.config.Config import com.typesafe.config.ConfigFactory -import language.postfixOps import org.scalatest.BeforeAndAfterEach import org.apache.pekko @@ -224,7 +223,7 @@ class SupervisorSpec def killExpectNoRestart(pingPongActor: ActorRef) = { val result = pingPongActor.?(DieReply)(DilatedTimeout) - expectNoMessage(500 milliseconds) + expectNoMessage(500.milliseconds) intercept[RuntimeException] { Await.result(result, DilatedTimeout) } } @@ -234,8 +233,8 @@ class SupervisorSpec val master = system.actorOf(Props(new Master(testActor))) master ! Die - expectMsg(3 seconds, "terminated") - expectNoMessage(1 second) + expectMsg(3.seconds, "terminated") + expectNoMessage(1.second) } "restart properly when same instance is returned" in { @@ -287,7 +286,7 @@ class SupervisorSpec expectMsg("postStop1") } - expectNoMessage(1 second) + expectNoMessage(1.second) } "not restart temporary actor" in { @@ -295,13 +294,13 @@ class SupervisorSpec intercept[RuntimeException] { Await.result(temporaryActor.?(DieReply)(DilatedTimeout), DilatedTimeout) } - expectNoMessage(1 second) + expectNoMessage(1.second) } "start server for nested supervisor hierarchy" in { val (actor1, _, _, _) = nestedSupervisorsAllForOne ping(actor1) - expectNoMessage(1 second) + expectNoMessage(1.second) } "kill single actor OneForOne" in { @@ -420,7 +419,7 @@ class SupervisorSpec "attempt restart when exception during restart" in { val inits = new AtomicInteger(0) val supervisor = system.actorOf(Props( - new Supervisor(OneForOneStrategy(maxNrOfRetries = 3, withinTimeRange = 10 seconds)(classOf[Exception] :: Nil)))) + new Supervisor(OneForOneStrategy(maxNrOfRetries = 3, withinTimeRange = 10.seconds)(classOf[Exception] :: Nil)))) val dyingProps = Props(new Actor { val init = inits.getAndIncrement() @@ -467,7 +466,7 @@ class SupervisorSpec val child = context.watch(context.actorOf(Props(new Actor { override def postRestart(reason: Throwable): Unit = testActor ! "child restarted" def receive = { - case l: TestLatch => { Await.ready(l, 5 seconds); throw new IllegalStateException("OHNOES") } + case l: TestLatch => { Await.ready(l, 5.seconds); throw new IllegalStateException("OHNOES") } case "test" => sender() ! "child green" } }), "child")) @@ -589,7 +588,7 @@ class SupervisorSpec "treats maxNrOfRetries = -1 as maxNrOfRetries = 1 if withinTimeRange is non-infinite Duration" in { val supervisor = system.actorOf(Props( - new Supervisor(OneForOneStrategy(maxNrOfRetries = -1, withinTimeRange = 10 seconds)(classOf[Exception] :: Nil)))) + new Supervisor(OneForOneStrategy(maxNrOfRetries = -1, withinTimeRange = 10.seconds)(classOf[Exception] :: Nil)))) val pingpong = child(supervisor, Props(new PingPongActor(testActor))) diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/SupervisorTreeSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/SupervisorTreeSpec.scala index 6c442d9784b..804fadba837 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/SupervisorTreeSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/SupervisorTreeSpec.scala @@ -16,8 +16,6 @@ package org.apache.pekko.actor import scala.concurrent.Await import scala.concurrent.duration._ -import language.postfixOps - import org.apache.pekko import pekko.pattern.ask import pekko.testkit.{ DefaultTimeout, EventFilter, ImplicitSender, PekkoSpec } @@ -28,10 +26,10 @@ class SupervisorTreeSpec extends PekkoSpec with ImplicitSender with DefaultTimeo "be able to kill the middle actor and see itself and its child restarted" in { EventFilter[ActorKilledException](occurrences = 1).intercept { - within(5 seconds) { + within(5.seconds) { val p = Props(new Actor { override val supervisorStrategy = - OneForOneStrategy(maxNrOfRetries = 3, withinTimeRange = 1 second)(List(classOf[Exception])) + OneForOneStrategy(maxNrOfRetries = 3, withinTimeRange = 1.second)(List(classOf[Exception])) def receive = { case p: Props => sender() ! context.actorOf(p) } @@ -44,7 +42,7 @@ class SupervisorTreeSpec extends PekkoSpec with ImplicitSender with DefaultTimeo middleActor ! Kill expectMsg(middleActor.path) expectMsg(lastActor.path) - expectNoMessage(2 seconds) + expectNoMessage(2.seconds) system.stop(headActor) } } diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/Ticket669Spec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/Ticket669Spec.scala index dc298923d0f..faf1968b0ab 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/Ticket669Spec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/Ticket669Spec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.actor import scala.concurrent.Await import scala.concurrent.duration._ -import language.postfixOps import org.scalatest.BeforeAndAfterAll import org.apache.pekko @@ -38,7 +37,7 @@ class Ticket669Spec extends PekkoSpec with BeforeAndAfterAll with ImplicitSender "be able to reply on failure during preRestart" in { filterEvents(EventFilter[Exception]("test", occurrences = 1)) { val supervisor = - system.actorOf(Props(new Supervisor(AllForOneStrategy(5, 10 seconds)(List(classOf[Exception]))))) + system.actorOf(Props(new Supervisor(AllForOneStrategy(5, 10.seconds)(List(classOf[Exception]))))) val supervised = Await.result((supervisor ? Props[Supervised]()).mapTo[ActorRef], timeout.duration) supervised.!("test")(testActor) diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/TypedActorSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/TypedActorSpec.scala index 828fd86c510..8e515f28333 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/TypedActorSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/TypedActorSpec.scala @@ -20,7 +20,6 @@ import scala.annotation.tailrec import scala.collection.immutable import scala.concurrent.{ Await, Future } import scala.concurrent.duration._ -import scala.language.postfixOps import scala.annotation.nowarn import org.scalatest.{ BeforeAndAfterAll, BeforeAndAfterEach } @@ -148,7 +147,7 @@ object TypedActorSpec { @nowarn def futureComposePigdogFrom(foo: Foo): Future[String] = { - foo.futurePigdog(500 millis).map(_.toUpperCase) + foo.futurePigdog(500.millis).map(_.toUpperCase) } def optionPigdog(): Option[String] = Some(pigdog()) @@ -360,7 +359,7 @@ class TypedActorSpec "be able to call Future-returning methods non-blockingly" in { val t = newFooBar - val f = t.futurePigdog(200 millis) + val f = t.futurePigdog(200.millis) f.isCompleted should ===(false) Await.result(f, timeout.duration) should ===("Pigdog") mustStop(t) @@ -368,7 +367,7 @@ class TypedActorSpec "be able to call multiple Future-returning methods non-blockingly" in within(timeout.duration) { val t = newFooBar - val futures = for (i <- 1 to 20) yield (i, t.futurePigdog(20 millis, i)) + val futures = for (i <- 1 to 20) yield (i, t.futurePigdog(20.millis, i)) for ((i, f) <- futures) { Await.result(f, remaining) should ===("Pigdog" + i) } @@ -376,22 +375,22 @@ class TypedActorSpec } "be able to call methods returning Java Options" taggedAs TimingTest in { - val t = newFooBar(1 second) - t.joptionPigdog(100 millis).get should ===("Pigdog") - t.joptionPigdog(2 seconds) should ===(JOption.none[String]) + val t = newFooBar(1.second) + t.joptionPigdog(100.millis).get should ===("Pigdog") + t.joptionPigdog(2.seconds) should ===(JOption.none[String]) mustStop(t) } "be able to handle AskTimeoutException as None" taggedAs TimingTest in { - val t = newFooBar(200 millis) - t.joptionPigdog(600 millis) should ===(JOption.none[String]) + val t = newFooBar(200.millis) + t.joptionPigdog(600.millis) should ===(JOption.none[String]) mustStop(t) } "be able to call methods returning Scala Options" taggedAs TimingTest in { - val t = newFooBar(1 second) - t.optionPigdog(100 millis).get should ===("Pigdog") - t.optionPigdog(2 seconds) should ===(None) + val t = newFooBar(1.second) + t.optionPigdog(100.millis).get should ===("Pigdog") + t.optionPigdog(2.seconds) should ===(None) mustStop(t) } @@ -415,14 +414,14 @@ class TypedActorSpec } })) val t = Await.result( - (boss ? TypedProps[Bar](classOf[Foo], classOf[Bar]).withTimeout(2 seconds)).mapTo[Foo], + (boss ? TypedProps[Bar](classOf[Foo], classOf[Bar]).withTimeout(2.seconds)).mapTo[Foo], timeout.duration) t.incr() t.failingPigdog() t.read() should ===(1) // Make sure state is not reset after failure - intercept[IllegalStateException] { Await.result(t.failingFuturePigdog(), 2 seconds) }.getMessage should ===( + intercept[IllegalStateException] { Await.result(t.failingFuturePigdog(), 2.seconds) }.getMessage should ===( "expected") t.read() should ===(1) // Make sure state is not reset after failure @@ -461,7 +460,7 @@ class TypedActorSpec "be able to support implementation only typed actors" in within(timeout.duration) { val t: Foo = pekko.actor.TypedActor(system).typedActorOf(TypedProps[Bar]()) - val f = t.futurePigdog(200 millis) + val f = t.futurePigdog(200.millis) val f2 = t.futurePigdog(Duration.Zero) f2.isCompleted should ===(false) f.isCompleted should ===(false) @@ -477,10 +476,10 @@ class TypedActorSpec } "be able to use balancing dispatcher" in within(timeout.duration) { - val thais = for (_ <- 1 to 60) yield newFooBar("pooled-dispatcher", 6 seconds) + val thais = for (_ <- 1 to 60) yield newFooBar("pooled-dispatcher", 6.seconds) val iterator = new CyclicIterator(thais) - val results = for (i <- 1 to 120) yield (i, iterator.next().futurePigdog(200 millis, i)) + val results = for (i <- 1 to 120) yield (i, iterator.next().futurePigdog(200.millis, i)) for ((i, r) <- results) Await.result(r, remaining) should ===("Pigdog" + i) diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/dispatch/ActorModelSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/dispatch/ActorModelSpec.scala index 1a64adbdc10..16bafdcf9fa 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/dispatch/ActorModelSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/dispatch/ActorModelSpec.scala @@ -23,7 +23,6 @@ import scala.concurrent.duration._ import scala.annotation.nowarn import com.typesafe.config.Config -import language.postfixOps import org.scalatest.Assertions._ import org.apache.pekko @@ -273,7 +272,7 @@ abstract class ActorModelSpec(config: String) extends PekkoSpec(config) with Def awaitCond(ref match { case r: RepointableRef => r.isStarted case _ => true - }, 1 second, 10 millis) + }, 1.second, 10.millis) } protected def interceptedDispatcher(): MessageDispatcherInterceptor @@ -322,7 +321,7 @@ abstract class ActorModelSpec(config: String) extends PekkoSpec(config) with Def a ! Wait(1000) a ! CountDown(oneAtATime) // in case of serialization violation, restart would happen instead of count down - assertCountDown(oneAtATime, (1.5 seconds).dilated.toMillis, "Processed message when allowed") + assertCountDown(oneAtATime, 1.5.seconds.dilated.toMillis, "Processed message when allowed") assertRefDefaultZero(a)(registers = 1, msgsReceived = 3, msgsProcessed = 3) system.stop(a) @@ -389,7 +388,7 @@ abstract class ActorModelSpec(config: String) extends PekkoSpec(config) with Def val cachedMessage = CountDownNStop(new CountDownLatch(num)) val stopLatch = new CountDownLatch(num) val keepAliveLatch = new CountDownLatch(1) - val waitTime = (20 seconds).dilated.toMillis + val waitTime = 20.seconds.dilated.toMillis val boss = system.actorOf(Props(new Actor { def receive = { case "run" => for (_ <- 1 to num) context.watch(context.actorOf(props)) ! cachedMessage diff --git a/actor-tests/src/test/scala/org/apache/pekko/actor/dispatch/DispatcherActorSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/actor/dispatch/DispatcherActorSpec.scala index 36eb3b875dc..f505b3a3ef8 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/actor/dispatch/DispatcherActorSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/actor/dispatch/DispatcherActorSpec.scala @@ -19,8 +19,6 @@ import java.util.concurrent.atomic.AtomicBoolean import scala.concurrent.Await import scala.concurrent.duration._ -import language.postfixOps - import org.apache.pekko import pekko.actor.{ Actor, Props } import pekko.pattern.ask @@ -112,7 +110,7 @@ class DispatcherActorSpec extends PekkoSpec(DispatcherActorSpec.config) with Def } "respect throughput deadline" in { - val deadline = 100 millis + val deadline = 100.millis val throughputDispatcher = "test-throughput-deadline-dispatcher" val works = new AtomicBoolean(true) diff --git a/actor-tests/src/test/scala/org/apache/pekko/dataflow/Future2Actor.scala b/actor-tests/src/test/scala/org/apache/pekko/dataflow/Future2Actor.scala index a7372d1d5ac..acaf568d6dc 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/dataflow/Future2Actor.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/dataflow/Future2Actor.scala @@ -19,8 +19,6 @@ import scala.concurrent.ExecutionException import scala.concurrent.Future import scala.concurrent.duration._ -import language.postfixOps - import org.apache.pekko import pekko.actor.{ Actor, Props } import pekko.actor.ActorRef @@ -33,20 +31,20 @@ class Future2ActorSpec extends PekkoSpec with DefaultTimeout { "support convenient sending to multiple destinations" in { Future(42).pipeTo(testActor).pipeTo(testActor) - expectMsgAllOf(1 second, 42, 42) + expectMsgAllOf(1.second, 42, 42) } "support convenient sending to multiple destinations with implicit sender" in { implicit val someActor: ActorRef = system.actorOf(Props(new Actor { def receive = Actor.emptyBehavior })) Future(42).pipeTo(testActor).pipeTo(testActor) - expectMsgAllOf(1 second, 42, 42) + expectMsgAllOf(1.second, 42, 42) lastSender should ===(someActor) } "support convenient sending with explicit sender" in { val someActor = system.actorOf(Props(new Actor { def receive = Actor.emptyBehavior })) Future(42).to(testActor, someActor) - expectMsgAllOf(1 second, 42) + expectMsgAllOf(1.second, 42) lastSender should ===(someActor) } diff --git a/actor-tests/src/test/scala/org/apache/pekko/dispatch/MailboxConfigSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/dispatch/MailboxConfigSpec.scala index 02ae1a5624b..a7c6d664fcf 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/dispatch/MailboxConfigSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/dispatch/MailboxConfigSpec.scala @@ -19,7 +19,6 @@ import scala.concurrent.{ Await, ExecutionContext, Future } import scala.concurrent.duration._ import com.typesafe.config.{ Config, ConfigFactory } -import language.postfixOps import org.scalatest.{ BeforeAndAfterAll, BeforeAndAfterEach } import org.apache.pekko @@ -51,11 +50,11 @@ abstract class MailboxSpec extends PekkoSpec with BeforeAndAfterAll with BeforeA } "BoundedMailbox.numberOfMessages should be consistent with queue size" in { - ensureSingleConsumerEnqueueDequeue(BoundedMailbox(1000, 10 milliseconds)) + ensureSingleConsumerEnqueueDequeue(BoundedMailbox(1000, 10.milliseconds)) } "create a bounded mailbox with 10 capacity and with push timeout" in { - val config = BoundedMailbox(10, 10 milliseconds) + val config = BoundedMailbox(10, 10.milliseconds) config.capacity should ===(10) val q = factory(config) ensureInitialMailboxState(config, q) @@ -80,15 +79,15 @@ abstract class MailboxSpec extends PekkoSpec with BeforeAndAfterAll with BeforeA } "dequeue what was enqueued properly for bounded mailboxes" in { - testEnqueueDequeue(BoundedMailbox(10000, -1 millisecond)) + testEnqueueDequeue(BoundedMailbox(10000, -1.millisecond)) } "dequeue what was enqueued properly for bounded mailboxes with 0 pushTimeout" in { - testEnqueueDequeue(BoundedMailbox(10, 0 millisecond), 20, 10, false) + testEnqueueDequeue(BoundedMailbox(10, 0.millisecond), 20, 10, false) } "dequeue what was enqueued properly for bounded mailboxes with pushTimeout" in { - testEnqueueDequeue(BoundedMailbox(10000, 100 milliseconds)) + testEnqueueDequeue(BoundedMailbox(10000, 100.milliseconds)) } } @@ -144,7 +143,7 @@ abstract class MailboxSpec extends PekkoSpec with BeforeAndAfterAll with BeforeA config: MailboxType, enqueueN: Int = 10000, dequeueN: Int = 10000, - parallel: Boolean = true): Unit = within(10 seconds) { + parallel: Boolean = true): Unit = within(10.seconds) { val q = factory(config) ensureInitialMailboxState(config, q) @@ -260,7 +259,7 @@ class CustomMailboxSpec extends PekkoSpec(CustomMailboxSpec.config) { awaitCond(actor match { case r: RepointableRef => r.isStarted case _ => true - }, 1 second, 10 millis) + }, 1.second, 10.millis) val queue = actor.asInstanceOf[ActorRefWithCell].underlying.asInstanceOf[ActorCell].mailbox.messageQueue queue.getClass should ===(classOf[CustomMailboxSpec.MyMailbox]) } diff --git a/actor-tests/src/test/scala/org/apache/pekko/dispatch/PriorityDispatcherSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/dispatch/PriorityDispatcherSpec.scala index 5eb6552cd6f..088446bcc9e 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/dispatch/PriorityDispatcherSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/dispatch/PriorityDispatcherSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.dispatch import scala.concurrent.duration._ import com.typesafe.config.Config -import language.postfixOps import org.apache.pekko import pekko.actor.{ Actor, ActorSystem, Props } @@ -48,7 +47,7 @@ object PriorityDispatcherSpec { case i: Int => i // Reverse order case Result => Int.MaxValue case _ => throw new RuntimeException() // compiler exhaustiveness check pleaser - }: Any => Int), 1000, 10 seconds) + }: Any => Int), 1000, 10.seconds) } @@ -68,7 +67,7 @@ class PriorityDispatcherSpec extends PekkoSpec(PriorityDispatcherSpec.config) wi } def testOrdering(dispatcherKey: String): Unit = { - val msgs = (1 to 100) toList + val msgs = (1 to 100).toList // It's important that the actor under test is not a top level actor // with RepointableActorRef, since messages might be queued in diff --git a/actor-tests/src/test/scala/org/apache/pekko/dispatch/StablePriorityDispatcherSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/dispatch/StablePriorityDispatcherSpec.scala index 88caa4c8fe4..9289409e4a8 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/dispatch/StablePriorityDispatcherSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/dispatch/StablePriorityDispatcherSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.dispatch import scala.concurrent.duration._ import com.typesafe.config.Config -import language.postfixOps import org.apache.pekko import pekko.actor.{ Actor, ActorSystem, Props } @@ -49,7 +48,7 @@ object StablePriorityDispatcherSpec { case _: Int => 101 // Don't care for other integers case Result => Int.MaxValue case _ => throw new RuntimeException() // compiler exhaustiveness check pleaser - }: Any => Int), 1000, 10 seconds) + }: Any => Int), 1000, 10.seconds) } @@ -70,7 +69,7 @@ class StablePriorityDispatcherSpec extends PekkoSpec(StablePriorityDispatcherSpe } def testOrdering(dispatcherKey: String): Unit = { - val msgs = (1 to 200) toList + val msgs = (1 to 200).toList val shuffled = scala.util.Random.shuffle(msgs) // It's important that the actor under test is not a top level actor @@ -100,7 +99,7 @@ class StablePriorityDispatcherSpec extends PekkoSpec(StablePriorityDispatcherSpe // Low messages should come out first, and in priority order. High messages follow - they are equal priority and // should come out in the same order in which they were sent. - val lo = (1 to 100) toList + val lo = (1 to 100).toList val hi = shuffled.filter { _ > 100 } (expectMsgType[List[Int]]: List[Int]) should ===(lo ++ hi) } diff --git a/actor-tests/src/test/scala/org/apache/pekko/event/LoggingReceiveSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/event/LoggingReceiveSpec.scala index 503c6842dda..d89e8af6d77 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/event/LoggingReceiveSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/event/LoggingReceiveSpec.scala @@ -17,7 +17,6 @@ import scala.annotation.tailrec import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import org.scalatest.BeforeAndAfterAll import org.scalatest.wordspec.AnyWordSpec @@ -29,7 +28,7 @@ import pekko.util.ccompat.JavaConverters._ object LoggingReceiveSpec { class TestLogActor extends Actor { override val supervisorStrategy = - OneForOneStrategy(maxNrOfRetries = 5, withinTimeRange = 5 seconds)(List(classOf[Throwable])) + OneForOneStrategy(maxNrOfRetries = 5, withinTimeRange = 5.seconds)(List(classOf[Throwable])) def receive = { case _ => } } } @@ -85,12 +84,12 @@ class LoggingReceiveSpec extends AnyWordSpec with BeforeAndAfterAll { })) a ! "hallo" expectMsg( - 1 second, + 1.second, Logging.Debug( "funky", classOf[DummyClassForStringSources], "received unhandled message hallo from " + system.deadLetters)) - expectMsgType[UnhandledMessage](1 second) + expectMsgType[UnhandledMessage](1.second) } } @@ -206,7 +205,7 @@ class LoggingReceiveSpec extends AnyWordSpec with BeforeAndAfterAll { "log Supervision events if requested" in { new TestKit(appLifecycle) { system.eventStream.subscribe(testActor, classOf[Logging.Debug]) - within(3 seconds) { + within(3.seconds) { val lifecycleGuardian = appLifecycle.asInstanceOf[ActorSystemImpl].guardian val lname = lifecycleGuardian.path.toString val supervisor = TestActorRef[TestLogActor](Props[TestLogActor]()) @@ -230,7 +229,7 @@ class LoggingReceiveSpec extends AnyWordSpec with BeforeAndAfterAll { "log DeathWatch events if requested" in { new TestKit(appLifecycle) { system.eventStream.subscribe(testActor, classOf[Logging.Debug]) - within(3 seconds) { + within(3.seconds) { val supervisor = TestActorRef[TestLogActor](Props[TestLogActor]()) val sclass = classOf[TestLogActor] val actor = TestActorRef[TestLogActor](Props[TestLogActor](), supervisor, "none") @@ -255,7 +254,7 @@ class LoggingReceiveSpec extends AnyWordSpec with BeforeAndAfterAll { new TestKit(appLifecycle) { system.eventStream.subscribe(testActor, classOf[Logging.Debug]) system.eventStream.subscribe(testActor, classOf[Logging.Error]) - within(3 seconds) { + within(3.seconds) { val supervisor = TestActorRef[TestLogActor](Props[TestLogActor]()) val sname = supervisor.path.toString val sclass = classOf[TestLogActor] diff --git a/actor-tests/src/test/scala/org/apache/pekko/io/TcpIntegrationSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/io/TcpIntegrationSpec.scala index f02bb50beeb..499b8ed0218 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/io/TcpIntegrationSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/io/TcpIntegrationSpec.scala @@ -17,7 +17,6 @@ import java.io.IOException import java.net.{ InetSocketAddress, ServerSocket } import scala.concurrent.duration._ -import scala.language.postfixOps import org.scalatest.concurrent.TimeLimits @@ -194,7 +193,7 @@ class TcpIntegrationSpec extends PekkoSpec(""" connectCommander.expectMsgType[Connected].remoteAddress should ===(endpoint) val connectionActor = connectCommander.lastSender connectCommander.send(connectionActor, PoisonPill) - failAfter(3 seconds) { + failAfter(3.seconds) { try { accept.getInputStream.read() should ===(-1) } catch { diff --git a/actor-tests/src/test/scala/org/apache/pekko/pattern/AskSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/pattern/AskSpec.scala index e84777167b5..e79024c34d1 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/pattern/AskSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/pattern/AskSpec.scala @@ -18,8 +18,6 @@ import scala.concurrent.duration._ import scala.util.Failure import scala.annotation.nowarn -import language.postfixOps - import org.apache.pekko import pekko.actor._ import pekko.testkit.{ PekkoSpec, TestProbe } @@ -41,7 +39,7 @@ class AskSpec extends PekkoSpec(""" } "return broken promises on DeadLetters" in { - val f = system.deadLetters.ask(42)(1 second) + val f = system.deadLetters.ask(42)(1.second) f.isCompleted should ===(true) f.value.get match { case Failure(_: AskTimeoutException) => @@ -50,7 +48,7 @@ class AskSpec extends PekkoSpec(""" } "return broken promises on EmptyLocalActorRefs" in { - implicit val timeout: Timeout = Timeout(5 seconds) + implicit val timeout: Timeout = Timeout(5.seconds) val empty = system.asInstanceOf[ExtendedActorSystem].provider.resolveActorRef("/user/unknown") val f = empty ? 3.14 f.isCompleted should ===(true) @@ -61,7 +59,7 @@ class AskSpec extends PekkoSpec(""" } "return broken promises on unsupported ActorRefs" in { - implicit val timeout: Timeout = Timeout(5 seconds) + implicit val timeout: Timeout = Timeout(5.seconds) val f = ask(null: ActorRef, 3.14) f.isCompleted should ===(true) @@ -72,7 +70,7 @@ class AskSpec extends PekkoSpec(""" } "return broken promises on 0 timeout" in { - implicit val timeout: Timeout = Timeout(0 seconds) + implicit val timeout: Timeout = Timeout(0.seconds) val echo = system.actorOf(Props(new Actor { def receive = { case x => sender() ! x } })) val f = echo ? "foo" val expectedMsg = @@ -83,7 +81,7 @@ class AskSpec extends PekkoSpec(""" } "return broken promises on < 0 timeout" in { - implicit val timeout: Timeout = Timeout(-1000 seconds) + implicit val timeout: Timeout = Timeout(-1000.seconds) val echo = system.actorOf(Props(new Actor { def receive = { case x => sender() ! x } })) val f = echo ? "foo" val expectedMsg = @@ -94,51 +92,51 @@ class AskSpec extends PekkoSpec(""" } "include target information in AskTimeout" in { - implicit val timeout: Timeout = Timeout(0.5 seconds) + implicit val timeout: Timeout = Timeout(0.5.seconds) val silentOne = system.actorOf(Props.empty, "silent") val f = silentOne ? "noreply" intercept[AskTimeoutException] { - Await.result(f, 1 second) + Await.result(f, 1.second) }.getMessage.contains("/user/silent") should ===(true) } "include timeout information in AskTimeout" in { - implicit val timeout: Timeout = Timeout(0.5 seconds) + implicit val timeout: Timeout = Timeout(0.5.seconds) val f = system.actorOf(Props.empty) ? "noreply" intercept[AskTimeoutException] { - Await.result(f, 1 second) + Await.result(f, 1.second) }.getMessage should include(timeout.duration.toMillis.toString) } "include sender information in AskTimeout" in { - implicit val timeout: Timeout = Timeout(0.5 seconds) + implicit val timeout: Timeout = Timeout(0.5.seconds) implicit val sender: ActorRef = system.actorOf(Props.empty) val f = system.actorOf(Props.empty) ? "noreply" intercept[AskTimeoutException] { - Await.result(f, 1 second) + Await.result(f, 1.second) }.getMessage.contains(sender.toString) should ===(true) } "include message class information in AskTimeout" in { - implicit val timeout: Timeout = Timeout(0.5 seconds) + implicit val timeout: Timeout = Timeout(0.5.seconds) val f = system.actorOf(Props.empty) ? Integer.valueOf(17) intercept[AskTimeoutException] { - Await.result(f, 1 second) + Await.result(f, 1.second) }.getMessage should include("[java.lang.Integer") } "work for ActorSelection" in { - implicit val timeout: Timeout = Timeout(5 seconds) + implicit val timeout: Timeout = Timeout(5.seconds) import system.dispatcher val echo = system.actorOf(Props(new Actor { def receive = { case x => sender() ! x } }), "select-echo") val identityFuture = (system.actorSelection("/user/select-echo") ? Identify(None)).mapTo[ActorIdentity].map(_.ref.get) - Await.result(identityFuture, 5 seconds) should ===(echo) + Await.result(identityFuture, 5.seconds) should ===(echo) } "work when reply uses actor selection" in { - implicit val timeout: Timeout = Timeout(5 seconds) + implicit val timeout: Timeout = Timeout(5.seconds) val deadListener = TestProbe() system.eventStream.subscribe(deadListener.ref, classOf[DeadLetter]) @@ -147,13 +145,13 @@ class AskSpec extends PekkoSpec(""" }), "select-echo2") val f = echo ? "hi" - Await.result(f, 1 seconds) should ===("hi") + Await.result(f, 1.seconds) should ===("hi") - deadListener.expectNoMessage(200 milliseconds) + deadListener.expectNoMessage(200.milliseconds) } "throw AskTimeoutException on using *" in { - implicit val timeout: Timeout = Timeout(0.5 seconds) + implicit val timeout: Timeout = Timeout(0.5.seconds) val deadListener = TestProbe() system.eventStream.subscribe(deadListener.ref, classOf[DeadLetter]) @@ -162,14 +160,14 @@ class AskSpec extends PekkoSpec(""" "select-echo3") val f = echo ? "hi" intercept[AskTimeoutException] { - Await.result(f, 1 seconds) + Await.result(f, 1.seconds) } - deadListener.expectMsgClass(200 milliseconds, classOf[DeadLetter]) + deadListener.expectMsgClass(200.milliseconds, classOf[DeadLetter]) } "throw AskTimeoutException on using .." in { - implicit val timeout: Timeout = Timeout(0.5 seconds) + implicit val timeout: Timeout = Timeout(0.5.seconds) val deadListener = TestProbe() system.eventStream.subscribe(deadListener.ref, classOf[DeadLetter]) @@ -183,14 +181,14 @@ class AskSpec extends PekkoSpec(""" }), "select-echo4") val f = echo ? "hi" intercept[AskTimeoutException] { - Await.result(f, 1 seconds) should ===("hi") + Await.result(f, 1.seconds) should ===("hi") } - deadListener.expectMsgClass(200 milliseconds, classOf[DeadLetter]) + deadListener.expectMsgClass(200.milliseconds, classOf[DeadLetter]) } "send to DeadLetter when child does not exist" in { - implicit val timeout: Timeout = Timeout(0.5 seconds) + implicit val timeout: Timeout = Timeout(0.5.seconds) val deadListener = TestProbe() system.eventStream.subscribe(deadListener.ref, classOf[DeadLetter]) @@ -203,13 +201,13 @@ class AskSpec extends PekkoSpec(""" }), "select-echo5") val f = echo ? "hi" intercept[AskTimeoutException] { - Await.result(f, 1 seconds) should ===("hi") + Await.result(f, 1.seconds) should ===("hi") } - deadListener.expectMsgClass(200 milliseconds, classOf[DeadLetter]) + deadListener.expectMsgClass(200.milliseconds, classOf[DeadLetter]) } "send DeadLetter when answering to grandchild" in { - implicit val timeout: Timeout = Timeout(0.5 seconds) + implicit val timeout: Timeout = Timeout(0.5.seconds) val deadListener = TestProbe() system.eventStream.subscribe(deadListener.ref, classOf[DeadLetter]) @@ -221,13 +219,13 @@ class AskSpec extends PekkoSpec(""" }), "select-echo6") val f = echo ? "hi" intercept[AskTimeoutException] { - Await.result(f, 1 seconds) should ===(ActorSelectionMessage("hi", Vector(SelectChildName("missing")), false)) + Await.result(f, 1.seconds) should ===(ActorSelectionMessage("hi", Vector(SelectChildName("missing")), false)) } - deadListener.expectMsgClass(200 milliseconds, classOf[DeadLetter]) + deadListener.expectMsgClass(200.milliseconds, classOf[DeadLetter]) } "allow watching the promiseActor and send Terminated() when completes" in { - implicit val timeout: Timeout = Timeout(300 millis) + implicit val timeout: Timeout = Timeout(300.millis) val p = TestProbe() val act = system.actorOf(Props(new Actor { @@ -248,7 +246,7 @@ class AskSpec extends PekkoSpec(""" } "encode target name in temporary actor name" in { - implicit val timeout: Timeout = Timeout(300 millis) + implicit val timeout: Timeout = Timeout(300.millis) val p = TestProbe() val act = system.actorOf(Props(new Actor { @@ -268,7 +266,7 @@ class AskSpec extends PekkoSpec(""" } "proper path when promise actor terminated" in { - implicit val timeout: Timeout = Timeout(300 millis) + implicit val timeout: Timeout = Timeout(300.millis) val p = TestProbe() val act = system.actorOf(Props(new Actor { diff --git a/actor-tests/src/test/scala/org/apache/pekko/pattern/BackoffOnRestartSupervisorSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/pattern/BackoffOnRestartSupervisorSpec.scala index d739891d619..f17bff441b2 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/pattern/BackoffOnRestartSupervisorSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/pattern/BackoffOnRestartSupervisorSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.pattern import java.util.concurrent.{ CountDownLatch, TimeUnit } import scala.concurrent.duration._ -import scala.language.postfixOps import scala.annotation.nowarn @@ -70,9 +69,9 @@ class BackoffOnRestartSupervisorSpec extends PekkoSpec(""" def supervisorProps(probeRef: ActorRef) = { val options = BackoffOpts - .onFailure(TestActor.props(probeRef), "someChildName", 200 millis, 10 seconds, 0.0) + .onFailure(TestActor.props(probeRef), "someChildName", 200.millis, 10.seconds, 0.0) .withMaxNrOfRetries(-1) - .withSupervisorStrategy(OneForOneStrategy(maxNrOfRetries = 5, withinTimeRange = 30 seconds) { + .withSupervisorStrategy(OneForOneStrategy(maxNrOfRetries = 5, withinTimeRange = 30.seconds) { case _: TestActor.StoppingException => SupervisorStrategy.Stop }) BackoffSupervisor.props(options) @@ -105,23 +104,23 @@ class BackoffOnRestartSupervisorSpec extends PekkoSpec(""" // Exponential back off restart test supervisor ! "THROW" // numRestart = 0: expected delay ~200 millis - probe.expectNoMessage(200 millis) - probe.expectMsg(250 millis, "STARTED") + probe.expectNoMessage(200.millis) + probe.expectMsg(250.millis, "STARTED") supervisor ! "THROW" // numRestart = 1: expected delay ~400 millis - probe.expectNoMessage(400 millis) - probe.expectMsg(250 millis, "STARTED") + probe.expectNoMessage(400.millis) + probe.expectMsg(250.millis, "STARTED") supervisor ! "THROW" // numRestart = 2: expected delay ~800 millis - probe.expectNoMessage(800 millis) - probe.expectMsg(250 millis, "STARTED") + probe.expectNoMessage(800.millis) + probe.expectMsg(250.millis, "STARTED") supervisor ! "THROW" // numRestart = 3: expected delay ~1600 millis - probe.expectNoMessage(1600 millis) - probe.expectMsg(250 millis, "STARTED") + probe.expectNoMessage(1600.millis) + probe.expectMsg(250.millis, "STARTED") // Verify that we only have one child at this point by selecting all the children // under the supervisor and broadcasting to them. @@ -166,7 +165,7 @@ class BackoffOnRestartSupervisorSpec extends PekkoSpec(""" val postStopLatch = new CountDownLatch(1) @nowarn val options = BackoffOpts - .onFailure(Props(new SlowlyFailingActor(postStopLatch)), "someChildName", 1 nanos, 1 nanos, 0.0) + .onFailure(Props(new SlowlyFailingActor(postStopLatch)), "someChildName", 1.nanos, 1.nanos, 0.0) .withMaxNrOfRetries(-1) .withSupervisorStrategy(OneForOneStrategy(loggingEnabled = false) { case _: TestActor.StoppingException => SupervisorStrategy.Stop @@ -212,7 +211,7 @@ class BackoffOnRestartSupervisorSpec extends PekkoSpec(""" if (i < 6) { // Since we should've died on this throw, don't expect to be started. // We're not testing timing, so set a reasonably high timeout. - probe.expectMsg(4 seconds, "STARTED") + probe.expectMsg(4.seconds, "STARTED") } } // Supervisor should've terminated. @@ -228,7 +227,7 @@ class BackoffOnRestartSupervisorSpec extends PekkoSpec(""" val options = BackoffOpts .onFailure(TestActor.props(probe.ref), "someChildName", 300.millis, 10.seconds, 0.0) .withMaxNrOfRetries(-1) - .withSupervisorStrategy(OneForOneStrategy(withinTimeRange = 1 seconds, maxNrOfRetries = 3) { + .withSupervisorStrategy(OneForOneStrategy(withinTimeRange = 1.seconds, maxNrOfRetries = 3) { case _: TestActor.StoppingException => SupervisorStrategy.Stop }) val supervisor = system.actorOf(BackoffSupervisor.props(options)) diff --git a/actor-tests/src/test/scala/org/apache/pekko/pattern/CircuitBreakerSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/pattern/CircuitBreakerSpec.scala index e1c125eab8f..72f3691d586 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/pattern/CircuitBreakerSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/pattern/CircuitBreakerSpec.scala @@ -19,7 +19,6 @@ import scala.concurrent.ExecutionContextExecutor import scala.concurrent.Future import scala.concurrent.TimeoutException import scala.concurrent.duration._ -import scala.language.postfixOps import scala.util.Failure import scala.util.Success import scala.util.Try @@ -119,7 +118,7 @@ class CircuitBreakerSpec extends PekkoSpec(""" new Breaker(new CircuitBreaker(system.scheduler, 1, 1000.millis.dilated, shortResetTimeout)) def longCallTimeoutCb()(implicit system: ActorSystem, ec: ExecutionContext): Breaker = - new Breaker(new CircuitBreaker(system.scheduler, 1, 5 seconds, 500.millis.dilated)) + new Breaker(new CircuitBreaker(system.scheduler, 1, 5.seconds, 500.millis.dilated)) val longResetTimeout = 5.seconds.dilated def longResetTimeoutCb()(implicit system: ActorSystem, ec: ExecutionContext): Breaker = diff --git a/actor-tests/src/test/scala/org/apache/pekko/pattern/PatternSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/pattern/PatternSpec.scala index 3e70bc781dc..56853ba50ff 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/pattern/PatternSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/pattern/PatternSpec.scala @@ -17,8 +17,6 @@ import scala.concurrent.{ Await, Future, Promise } import scala.concurrent.ExecutionContextExecutor import scala.concurrent.duration._ -import language.postfixOps - import org.apache.pekko import pekko.actor.{ Actor, Props } import pekko.testkit.{ PekkoSpec, TestLatch } @@ -41,21 +39,21 @@ class PatternSpec extends PekkoSpec { "provide Future for stopping an actor" in { val target = system.actorOf(Props[TargetActor]()) - val result = gracefulStop(target, 5 seconds) - Await.result(result, 6 seconds) should ===(true) + val result = gracefulStop(target, 5.seconds) + Await.result(result, 6.seconds) should ===(true) } "complete Future when actor already terminated" in { val target = system.actorOf(Props[TargetActor]()) - Await.ready(gracefulStop(target, 5 seconds), 6 seconds) - Await.ready(gracefulStop(target, 1 millis), 1 second) + Await.ready(gracefulStop(target, 5.seconds), 6.seconds) + Await.ready(gracefulStop(target, 1.millis), 1.second) } "complete Future with AskTimeoutException when actor not terminated within timeout" in { val target = system.actorOf(Props[TargetActor]()) val latch = TestLatch() target ! ((latch, remainingOrDefault)) - intercept[AskTimeoutException] { Await.result(gracefulStop(target, 500 millis), remainingOrDefault) } + intercept[AskTimeoutException] { Await.result(gracefulStop(target, 500.millis), remainingOrDefault) } latch.open() } } @@ -63,7 +61,7 @@ class PatternSpec extends PekkoSpec { "pattern.after" must { "be completed successfully eventually" in { // TODO after is unfortunately shadowed by ScalaTest, fix as part of #3759 - val f = pekko.pattern.after(1 second, using = system.scheduler)(Future.successful(5)) + val f = pekko.pattern.after(1.second, using = system.scheduler)(Future.successful(5)) val r = Future.firstCompletedOf(Seq(Promise[Int]().future, f)) Await.result(r, remainingOrDefault) should ===(5) @@ -72,7 +70,7 @@ class PatternSpec extends PekkoSpec { "be completed abnormally eventually" in { // TODO after is unfortunately shadowed by ScalaTest, fix as part of #3759 val f = - pekko.pattern.after(1 second, using = system.scheduler)(Future.failed(new IllegalStateException("Mexico"))) + pekko.pattern.after(1.second, using = system.scheduler)(Future.failed(new IllegalStateException("Mexico"))) val r = Future.firstCompletedOf(Seq(Promise[Int]().future, f)) intercept[IllegalStateException] { Await.result(r, remainingOrDefault) }.getMessage should ===("Mexico") diff --git a/actor-tests/src/test/scala/org/apache/pekko/pattern/RetrySpec.scala b/actor-tests/src/test/scala/org/apache/pekko/pattern/RetrySpec.scala index 5aa9e093c3e..26b78b37a9f 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/pattern/RetrySpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/pattern/RetrySpec.scala @@ -16,8 +16,6 @@ package org.apache.pekko.pattern import scala.concurrent.{ Await, ExecutionContextExecutor, Future } import scala.concurrent.duration._ -import language.postfixOps - import org.apache.pekko import pekko.actor.Scheduler import pekko.testkit.PekkoSpec @@ -30,9 +28,9 @@ class RetrySpec extends PekkoSpec with RetrySupport { "pattern.retry" must { "run a successful Future immediately" in { - val retried = retry(() => Future.successful(5), 5, 1 second) + val retried = retry(() => Future.successful(5), 5, 1.second) - within(3 seconds) { + within(3.seconds) { Await.result(retried, remaining) should ===(5) } } @@ -46,17 +44,17 @@ class RetrySpec extends PekkoSpec with RetrySupport { counter }, 5, - 1 second) + 1.second) - within(3 seconds) { + within(3.seconds) { Await.result(retried, remaining) should ===(1) } } "eventually return a failure for a Future that will never succeed" in { - val retried = retry(() => Future.failed(new IllegalStateException("Mexico")), 5, 100 milliseconds) + val retried = retry(() => Future.failed(new IllegalStateException("Mexico")), 5, 100.milliseconds) - within(3 second) { + within(3.second) { intercept[IllegalStateException] { Await.result(retried, remaining) }.getMessage should ===("Mexico") } } @@ -71,9 +69,9 @@ class RetrySpec extends PekkoSpec with RetrySupport { } else Future.successful(5) } - val retried = retry(() => attempt(), 10, 100 milliseconds) + val retried = retry(() => attempt(), 10, 100.milliseconds) - within(3 seconds) { + within(3.seconds) { Await.result(retried, remaining) should ===(5) } } @@ -88,9 +86,9 @@ class RetrySpec extends PekkoSpec with RetrySupport { } else Future.successful(5) } - val retried = retry(() => attempt(), 5, 100 milliseconds) + val retried = retry(() => attempt(), 5, 100.milliseconds) - within(3 seconds) { + within(3.seconds) { intercept[IllegalStateException] { Await.result(retried, remaining) }.getMessage should ===("6") } } @@ -111,7 +109,7 @@ class RetrySpec extends PekkoSpec with RetrySupport { attemptedCount = attempted Some(100.milliseconds * attempted) }) - within(30000000 seconds) { + within(30000000.seconds) { intercept[IllegalStateException] { Await.result(retried, remaining) }.getMessage should ===("6") attemptedCount shouldBe 5 } @@ -129,7 +127,7 @@ class RetrySpec extends PekkoSpec with RetrySupport { val start = System.currentTimeMillis() val retried = retry(() => attempt(), 999) - within(1 seconds) { + within(1.seconds) { intercept[IllegalStateException] { Await.result(retried, remaining) }.getMessage should ===("1000") @@ -148,9 +146,9 @@ class RetrySpec extends PekkoSpec with RetrySupport { } else Future.successful(5) } - val retried = retry(() => attempt(), 10, 100 milliseconds) + val retried = retry(() => attempt(), 10, 100.milliseconds) - within(3 seconds) { + within(3.seconds) { Await.result(retried, remaining) should ===(5) } } @@ -161,9 +159,9 @@ class RetrySpec extends PekkoSpec with RetrySupport { Future.successful(counter.incrementAndGet()) } - val retried = retry(() => attempt(), (t: Int, _) => t < 5, 10, 100 milliseconds) + val retried = retry(() => attempt(), (t: Int, _) => t < 5, 10, 100.milliseconds) - within(3 seconds) { + within(3.seconds) { Await.result(retried, remaining) should ===(5) } } @@ -178,9 +176,9 @@ class RetrySpec extends PekkoSpec with RetrySupport { } val retried = - retry(() => attempt(), (_: Int, e) => !e.isInstanceOf[IllegalArgumentException], 10, 100 milliseconds) + retry(() => attempt(), (_: Int, e) => !e.isInstanceOf[IllegalArgumentException], 10, 100.milliseconds) - within(3 seconds) { + within(3.seconds) { retried.failed.futureValue shouldBe an[IllegalArgumentException] counter.get() should ===(1) } diff --git a/actor-tests/src/test/scala/org/apache/pekko/routing/ConfiguredLocalRoutingSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/routing/ConfiguredLocalRoutingSpec.scala index 2e33fdbad4d..cbd6b97c898 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/routing/ConfiguredLocalRoutingSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/routing/ConfiguredLocalRoutingSpec.scala @@ -19,7 +19,6 @@ import scala.concurrent.duration._ import scala.annotation.nowarn import com.typesafe.config.Config -import language.postfixOps import org.apache.pekko import pekko.ConfigurationException @@ -142,19 +141,19 @@ class ConfiguredLocalRoutingSpec "be picked up from Props" in { val actor = system.actorOf(RoundRobinPool(12).props(routeeProps = Props[EchoProps]()), "someOther") routerConfig(actor) should ===(RoundRobinPool(12)) - Await.result(gracefulStop(actor, 3 seconds), 3 seconds) + Await.result(gracefulStop(actor, 3.seconds), 3.seconds) } "be overridable in config" in { val actor = system.actorOf(RoundRobinPool(12).props(routeeProps = Props[EchoProps]()), "config") routerConfig(actor) should ===(RandomPool(nrOfInstances = 4, usePoolDispatcher = true)) - Await.result(gracefulStop(actor, 3 seconds), 3 seconds) + Await.result(gracefulStop(actor, 3.seconds), 3.seconds) } "use routees.paths from config" in { val actor = system.actorOf(RandomPool(12).props(routeeProps = Props[EchoProps]()), "paths") routerConfig(actor) should ===(RandomGroup(List("/user/service1", "/user/service2"))) - Await.result(gracefulStop(actor, 3 seconds), 3 seconds) + Await.result(gracefulStop(actor, 3.seconds), 3.seconds) } "be overridable in explicit deployment" in { @@ -162,7 +161,7 @@ class ConfiguredLocalRoutingSpec FromConfig.props(routeeProps = Props[EchoProps]()).withDeploy(Deploy(routerConfig = RoundRobinPool(12))), "someOther") routerConfig(actor) should ===(RoundRobinPool(12)) - Await.result(gracefulStop(actor, 3 seconds), 3 seconds) + Await.result(gracefulStop(actor, 3.seconds), 3.seconds) } "be overridable in config even with explicit deployment" in { @@ -170,7 +169,7 @@ class ConfiguredLocalRoutingSpec FromConfig.props(routeeProps = Props[EchoProps]()).withDeploy(Deploy(routerConfig = RoundRobinPool(12))), "config") routerConfig(actor) should ===(RandomPool(nrOfInstances = 4, usePoolDispatcher = true)) - Await.result(gracefulStop(actor, 3 seconds), 3 seconds) + Await.result(gracefulStop(actor, 3.seconds), 3.seconds) } "fail with an exception if not correct" in { @@ -185,7 +184,7 @@ class ConfiguredLocalRoutingSpec @nowarn val expc = Set('a', 'b', 'c').map(i => "/user/weird/$" + i) recv should ===(expc) - expectNoMessage(1 second) + expectNoMessage(1.second) } "support custom router" in { diff --git a/actor-tests/src/test/scala/org/apache/pekko/routing/RandomSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/routing/RandomSpec.scala index f99cf9b600e..0b850fe32a6 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/routing/RandomSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/routing/RandomSpec.scala @@ -18,8 +18,6 @@ import java.util.concurrent.atomic.AtomicInteger import scala.concurrent.Await import scala.concurrent.duration._ -import language.postfixOps - import org.apache.pekko import pekko.actor.{ Actor, Props } import pekko.pattern.ask @@ -48,12 +46,12 @@ class RandomSpec extends PekkoSpec with DefaultTimeout with ImplicitSender { actor ! "hello" actor ! "hello" - within(2 seconds) { + within(2.seconds) { for (_ <- 1 to 5) expectMsg("world") } system.stop(actor) - Await.ready(stopLatch, 5 seconds) + Await.ready(stopLatch, 5.seconds) } "deliver messages in a random fashion" in { @@ -85,7 +83,7 @@ class RandomSpec extends PekkoSpec with DefaultTimeout with ImplicitSender { counter.get should ===(connectionCount) actor ! pekko.routing.Broadcast("end") - Await.ready(doneLatch, 5 seconds) + Await.ready(doneLatch, 5.seconds) replies.values.foreach { _ should be > 0 } replies.values.sum should ===(iterationCount * connectionCount) @@ -106,10 +104,10 @@ class RandomSpec extends PekkoSpec with DefaultTimeout with ImplicitSender { })), "random-broadcast") actor ! pekko.routing.Broadcast("hello") - Await.ready(helloLatch, 5 seconds) + Await.ready(helloLatch, 5.seconds) system.stop(actor) - Await.ready(stopLatch, 5 seconds) + Await.ready(stopLatch, 5.seconds) } } } diff --git a/actor-tests/src/test/scala/org/apache/pekko/routing/ResizerSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/routing/ResizerSpec.scala index 7524ab6f233..1e7a4ab77b4 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/routing/ResizerSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/routing/ResizerSpec.scala @@ -17,7 +17,6 @@ import scala.concurrent.Await import scala.concurrent.duration._ import com.typesafe.config.{ Config, ConfigFactory } -import language.postfixOps import org.apache.pekko import pekko.actor.{ Actor, ActorRef, ActorSystem, Props } @@ -205,15 +204,15 @@ class ResizerSpec extends PekkoSpec(ResizerSpec.config) with DefaultTimeout with } // 2 more should go through without triggering more - loop(2, 200 millis) + loop(2, 200.millis) routeeSize(router) should ===(resizer.lowerBound) // a whole bunch should max it out - loop(20, 500 millis) + loop(20, 500.millis) routeeSize(router) should ===(resizer.upperBound) } - "backoff" in within(10 seconds) { + "backoff" in within(10.seconds) { val resizer = DefaultResizer( lowerBound = 2, upperBound = 5, @@ -226,25 +225,25 @@ class ResizerSpec extends PekkoSpec(ResizerSpec.config) with DefaultTimeout with val router = system.actorOf(RoundRobinPool(nrOfInstances = 0, resizer = Some(resizer)).props(Props(new Actor { def receive = { case n: Int if n <= 0 => // done - case n: Int => Thread.sleep((n millis).dilated.toMillis) + case n: Int => Thread.sleep(n.millis.dilated.toMillis) } }))) // put some pressure on the router for (_ <- 0 until 15) { router ! 150 - Thread.sleep((20 millis).dilated.toMillis) + Thread.sleep(20.millis.dilated.toMillis) } val z = routeeSize(router) z should be > 2 - Thread.sleep((300 millis).dilated.toMillis) + Thread.sleep(300.millis.dilated.toMillis) // let it cool down awaitCond({ router ! 0 // trigger resize - Thread.sleep((20 millis).dilated.toMillis) + Thread.sleep(20.millis.dilated.toMillis) routeeSize(router) < z }, interval = 500.millis.dilated) diff --git a/actor-tests/src/test/scala/org/apache/pekko/routing/RoundRobinSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/routing/RoundRobinSpec.scala index 1f7b1c5d247..2e47538c5dd 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/routing/RoundRobinSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/routing/RoundRobinSpec.scala @@ -18,8 +18,6 @@ import java.util.concurrent.atomic.AtomicInteger import scala.concurrent.Await import scala.concurrent.duration._ -import language.postfixOps - import org.apache.pekko import pekko.actor.Actor import pekko.actor.ActorRef @@ -54,10 +52,10 @@ class RoundRobinSpec extends PekkoSpec with DefaultTimeout with ImplicitSender { actor ! "hello" actor ! "hello" actor ! "hello" - Await.ready(helloLatch, 5 seconds) + Await.ready(helloLatch, 5.seconds) system.stop(actor) - Await.ready(stopLatch, 5 seconds) + Await.ready(stopLatch, 5.seconds) } "deliver messages in a round robin fashion" in { @@ -84,7 +82,7 @@ class RoundRobinSpec extends PekkoSpec with DefaultTimeout with ImplicitSender { counter.get should ===(connectionCount) actor ! pekko.routing.Broadcast("end") - Await.ready(doneLatch, 5 seconds) + Await.ready(doneLatch, 5.seconds) replies.values.foreach { _ should ===(iterationCount) } } @@ -104,10 +102,10 @@ class RoundRobinSpec extends PekkoSpec with DefaultTimeout with ImplicitSender { })), "round-robin-broadcast") actor ! pekko.routing.Broadcast("hello") - Await.ready(helloLatch, 5 seconds) + Await.ready(helloLatch, 5.seconds) system.stop(actor) - Await.ready(stopLatch, 5 seconds) + Await.ready(stopLatch, 5.seconds) } "be controlled with management messages" in { @@ -156,7 +154,7 @@ class RoundRobinSpec extends PekkoSpec with DefaultTimeout with ImplicitSender { } actor ! pekko.routing.Broadcast("end") - Await.ready(doneLatch, 5 seconds) + Await.ready(doneLatch, 5.seconds) replies.values.foreach { _ should ===(iterationCount) } } diff --git a/actor-tests/src/test/scala/org/apache/pekko/routing/RoutingSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/routing/RoutingSpec.scala index 893387ea922..eed7e6bb81f 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/routing/RoutingSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/routing/RoutingSpec.scala @@ -19,7 +19,6 @@ import scala.concurrent.ExecutionContextExecutor import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import org.apache.pekko import pekko.ConfigurationException @@ -79,7 +78,7 @@ class RoutingSpec extends PekkoSpec(RoutingSpec.config) with DefaultTimeout with awaitCond { router ! "" router ! "" - val res = receiveWhile(100 millis, messages = 2) { + val res = receiveWhile(100.millis, messages = 2) { case x: ActorRef => x } res == Seq(c1, c1) diff --git a/actor-tests/src/test/scala/org/apache/pekko/serialization/SerializeSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/serialization/SerializeSpec.scala index 3a5cc4adef3..cb379ee8541 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/serialization/SerializeSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/serialization/SerializeSpec.scala @@ -20,7 +20,6 @@ import java.nio.charset.StandardCharsets import scala.annotation.nowarn import scala.concurrent.Await import scala.concurrent.duration._ -import language.postfixOps import SerializationTests._ import com.typesafe.config._ @@ -307,7 +306,7 @@ class SerializeSpec extends PekkoSpec(SerializationTests.serializeConf) { } class VerifySerializabilitySpec extends PekkoSpec(SerializationTests.verifySerializabilityConf) { - implicit val timeout: Timeout = Timeout(5 seconds) + implicit val timeout: Timeout = Timeout(5.seconds) "verify config" in { system.settings.SerializeAllCreators should ===(true) diff --git a/actor-tests/src/test/scala/org/apache/pekko/util/DurationSpec.scala b/actor-tests/src/test/scala/org/apache/pekko/util/DurationSpec.scala index 366fc743480..7ee76098d37 100644 --- a/actor-tests/src/test/scala/org/apache/pekko/util/DurationSpec.scala +++ b/actor-tests/src/test/scala/org/apache/pekko/util/DurationSpec.scala @@ -15,8 +15,6 @@ package org.apache.pekko.util import scala.concurrent.duration._ -import language.postfixOps - import org.apache.pekko.testkit.PekkoSpec class DurationSpec extends PekkoSpec { @@ -24,8 +22,8 @@ class DurationSpec extends PekkoSpec { "Duration" must { "form a one-dimensional vector field" in { - val zero = 0 seconds - val one = 1 second + val zero = 0.seconds + val one = 1.second val two = one + one val three = 3 * one (0 * one) should ===(zero) @@ -96,11 +94,11 @@ class DurationSpec extends PekkoSpec { val dead = 2.seconds.fromNow val dead2 = 2.seconds(fromNow) // view bounds vs. very local type inference vs. operator precedence: sigh - dead.timeLeft should be > (1 second: Duration) - dead2.timeLeft should be > (1 second: Duration) + dead.timeLeft should be > (1.second: Duration) + dead2.timeLeft should be > (1.second: Duration) Thread.sleep(1.second.toMillis) - dead.timeLeft should be < (1 second: Duration) - dead2.timeLeft should be < (1 second: Duration) + dead.timeLeft should be < (1.second: Duration) + dead2.timeLeft should be < (1.second: Duration) } } diff --git a/actor-typed-tests/src/test/scala/org/apache/pekko/actor/typed/delivery/TestConsumer.scala b/actor-typed-tests/src/test/scala/org/apache/pekko/actor/typed/delivery/TestConsumer.scala index d7681948ab1..fd565d095f1 100644 --- a/actor-typed-tests/src/test/scala/org/apache/pekko/actor/typed/delivery/TestConsumer.scala +++ b/actor-typed-tests/src/test/scala/org/apache/pekko/actor/typed/delivery/TestConsumer.scala @@ -113,8 +113,7 @@ class TestConsumer( case job @ SomeAsyncJob(_, confirmTo, producerId, seqNr) => // when replacing producer the seqNr may start from 1 again val cleanProcessed = - if (seqNr == 1L) processed.filterNot { case (pid, _) => pid == producerId } - else processed + if (seqNr == 1L) processed.filterNot { case (pid, _) => pid == producerId } else processed if (cleanProcessed((producerId, seqNr))) throw new RuntimeException(s"Received duplicate [($producerId,$seqNr)]") diff --git a/actor/src/main/scala/org/apache/pekko/io/DirectByteBufferPool.scala b/actor/src/main/scala/org/apache/pekko/io/DirectByteBufferPool.scala index e8902db9d8e..b0efe71a4a3 100644 --- a/actor/src/main/scala/org/apache/pekko/io/DirectByteBufferPool.scala +++ b/actor/src/main/scala/org/apache/pekko/io/DirectByteBufferPool.scala @@ -100,7 +100,9 @@ private[pekko] object DirectByteBufferPool { val cleaner = cleanerMethod.invoke(bb) cleanMethod.invoke(cleaner) } - catch { case NonFatal(_) => /* ok, best effort attempt to cleanup failed */ } + catch { + case NonFatal(_) => /* ok, best effort attempt to cleanup failed */ + } } } catch { case NonFatal(_) => _ => () /* reflection failed, use no-op fallback */ } diff --git a/cluster-metrics/src/main/scala/org/apache/pekko/cluster/metrics/Provision.scala b/cluster-metrics/src/main/scala/org/apache/pekko/cluster/metrics/Provision.scala index 7af138a738f..3c4099d10c7 100644 --- a/cluster-metrics/src/main/scala/org/apache/pekko/cluster/metrics/Provision.scala +++ b/cluster-metrics/src/main/scala/org/apache/pekko/cluster/metrics/Provision.scala @@ -15,7 +15,6 @@ package org.apache.pekko.cluster.metrics import java.io.File -import scala.language.postfixOps import scala.util.Failure import scala.util.Success import scala.util.Try @@ -81,7 +80,7 @@ trait SigarProvider { }) .recover { case e: Throwable => throw new RuntimeException("Failed to load sigar:", e) - } get + }.get } } diff --git a/cluster-metrics/src/multi-jvm/scala/org/apache/pekko/cluster/metrics/ClusterMetricsExtensionSpec.scala b/cluster-metrics/src/multi-jvm/scala/org/apache/pekko/cluster/metrics/ClusterMetricsExtensionSpec.scala index a772dd2d17a..ec417fa8a88 100644 --- a/cluster-metrics/src/multi-jvm/scala/org/apache/pekko/cluster/metrics/ClusterMetricsExtensionSpec.scala +++ b/cluster-metrics/src/multi-jvm/scala/org/apache/pekko/cluster/metrics/ClusterMetricsExtensionSpec.scala @@ -14,7 +14,6 @@ package org.apache.pekko.cluster.metrics import scala.concurrent.duration._ -import scala.language.postfixOps import com.typesafe.config.ConfigFactory @@ -113,7 +112,7 @@ abstract class ClusterMetricsEnabledSpec "Cluster metrics" must { "periodically collect metrics on each node, publish to the event stream, " + - "and gossip metrics around the node ring" in within(60 seconds) { + "and gossip metrics around the node ring" in within(60.seconds) { awaitClusterUp(roles: _*) enterBarrier("cluster-started") awaitAssert(clusterView.members.count(_.status == MemberStatus.Up) should ===(roles.size)) @@ -124,7 +123,7 @@ abstract class ClusterMetricsEnabledSpec collector.sample().metrics.size should be > 3 enterBarrier("after") } - "reflect the correct number of node metrics in cluster view" in within(30 seconds) { + "reflect the correct number of node metrics in cluster view" in within(30.seconds) { runOn(node2) { cluster.leave(node1) } diff --git a/cluster-metrics/src/multi-jvm/scala/org/apache/pekko/cluster/metrics/ClusterMetricsRoutingSpec.scala b/cluster-metrics/src/multi-jvm/scala/org/apache/pekko/cluster/metrics/ClusterMetricsRoutingSpec.scala index 62da2a0f6dd..41417bcd145 100644 --- a/cluster-metrics/src/multi-jvm/scala/org/apache/pekko/cluster/metrics/ClusterMetricsRoutingSpec.scala +++ b/cluster-metrics/src/multi-jvm/scala/org/apache/pekko/cluster/metrics/ClusterMetricsRoutingSpec.scala @@ -21,7 +21,6 @@ import scala.concurrent.duration._ import com.typesafe.config.Config import com.typesafe.config.ConfigFactory -import language.postfixOps import org.apache.pekko import pekko.actor._ @@ -143,7 +142,7 @@ abstract class AdaptiveLoadBalancingRouterSpec def receiveReplies(expectedReplies: Int): Map[Address, Int] = { val zero = Map.empty[Address, Int] ++ roles.map(address(_) -> 0) - receiveWhile(5 seconds, messages = expectedReplies) { + receiveWhile(5.seconds, messages = expectedReplies) { case Reply(address) => address }.foldLeft(zero) { case (replyMap, address) => replyMap + (address -> (replyMap(address) + 1)) diff --git a/cluster-metrics/src/multi-jvm/scala/org/apache/pekko/cluster/metrics/sample/StatsSampleSpec.scala b/cluster-metrics/src/multi-jvm/scala/org/apache/pekko/cluster/metrics/sample/StatsSampleSpec.scala index 05376e313c2..32c2697d463 100644 --- a/cluster-metrics/src/multi-jvm/scala/org/apache/pekko/cluster/metrics/sample/StatsSampleSpec.scala +++ b/cluster-metrics/src/multi-jvm/scala/org/apache/pekko/cluster/metrics/sample/StatsSampleSpec.scala @@ -19,7 +19,6 @@ import pekko.cluster.Cluster import pekko.cluster.ClusterEvent.{ CurrentClusterState, MemberUp } import scala.concurrent.duration._ -import scala.language.postfixOps //#MultiNodeConfig import org.apache.pekko.remote.testkit.MultiNodeConfig @@ -104,7 +103,7 @@ abstract class StatsSampleSpec "The stats sample" must { // #startup-cluster - "illustrate how to startup cluster" in within(15 seconds) { + "illustrate how to startup cluster" in within(15.seconds) { Cluster(system).subscribe(testActor, classOf[MemberUp]) expectMsgClass(classOf[CurrentClusterState]) @@ -131,7 +130,7 @@ abstract class StatsSampleSpec // #startup-cluster // #test-statsService - "show usage of the statsService from one node" in within(15 seconds) { + "show usage of the statsService from one node" in within(15.seconds) { runOn(second) { assertServiceOk() } @@ -151,7 +150,7 @@ abstract class StatsSampleSpec } // #test-statsService - "show usage of the statsService from all nodes" in within(15 seconds) { + "show usage of the statsService from all nodes" in within(15.seconds) { assertServiceOk() testConductor.enter("done-3") } diff --git a/cluster-metrics/src/test/scala/org/apache/pekko/cluster/metrics/ClusterMetricsExtensionSpec.scala b/cluster-metrics/src/test/scala/org/apache/pekko/cluster/metrics/ClusterMetricsExtensionSpec.scala index f9532a2e7a7..948221b6b0b 100644 --- a/cluster-metrics/src/test/scala/org/apache/pekko/cluster/metrics/ClusterMetricsExtensionSpec.scala +++ b/cluster-metrics/src/test/scala/org/apache/pekko/cluster/metrics/ClusterMetricsExtensionSpec.scala @@ -14,7 +14,6 @@ package org.apache.pekko.cluster.metrics import scala.concurrent.duration._ -import scala.language.postfixOps import org.apache.pekko import pekko.cluster.Cluster @@ -54,11 +53,11 @@ class ClusterMetricsExtensionSpec "collect metrics after start command" in { extension.supervisor ! CollectionStartMessage - awaitAssert(metricsNodeCount should ===(nodeCount), 15 seconds) + awaitAssert(metricsNodeCount should ===(nodeCount), 15.seconds) } "collect mock sample during a time window" in { - awaitAssert(metricsHistorySize should ===(sampleCount), 15 seconds) + awaitAssert(metricsHistorySize should ===(sampleCount), 15.seconds) extension.supervisor ! CollectionStopMessage awaitSample() metricsNodeCount should ===(nodeCount) diff --git a/cluster-metrics/src/test/scala/org/apache/pekko/cluster/metrics/ClusterMetricsSettingsSpec.scala b/cluster-metrics/src/test/scala/org/apache/pekko/cluster/metrics/ClusterMetricsSettingsSpec.scala index a8622f72e44..2336a7dd4d2 100644 --- a/cluster-metrics/src/test/scala/org/apache/pekko/cluster/metrics/ClusterMetricsSettingsSpec.scala +++ b/cluster-metrics/src/test/scala/org/apache/pekko/cluster/metrics/ClusterMetricsSettingsSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.cluster.metrics import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import org.apache.pekko import pekko.dispatch.Dispatchers @@ -32,7 +31,7 @@ class ClusterMetricsSettingsSpec extends PekkoSpec { // Extension. MetricsDispatcher should ===(Dispatchers.DefaultDispatcherId) - PeriodicTasksInitialDelay should ===(1 second) + PeriodicTasksInitialDelay should ===(1.second) NativeLibraryExtractFolder should ===(System.getProperty("user.dir") + "/native") // Supervisor. @@ -44,9 +43,9 @@ class ClusterMetricsSettingsSpec extends PekkoSpec { // Collector. CollectorEnabled should ===(true) CollectorProvider should ===("") - CollectorSampleInterval should ===(3 seconds) - CollectorGossipInterval should ===(3 seconds) - CollectorMovingAverageHalfLife should ===(12 seconds) + CollectorSampleInterval should ===(3.seconds) + CollectorGossipInterval should ===(3.seconds) + CollectorMovingAverageHalfLife should ===(12.seconds) } } } diff --git a/cluster-metrics/src/test/scala/org/apache/pekko/cluster/metrics/MetricsCollectorSpec.scala b/cluster-metrics/src/test/scala/org/apache/pekko/cluster/metrics/MetricsCollectorSpec.scala index 276db678917..2ebc4cd054e 100644 --- a/cluster-metrics/src/test/scala/org/apache/pekko/cluster/metrics/MetricsCollectorSpec.scala +++ b/cluster-metrics/src/test/scala/org/apache/pekko/cluster/metrics/MetricsCollectorSpec.scala @@ -14,7 +14,6 @@ package org.apache.pekko.cluster.metrics import scala.concurrent.duration._ -import scala.language.postfixOps import scala.util.Try import scala.annotation.nowarn @@ -103,7 +102,7 @@ class MetricsCollectorSpec c.processors.isDefined should ===(true) } - "collect 50 node metrics samples in an acceptable duration" taggedAs LongRunningTest in within(10 seconds) { + "collect 50 node metrics samples in an acceptable duration" taggedAs LongRunningTest in within(10.seconds) { (1 to 50).foreach { _ => val sample = collector.sample() sample.metrics.size should be >= 3 diff --git a/cluster-metrics/src/test/scala/org/apache/pekko/cluster/metrics/TestUtil.scala b/cluster-metrics/src/test/scala/org/apache/pekko/cluster/metrics/TestUtil.scala index 8b195040662..a3adf58d24e 100644 --- a/cluster-metrics/src/test/scala/org/apache/pekko/cluster/metrics/TestUtil.scala +++ b/cluster-metrics/src/test/scala/org/apache/pekko/cluster/metrics/TestUtil.scala @@ -16,8 +16,6 @@ package org.apache.pekko.cluster.metrics import java.io.Closeable import java.util.logging.LogManager -import scala.language.postfixOps - import org.scalatestplus.mockito.MockitoSugar import org.slf4j.bridge.SLF4JBridgeHandler @@ -80,7 +78,7 @@ case class MockitoSigarProvider( /** Generate monotonic array from 0 to value. */ def increase(value: Double): Array[Double] = { val delta = value / steps - (0 to steps).map { _ * delta } toArray + (0 to steps).map { _ * delta }.toArray } /** Sigar mock instance. */ diff --git a/cluster-sharding/src/multi-jvm/scala/org/apache/pekko/cluster/sbr/RandomizedBrainResolverIntegrationSpec.scala b/cluster-sharding/src/multi-jvm/scala/org/apache/pekko/cluster/sbr/RandomizedBrainResolverIntegrationSpec.scala index 0672f412232..39ca53bb23c 100644 --- a/cluster-sharding/src/multi-jvm/scala/org/apache/pekko/cluster/sbr/RandomizedBrainResolverIntegrationSpec.scala +++ b/cluster-sharding/src/multi-jvm/scala/org/apache/pekko/cluster/sbr/RandomizedBrainResolverIntegrationSpec.scala @@ -312,7 +312,9 @@ class RandomizedSplitBrainResolverIntegrationSpec (if (cleanSplit) s"side1 [${side1.map(_.name).mkString(", ")}], side2 [${side2.map(_.name).mkString(", ")}] " else " ") + - s", flaky [${flaky.map { case (_, (from, to)) => from.name -> to.map(_.name).mkString("(", ", ", ")") }.mkString("; ")}] " + + s", flaky [${flaky.map { case (_, (from, to)) => + from.name -> to.map(_.name).mkString("(", ", ", ")") + }.mkString("; ")}] " + s", healLastFlaky [$healLastFlaky] " + s", delays [${delays.mkString(", ")}]") diff --git a/cluster-sharding/src/multi-jvm/scala/org/apache/pekko/cluster/sharding/ClusterShardingSpec.scala b/cluster-sharding/src/multi-jvm/scala/org/apache/pekko/cluster/sharding/ClusterShardingSpec.scala index 5adffa7f22d..d9556e924e7 100644 --- a/cluster-sharding/src/multi-jvm/scala/org/apache/pekko/cluster/sharding/ClusterShardingSpec.scala +++ b/cluster-sharding/src/multi-jvm/scala/org/apache/pekko/cluster/sharding/ClusterShardingSpec.scala @@ -14,7 +14,6 @@ package org.apache.pekko.cluster.sharding import scala.concurrent.duration._ -import scala.language.postfixOps import com.typesafe.config.ConfigFactory import org.apache.pekko import pekko.actor._ @@ -430,7 +429,7 @@ abstract class ClusterShardingSpec(multiNodeConfig: ClusterShardingSpecConfig) enterBarrier("after-1") } - "work in single node cluster" in within(20 seconds) { + "work in single node cluster" in within(20.seconds) { join(first, first) runOn(first) { @@ -448,7 +447,7 @@ abstract class ClusterShardingSpec(multiNodeConfig: ClusterShardingSpecConfig) enterBarrier("after-2") } - "use second node" in within(20 seconds) { + "use second node" in within(20.seconds) { join(second, first) runOn(second) { @@ -534,7 +533,7 @@ abstract class ClusterShardingSpec(multiNodeConfig: ClusterShardingSpecConfig) enterBarrier("after-5") } - "failover shards on crashed node" in within(30 seconds) { + "failover shards on crashed node" in within(30.seconds) { // mute logging of deadLetters during shutdown of systems if (!log.isDebugEnabled) system.eventStream.publish(Mute(DeadLettersFilter[Any])) @@ -567,7 +566,7 @@ abstract class ClusterShardingSpec(multiNodeConfig: ClusterShardingSpecConfig) enterBarrier("after-6") } - "use third and fourth node" in within(15 seconds) { + "use third and fourth node" in within(15.seconds) { join(third, first) runOn(third) { @@ -618,7 +617,7 @@ abstract class ClusterShardingSpec(multiNodeConfig: ClusterShardingSpecConfig) enterBarrier("after-7") } - "recover coordinator state after coordinator crash" in within(60 seconds) { + "recover coordinator state after coordinator crash" in within(60.seconds) { join(fifth, fourth) runOn(controller) { @@ -649,7 +648,7 @@ abstract class ClusterShardingSpec(multiNodeConfig: ClusterShardingSpecConfig) enterBarrier("after-8") } - "rebalance to nodes with less shards" in within(60 seconds) { + "rebalance to nodes with less shards" in within(60.seconds) { runOn(fourth) { for (n <- 1 to 10) { rebalancingRegion ! EntityEnvelope(n, Increment) @@ -799,26 +798,26 @@ abstract class ClusterShardingSpec(multiNodeConfig: ClusterShardingSpecConfig) // clean up shard cache everywhere runOn(third, fourth, fifth) { persistentEntitiesRegion ! BeginHandOff("1") - expectMsg(10 seconds, "ShardStopped not received", BeginHandOffAck("1")) + expectMsg(10.seconds, "ShardStopped not received", BeginHandOffAck("1")) } enterBarrier("everybody-hand-off-ack") runOn(third) { // Stop the shard cleanly region ! HandOff("1") - expectMsg(10 seconds, "ShardStopped not received", ShardStopped("1")) + expectMsg(10.seconds, "ShardStopped not received", ShardStopped("1")) val probe = TestProbe() awaitAssert({ shard.tell(Identify(1), probe.ref) - probe.expectMsg(1 second, "Shard was still around", ActorIdentity(1, None)) - }, 5 seconds, 500 millis) + probe.expectMsg(1.second, "Shard was still around", ActorIdentity(1, None)) + }, 5.seconds, 500.millis) // Get the path to where the shard now resides awaitAssert({ persistentEntitiesRegion ! Get(13) expectMsg(0) - }, 5 seconds, 500 millis) + }, 5.seconds, 500.millis) // Check that counter 1 is now alive again, even though we have // not sent a message to it via the ShardRegion @@ -847,7 +846,7 @@ abstract class ClusterShardingSpec(multiNodeConfig: ClusterShardingSpecConfig) // Check that no counter "1" exists in this shard val secondCounter1 = system.actorSelection(lastSender.path.parent / "1") secondCounter1 ! Identify(3) - expectMsg(3 seconds, ActorIdentity(3, None)) + expectMsg(3.seconds, ActorIdentity(3, None)) } enterBarrier("after-12") @@ -883,24 +882,24 @@ abstract class ClusterShardingSpec(multiNodeConfig: ClusterShardingSpecConfig) shard.tell(Passivate(Stop), counter1) // Watch for the terminated message - expectTerminated(counter1, 5 seconds) + expectTerminated(counter1, 5.seconds) val probe1 = TestProbe() awaitAssert({ // Check counter 1 is dead counter1.tell(Identify(1), probe1.ref) - probe1.expectMsg(1 second, "Entity 1 was still around", ActorIdentity(1, None)) - }, 5 second, 500 millis) + probe1.expectMsg(1.second, "Entity 1 was still around", ActorIdentity(1, None)) + }, 5.second, 500.millis) // Stop the shard cleanly region ! HandOff("1") - expectMsg(10 seconds, "ShardStopped not received", ShardStopped("1")) + expectMsg(10.seconds, "ShardStopped not received", ShardStopped("1")) val probe2 = TestProbe() awaitAssert({ shard.tell(Identify(2), probe2.ref) - probe2.expectMsg(1 second, "Shard was still around", ActorIdentity(2, None)) - }, 5 seconds, 500 millis) + probe2.expectMsg(1.second, "Shard was still around", ActorIdentity(2, None)) + }, 5.seconds, 500.millis) } enterBarrier("shard-shutdown-12") @@ -920,8 +919,8 @@ abstract class ClusterShardingSpec(multiNodeConfig: ClusterShardingSpecConfig) val probe3 = TestProbe() awaitAssert({ system.actorSelection(shard / "13").tell(Identify(4), probe3.ref) - probe3.expectMsgType[ActorIdentity](1 second).ref should not be None - }, 5 seconds, 500 millis) + probe3.expectMsgType[ActorIdentity](1.second).ref should not be None + }, 5.seconds, 500.millis) } enterBarrier("after-13") @@ -946,7 +945,7 @@ abstract class ClusterShardingSpec(multiNodeConfig: ClusterShardingSpecConfig) val probe = TestProbe() awaitAssert({ counter1.tell(Identify(1), probe.ref) - probe.expectMsgType[ActorIdentity](1 second).ref should not be None + probe.expectMsgType[ActorIdentity](1.second).ref should not be None }, 5.seconds, 500.millis) } @@ -983,8 +982,8 @@ abstract class ClusterShardingSpec(multiNodeConfig: ClusterShardingSpecConfig) val probe = TestProbe() awaitAssert({ counter1.tell(Identify(1), probe.ref) - probe.expectMsgType[ActorIdentity](1 second).ref should not be None - }, 5.seconds, 500 millis) + probe.expectMsgType[ActorIdentity](1.second).ref should not be None + }, 5.seconds, 500.millis) counter1 ! Get(1) expectMsg(2) @@ -1017,7 +1016,7 @@ abstract class ClusterShardingSpec(multiNodeConfig: ClusterShardingSpecConfig) for (n <- 2 to 12) { val entity = system.actorSelection(rebalancingPersistentRegion.path / (n % 12).toString / n.toString) entity ! Identify(n) - receiveOne(3 seconds) match { + receiveOne(3.seconds) match { case ActorIdentity(id, Some(_)) if id == n => count = count + 1 case ActorIdentity(_, None) => // Not on the fifth shard case _ => fail() diff --git a/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/client/ClusterClientSpec.scala b/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/client/ClusterClientSpec.scala index 2854065cd51..d5b1be40d84 100644 --- a/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/client/ClusterClientSpec.scala +++ b/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/client/ClusterClientSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.cluster.client import scala.annotation.nowarn import scala.concurrent.Await import scala.concurrent.duration._ -import scala.language.postfixOps import com.typesafe.config.ConfigFactory @@ -216,7 +215,7 @@ class ClusterClientSpec extends MultiNodeSpec(ClusterClientSpec) with STMultiNod "A ClusterClient" must { - "startup cluster" in within(30 seconds) { + "startup cluster" in within(30.seconds) { join(first, first) join(second, first) join(third, first) @@ -232,7 +231,7 @@ class ClusterClientSpec extends MultiNodeSpec(ClusterClientSpec) with STMultiNod enterBarrier("after-1") } - "communicate to actor on any node in cluster" in within(10 seconds) { + "communicate to actor on any node in cluster" in within(10.seconds) { runOn(client) { val c = system.actorOf( ClusterClient.props(ClusterClientSettings(system).withInitialContacts(initialContacts)), @@ -248,7 +247,7 @@ class ClusterClientSpec extends MultiNodeSpec(ClusterClientSpec) with STMultiNod enterBarrier("after-2") } - "work with ask" in within(10 seconds) { + "work with ask" in within(10.seconds) { runOn(client) { import pekko.pattern.ask val c = system.actorOf( @@ -266,7 +265,7 @@ class ClusterClientSpec extends MultiNodeSpec(ClusterClientSpec) with STMultiNod enterBarrier("after-3") } - "demonstrate usage" in within(15 seconds) { + "demonstrate usage" in within(15.seconds) { def host1 = first def host2 = second def host3 = third @@ -308,7 +307,7 @@ class ClusterClientSpec extends MultiNodeSpec(ClusterClientSpec) with STMultiNod enterBarrier("after-4") } - "report events" in within(15 seconds) { + "report events" in within(15.seconds) { runOn(client) { implicit val timeout: Timeout = Timeout(1.second.dilated) val client = Await.result(system.actorSelection("/user/client").resolveOne(), timeout.duration) @@ -348,7 +347,7 @@ class ClusterClientSpec extends MultiNodeSpec(ClusterClientSpec) with STMultiNod enterBarrier("after-5") } - "report a removal of a receptionist" in within(10 seconds) { + "report a removal of a receptionist" in within(10.seconds) { runOn(client) { val unreachableContact = node(client) / "system" / "receptionist" val expectedRoles = Set(first, second, third, fourth) diff --git a/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/pubsub/DistributedPubSubMediatorSpec.scala b/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/pubsub/DistributedPubSubMediatorSpec.scala index 26b6a1837d0..599aed999ba 100644 --- a/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/pubsub/DistributedPubSubMediatorSpec.scala +++ b/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/pubsub/DistributedPubSubMediatorSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.cluster.pubsub import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import org.apache.pekko import pekko.actor.Actor @@ -186,13 +185,13 @@ class DistributedPubSubMediatorSpec "A DistributedPubSubMediator" must { - "startup 2 node cluster" in within(15 seconds) { + "startup 2 node cluster" in within(15.seconds) { join(first, first) join(second, first) enterBarrier("after-1") } - "keep track of added users" in within(15 seconds) { + "keep track of added users" in within(15.seconds) { runOn(first) { val u1 = createChatUser("u1") mediator ! Put(u1) @@ -242,7 +241,7 @@ class DistributedPubSubMediatorSpec enterBarrier("after-2") } - "replicate users to new node" in within(20 seconds) { + "replicate users to new node" in within(20.seconds) { join(third, first) runOn(third) { @@ -265,7 +264,7 @@ class DistributedPubSubMediatorSpec enterBarrier("after-3") } - "keep track of removed users" in within(15 seconds) { + "keep track of removed users" in within(15.seconds) { runOn(first) { val u6 = createChatUser("u6") mediator ! Put(u6) @@ -281,7 +280,7 @@ class DistributedPubSubMediatorSpec enterBarrier("after-4") } - "remove terminated users" in within(5 seconds) { + "remove terminated users" in within(5.seconds) { runOn(second) { chatUser("u3") ! PoisonPill } @@ -290,7 +289,7 @@ class DistributedPubSubMediatorSpec enterBarrier("after-5") } - "publish" in within(15 seconds) { + "publish" in within(15.seconds) { runOn(first, second) { val u7 = createChatUser("u7") mediator ! Put(u7) @@ -313,7 +312,7 @@ class DistributedPubSubMediatorSpec enterBarrier("after-6") } - "publish to topic" in within(15 seconds) { + "publish to topic" in within(15.seconds) { runOn(first) { val s8 = Subscribe("topic1", createChatUser("u8")) mediator ! s8 @@ -352,7 +351,7 @@ class DistributedPubSubMediatorSpec enterBarrier("after-7") } - "demonstrate usage of Publish" in within(15 seconds) { + "demonstrate usage of Publish" in within(15.seconds) { def later(): Unit = { awaitCount(10) } @@ -379,7 +378,7 @@ class DistributedPubSubMediatorSpec enterBarrier("after-8") } - "demonstrate usage of Send" in within(15 seconds) { + "demonstrate usage of Send" in within(15.seconds) { def later(): Unit = { awaitCount(12) } @@ -405,7 +404,7 @@ class DistributedPubSubMediatorSpec enterBarrier("after-8") } - "send-all to all other nodes" in within(15 seconds) { + "send-all to all other nodes" in within(15.seconds) { runOn(first, second, third) { // create the user on all nodes val u11 = createChatUser("u11") mediator ! Put(u11) @@ -428,7 +427,7 @@ class DistributedPubSubMediatorSpec enterBarrier("after-11") } - "send one message to each group" in within(20 seconds) { + "send one message to each group" in within(20.seconds) { runOn(first) { val u12 = createChatUser("u12") u12 ! JoinGroup("topic2", "group1") @@ -517,7 +516,7 @@ class DistributedPubSubMediatorSpec enterBarrier("after-13") } - "remove entries when node is removed" in within(30 seconds) { + "remove entries when node is removed" in within(30.seconds) { mediator ! Count val countBefore = expectMsgType[Int] @@ -535,7 +534,7 @@ class DistributedPubSubMediatorSpec enterBarrier("after-14") } - "receive proper unsubscribeAck message" in within(15 seconds) { + "receive proper unsubscribeAck message" in within(15.seconds) { runOn(first) { val user = createChatUser("u111") val topic = "sample-topic1" @@ -549,7 +548,7 @@ class DistributedPubSubMediatorSpec enterBarrier("after-14") } - "get topics after simple publish" in within(15 seconds) { + "get topics after simple publish" in within(15.seconds) { runOn(first) { val s1 = Subscribe("topic_a1", createChatUser("u14")) mediator ! s1 @@ -597,7 +596,7 @@ class DistributedPubSubMediatorSpec } - "remove topic subscribers when they terminate" in within(15 seconds) { + "remove topic subscribers when they terminate" in within(15.seconds) { runOn(first) { val s1 = Subscribe("topic_b1", createChatUser("u18")) mediator ! s1 diff --git a/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/pubsub/DistributedPubSubRestartSpec.scala b/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/pubsub/DistributedPubSubRestartSpec.scala index 55c87551ca2..fa1b0846244 100644 --- a/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/pubsub/DistributedPubSubRestartSpec.scala +++ b/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/pubsub/DistributedPubSubRestartSpec.scala @@ -17,7 +17,6 @@ import scala.concurrent.Await import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import org.apache.pekko import pekko.actor.Actor @@ -93,14 +92,14 @@ class DistributedPubSubRestartSpec "A Cluster with DistributedPubSub" must { - "startup 3 node cluster" in within(15 seconds) { + "startup 3 node cluster" in within(15.seconds) { join(first, first) join(second, first) join(third, first) enterBarrier("after-1") } - "handle restart of nodes with same address" in within(30 seconds) { + "handle restart of nodes with same address" in within(30.seconds) { mediator ! Subscribe("topic1", testActor) expectMsgType[SubscribeAck] awaitCount(3) diff --git a/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/singleton/ClusterSingletonManagerChaosSpec.scala b/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/singleton/ClusterSingletonManagerChaosSpec.scala index 57b0819af34..e2b58be7f7e 100644 --- a/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/singleton/ClusterSingletonManagerChaosSpec.scala +++ b/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/singleton/ClusterSingletonManagerChaosSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.cluster.singleton import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import org.apache.pekko import pekko.actor.Actor @@ -122,7 +121,7 @@ class ClusterSingletonManagerChaosSpec "A ClusterSingletonManager in chaotic cluster" must { - "startup 6 node cluster" in within(60 seconds) { + "startup 6 node cluster" in within(60.seconds) { val memberProbe = TestProbe() Cluster(system).subscribe(memberProbe.ref, classOf[MemberUp]) memberProbe.expectMsgClass(classOf[CurrentClusterState]) @@ -157,7 +156,7 @@ class ClusterSingletonManagerChaosSpec } - "take over when three oldest nodes crash in 6 nodes cluster" in within(90 seconds) { + "take over when three oldest nodes crash in 6 nodes cluster" in within(90.seconds) { // mute logging of deadLetters during shutdown of systems if (!log.isDebugEnabled) system.eventStream.publish(Mute(DeadLettersFilter[Any])) diff --git a/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/singleton/ClusterSingletonManagerSpec.scala b/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/singleton/ClusterSingletonManagerSpec.scala index f04c2aa2763..01583b2a7b6 100644 --- a/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/singleton/ClusterSingletonManagerSpec.scala +++ b/cluster-tools/src/multi-jvm/scala/org/apache/pekko/cluster/singleton/ClusterSingletonManagerSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.cluster.singleton import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import org.apache.pekko import pekko.actor.Actor @@ -313,13 +312,13 @@ class ClusterSingletonManagerSpec runOn(controller) { queue ! msg // make sure it's not terminated, which would be wrong - expectNoMessage(1 second) + expectNoMessage(1.second) } runOn(oldest) { expectMsg(5.seconds, msg) } runOn(roles.filterNot(r => r == oldest || r == controller || r == observer): _*) { - expectNoMessage(1 second) + expectNoMessage(1.second) } enterBarrier("after-" + msg + "-verified") } @@ -337,7 +336,7 @@ class ClusterSingletonManagerSpec "A ClusterSingletonManager" must { - "startup 6 node cluster" in within(60 seconds) { + "startup 6 node cluster" in within(60.seconds) { val memberProbe = TestProbe() Cluster(system).subscribe(memberProbe.ref, classOf[MemberUp]) @@ -387,7 +386,7 @@ class ClusterSingletonManagerSpec enterBarrier("after-1") } - "let the proxy route messages to the singleton in a 6 node cluster" in within(60 seconds) { + "let the proxy route messages to the singleton in a 6 node cluster" in within(60.seconds) { verifyProxyMsg(first, first, msg = msg()) verifyProxyMsg(first, second, msg = msg()) verifyProxyMsg(first, third, msg = msg()) @@ -396,7 +395,7 @@ class ClusterSingletonManagerSpec verifyProxyMsg(first, sixth, msg = msg()) } - "hand over when oldest leaves in 6 nodes cluster " in within(30 seconds) { + "hand over when oldest leaves in 6 nodes cluster " in within(30.seconds) { val leaveRole = first runOn(leaveRole) { @@ -424,7 +423,7 @@ class ClusterSingletonManagerSpec enterBarrier("after-leave") } - "take over when oldest crashes in 5 nodes cluster" in within(60 seconds) { + "take over when oldest crashes in 5 nodes cluster" in within(60.seconds) { // mute logging of deadLetters during shutdown of systems if (!log.isDebugEnabled) system.eventStream.publish(Mute(DeadLettersFilter[Any])) @@ -439,7 +438,7 @@ class ClusterSingletonManagerSpec verifyProxyMsg(third, sixth, msg = msg()) } - "take over when two oldest crash in 3 nodes cluster" in within(60 seconds) { + "take over when two oldest crash in 3 nodes cluster" in within(60.seconds) { crash(third, fourth) verifyRegistration(fifth) verifyMsg(fifth, msg = msg()) @@ -447,7 +446,7 @@ class ClusterSingletonManagerSpec verifyProxyMsg(fifth, sixth, msg = msg()) } - "take over when oldest crashes in 2 nodes cluster" in within(60 seconds) { + "take over when oldest crashes in 2 nodes cluster" in within(60.seconds) { crash(fifth) verifyRegistration(sixth) verifyMsg(sixth, msg = msg()) diff --git a/cluster/src/main/scala/org/apache/pekko/cluster/ClusterEvent.scala b/cluster/src/main/scala/org/apache/pekko/cluster/ClusterEvent.scala index d571f39978c..5355a94880e 100644 --- a/cluster/src/main/scala/org/apache/pekko/cluster/ClusterEvent.scala +++ b/cluster/src/main/scala/org/apache/pekko/cluster/ClusterEvent.scala @@ -18,7 +18,6 @@ import scala.collection.immutable.{ SortedSet, VectorBuilder } import scala.runtime.AbstractFunction5 import scala.annotation.nowarn -import language.postfixOps import org.apache.pekko import pekko.actor.{ Actor, ActorRef, Address } @@ -166,7 +165,7 @@ object ClusterEvent { /** * Java API: get address of current data center leader, or null if none */ - def getLeader: Address = leader orNull + def getLeader: Address = leader.orNull /** * get address of current leader, if any, within the data center that has the given role @@ -366,7 +365,7 @@ object ClusterEvent { * Java API * @return address of current leader, or null if none */ - def getLeader: Address = leader orNull + def getLeader: Address = leader.orNull } /** @@ -380,7 +379,7 @@ object ClusterEvent { * Java API * @return address of current leader, or null if none */ - def getLeader: Address = leader orNull + def getLeader: Address = leader.orNull } /** diff --git a/cluster/src/main/scala/org/apache/pekko/cluster/Member.scala b/cluster/src/main/scala/org/apache/pekko/cluster/Member.scala index d09e31fd279..0c813132f97 100644 --- a/cluster/src/main/scala/org/apache/pekko/cluster/Member.scala +++ b/cluster/src/main/scala/org/apache/pekko/cluster/Member.scala @@ -52,7 +52,8 @@ class Member private[cluster] ( case _ => false } override def toString: String = { - s"Member($address, $status${if (dataCenter == ClusterSettings.DefaultDataCenter) "" else s", $dataCenter"}${if (appVersion == Version.Zero) "" + s"Member($address, $status${if (dataCenter == ClusterSettings.DefaultDataCenter) "" + else s", $dataCenter"}${if (appVersion == Version.Zero) "" else s", $appVersion"})" } diff --git a/cluster/src/main/scala/org/apache/pekko/cluster/sbr/SplitBrainResolver.scala b/cluster/src/main/scala/org/apache/pekko/cluster/sbr/SplitBrainResolver.scala index 0fed30518c4..1386b812fa6 100644 --- a/cluster/src/main/scala/org/apache/pekko/cluster/sbr/SplitBrainResolver.scala +++ b/cluster/src/main/scala/org/apache/pekko/cluster/sbr/SplitBrainResolver.scala @@ -484,7 +484,8 @@ import pekko.remote.artery.ThisActorSystemQuarantinedEvent log.warning( ClusterLogMarker.sbrDowning(decision), - s"SBR took decision $decision and is downing [${nodesToDown.map(_.address).mkString(", ")}]${if (downMyself) " including myself" + s"SBR took decision $decision and is downing [${nodesToDown.map(_.address).mkString(", ")}]${if (downMyself) + " including myself" else ""}, " + s"[${strategy.unreachable.size}] unreachable of [${strategy.members.size}] members" + indirectlyConnectedLogMessage + diff --git a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/ClusterDeathWatchSpec.scala b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/ClusterDeathWatchSpec.scala index dd5147d0f1a..f72df20774a 100644 --- a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/ClusterDeathWatchSpec.scala +++ b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/ClusterDeathWatchSpec.scala @@ -17,7 +17,6 @@ import java.util.concurrent.TimeoutException import scala.concurrent.Await import scala.concurrent.duration._ -import scala.language.postfixOps import com.typesafe.config.ConfigFactory import org.scalatest.concurrent.ScalaFutures @@ -86,7 +85,7 @@ abstract class ClusterDeathWatchSpec "An actor watching a remote actor in the cluster" must { - "receive Terminated when watched node becomes Down/Removed" in within(20 seconds) { + "receive Terminated when watched node becomes Down/Removed" in within(20.seconds) { awaitClusterUp(first, second, third, fourth) enterBarrier("cluster-up") @@ -163,7 +162,7 @@ abstract class ClusterDeathWatchSpec } "not be able to watch an actor before node joins cluster, ClusterRemoteWatcher takes over from RemoteWatcher" in within( - 20 seconds) { + 20.seconds) { runOn(fifth) { system.actorOf( Props(new Actor { def receive = Actor.emptyBehavior }).withDeploy(Deploy.local), @@ -253,7 +252,7 @@ abstract class ClusterDeathWatchSpec enterBarrier("after-4") } - "be able to shutdown system when using remote deployed actor on node that crash" in within(20 seconds) { + "be able to shutdown system when using remote deployed actor on node that crash" in within(20.seconds) { // fourth actor system will be shutdown, not part of testConductor any more // so we can't use barriers to synchronize with it val firstAddress = address(first) @@ -298,7 +297,7 @@ abstract class ClusterDeathWatchSpec endProbe.expectMsg(EndActor.EndAck) } finally { - shutdown(endSystem, 10 seconds) + shutdown(endSystem, 10.seconds) } // no barrier here, because it is not part of testConductor roles any more diff --git a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/ConvergenceSpec.scala b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/ConvergenceSpec.scala index 6c88cd46c2d..e9060669b80 100644 --- a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/ConvergenceSpec.scala +++ b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/ConvergenceSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.cluster import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import org.apache.pekko import pekko.actor.Address @@ -79,7 +78,7 @@ abstract class ConvergenceSpec(multiNodeConfig: ConvergenceMultiNodeConfig) runOn(first, second) { - within(28 seconds) { + within(28.seconds) { // third becomes unreachable awaitAssert(clusterView.unreachableMembers.size should ===(1)) awaitSeenSameState(first, second) diff --git a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/InitialHeartbeatSpec.scala b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/InitialHeartbeatSpec.scala index c5895573a5c..7ab6aa253ba 100644 --- a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/InitialHeartbeatSpec.scala +++ b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/InitialHeartbeatSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.cluster import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import org.apache.pekko import pekko.cluster.ClusterEvent.CurrentClusterState @@ -54,7 +53,7 @@ abstract class InitialHeartbeatSpec extends MultiNodeClusterSpec(InitialHeartbea awaitClusterUp(first) runOn(first) { - within(10 seconds) { + within(10.seconds) { awaitAssert({ cluster.sendCurrentClusterState(testActor) expectMsgType[CurrentClusterState].members.map(_.address) should contain(secondAddress) @@ -63,7 +62,7 @@ abstract class InitialHeartbeatSpec extends MultiNodeClusterSpec(InitialHeartbea } runOn(second) { cluster.join(first) - within(10 seconds) { + within(10.seconds) { awaitAssert({ cluster.sendCurrentClusterState(testActor) expectMsgType[CurrentClusterState].members.map(_.address) should contain(firstAddress) @@ -81,7 +80,7 @@ abstract class InitialHeartbeatSpec extends MultiNodeClusterSpec(InitialHeartbea } runOn(second) { - within(15 seconds) { + within(15.seconds) { awaitCond(!cluster.failureDetector.isAvailable(first)) } } diff --git a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/LeaderDowningNodeThatIsUnreachableSpec.scala b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/LeaderDowningNodeThatIsUnreachableSpec.scala index 2b58a8a72ac..bec2420c205 100644 --- a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/LeaderDowningNodeThatIsUnreachableSpec.scala +++ b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/LeaderDowningNodeThatIsUnreachableSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.cluster import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import org.apache.pekko import pekko.remote.testkit.MultiNodeConfig @@ -124,7 +123,7 @@ abstract class LeaderDowningNodeThatIsUnreachableSpec( runOn(third) { enterBarrier("down-second-node") - awaitMembersUp(numberOfMembers = 2, canNotBePartOfMemberRing = Set(secondAddress), 30 seconds) + awaitMembersUp(numberOfMembers = 2, canNotBePartOfMemberRing = Set(secondAddress), 30.seconds) } enterBarrier("await-completion-2") diff --git a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/LeaderElectionSpec.scala b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/LeaderElectionSpec.scala index 9a09a425ccf..44595913df1 100644 --- a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/LeaderElectionSpec.scala +++ b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/LeaderElectionSpec.scala @@ -15,8 +15,6 @@ package org.apache.pekko.cluster import scala.concurrent.duration._ -import language.postfixOps - import org.apache.pekko import pekko.remote.testkit.MultiNodeConfig import pekko.testkit._ @@ -121,13 +119,13 @@ abstract class LeaderElectionSpec(multiNodeConfig: LeaderElectionMultiNodeConfig } } - "be able to 're-elect' a single leader after leader has left" taggedAs LongRunningTest in within(30 seconds) { + "be able to 're-elect' a single leader after leader has left" taggedAs LongRunningTest in within(30.seconds) { shutdownLeaderAndVerifyNewLeader(alreadyShutdown = 0) enterBarrier("after-2") } "be able to 're-elect' a single leader after leader has left (again)" taggedAs LongRunningTest in within( - 30 seconds) { + 30.seconds) { shutdownLeaderAndVerifyNewLeader(alreadyShutdown = 1) enterBarrier("after-3") } diff --git a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/MBeanSpec.scala b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/MBeanSpec.scala index 9fc91cbb057..fcdcc7a5eb1 100644 --- a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/MBeanSpec.scala +++ b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/MBeanSpec.scala @@ -20,7 +20,6 @@ import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory import javax.management.InstanceNotFoundException import javax.management.ObjectName -import language.postfixOps import org.apache.pekko import pekko.remote.testkit.MultiNodeConfig @@ -107,7 +106,7 @@ abstract class MBeanSpec extends MultiNodeClusterSpec(MBeanMultiJvmSpec) { val fourthAddress = address(fourth) - "format cluster status as JSON with full reachability info" taggedAs LongRunningTest in within(30 seconds) { + "format cluster status as JSON with full reachability info" taggedAs LongRunningTest in within(30.seconds) { runOn(first) { testConductor.exit(fourth, 0).await } @@ -187,7 +186,7 @@ abstract class MBeanSpec extends MultiNodeClusterSpec(MBeanMultiJvmSpec) { } - "support down" taggedAs LongRunningTest in within(20 seconds) { + "support down" taggedAs LongRunningTest in within(20.seconds) { // fourth unreachable in previous step @@ -205,7 +204,7 @@ abstract class MBeanSpec extends MultiNodeClusterSpec(MBeanMultiJvmSpec) { enterBarrier("after-6") } - "support leave" taggedAs LongRunningTest in within(20 seconds) { + "support leave" taggedAs LongRunningTest in within(20.seconds) { runOn(second) { mbeanServer.invoke(mbeanName, "leave", Array(address(third).toString), Array("java.lang.String")) } diff --git a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/MemberWeaklyUpSpec.scala b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/MemberWeaklyUpSpec.scala index 83736605b2f..ee83181da93 100644 --- a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/MemberWeaklyUpSpec.scala +++ b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/MemberWeaklyUpSpec.scala @@ -14,7 +14,6 @@ package org.apache.pekko.cluster import scala.concurrent.duration._ -import scala.language.postfixOps import com.typesafe.config.ConfigFactory @@ -63,7 +62,7 @@ abstract class MemberWeaklyUpSpec extends MultiNodeClusterSpec(MemberWeaklyUpSpe } "detect network partition and mark nodes on other side as unreachable" taggedAs LongRunningTest in within( - 20 seconds) { + 20.seconds) { runOn(first) { // split the cluster in two parts (first, second) / (third, fourth, fifth) for (role1 <- side1; role2 <- side2) { @@ -83,7 +82,7 @@ abstract class MemberWeaklyUpSpec extends MultiNodeClusterSpec(MemberWeaklyUpSpe enterBarrier("after-2") } - "accept joining on each side and set status to WeaklyUp" taggedAs LongRunningTest in within(20 seconds) { + "accept joining on each side and set status to WeaklyUp" taggedAs LongRunningTest in within(20.seconds) { runOn(second) { Cluster(system).join(first) } @@ -113,7 +112,7 @@ abstract class MemberWeaklyUpSpec extends MultiNodeClusterSpec(MemberWeaklyUpSpe enterBarrier("after-3") } - "change status to Up after healed network partition" taggedAs LongRunningTest in within(20 seconds) { + "change status to Up after healed network partition" taggedAs LongRunningTest in within(20.seconds) { runOn(first) { for (role1 <- side1; role2 <- side2) { testConductor.passThrough(role1, role2, Direction.Both).await diff --git a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/RestartFirstSeedNodeSpec.scala b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/RestartFirstSeedNodeSpec.scala index 956007b6931..6b43c7a37d8 100644 --- a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/RestartFirstSeedNodeSpec.scala +++ b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/RestartFirstSeedNodeSpec.scala @@ -17,7 +17,6 @@ import scala.collection.immutable import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import org.apache.pekko import pekko.actor.Actor @@ -84,7 +83,7 @@ abstract class RestartFirstSeedNodeSpec } "Cluster seed nodes" must { - "be able to restart first seed node and join other seed nodes" taggedAs LongRunningTest in within(40 seconds) { + "be able to restart first seed node and join other seed nodes" taggedAs LongRunningTest in within(40.seconds) { // seed1System is a separate ActorSystem, to be able to simulate restart // we must transfer its address to seed2 and seed3 runOn(seed2, seed3) { @@ -103,7 +102,7 @@ abstract class RestartFirstSeedNodeSpec seedNode1Address = Cluster(seed1System).selfAddress List(seed2, seed3).foreach { r => system.actorSelection(RootActorPath(r) / "user" / "address-receiver") ! seedNode1Address - expectMsg(5 seconds, "ok") + expectMsg(5.seconds, "ok") } } enterBarrier("seed1-address-transferred") diff --git a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/SplitBrainSpec.scala b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/SplitBrainSpec.scala index 51b5f41e29d..a7cbf70c9ab 100644 --- a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/SplitBrainSpec.scala +++ b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/SplitBrainSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.cluster import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import org.apache.pekko import pekko.remote.testkit.MultiNodeConfig @@ -77,7 +76,7 @@ abstract class SplitBrainSpec(multiNodeConfig: SplitBrainMultiNodeConfig) } "detect network partition and mark nodes on other side as unreachable and form new cluster" taggedAs LongRunningTest in within( - 30 seconds) { + 30.seconds) { enterBarrier("before-split") runOn(first) { diff --git a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/StressSpec.scala b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/StressSpec.scala index 6ad2db7aa63..a6316ed4e85 100644 --- a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/StressSpec.scala +++ b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/StressSpec.scala @@ -18,7 +18,6 @@ import java.lang.management.ManagementFactory import scala.annotation.tailrec import scala.collection.immutable import scala.concurrent.duration._ -import scala.language.postfixOps import com.typesafe.config.Config import com.typesafe.config.ConfigFactory @@ -857,7 +856,7 @@ abstract class StressSpec extends MultiNodeClusterSpec(StressMultiJvmSpec) with // note: there must be one test step before pending, otherwise afterTermination will not run if (isArteryEnabled && isAeronUdpTransport) pending - "join seed nodes" taggedAs LongRunningTest in within(30 seconds) { + "join seed nodes" taggedAs LongRunningTest in within(30.seconds) { val otherNodesJoiningSeedNodes = roles.slice(numberOfSeedNodes, numberOfSeedNodes + numberOfNodesJoiningToSeedNodesInitially) diff --git a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/UnreachableNodeJoinsAgainSpec.scala b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/UnreachableNodeJoinsAgainSpec.scala index 3bfe0beda35..5eadcd4e41f 100644 --- a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/UnreachableNodeJoinsAgainSpec.scala +++ b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/UnreachableNodeJoinsAgainSpec.scala @@ -18,7 +18,6 @@ import scala.concurrent.Await import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import org.apache.pekko import pekko.actor.ActorSystem @@ -96,7 +95,7 @@ abstract class UnreachableNodeJoinsAgainSpec extends MultiNodeClusterSpec(Unreac val allButVictim = allBut(victim, roles) runOn(victim) { allButVictim.foreach(markNodeAsUnavailable(_)) - within(30 seconds) { + within(30.seconds) { // victim becomes all alone awaitAssert { clusterView.unreachableMembers.size should ===(roles.size - 1) @@ -107,7 +106,7 @@ abstract class UnreachableNodeJoinsAgainSpec extends MultiNodeClusterSpec(Unreac runOn(allButVictim: _*) { markNodeAsUnavailable(victim) - within(30 seconds) { + within(30.seconds) { // victim becomes unreachable awaitAssert { clusterView.unreachableMembers.size should ===(1) @@ -132,7 +131,7 @@ abstract class UnreachableNodeJoinsAgainSpec extends MultiNodeClusterSpec(Unreac runOn(allButVictim: _*) { // eventually removed awaitMembersUp(roles.size - 1, Set(victim)) - awaitAssert(clusterView.unreachableMembers should ===(Set.empty), 15 seconds) + awaitAssert(clusterView.unreachableMembers should ===(Set.empty), 15.seconds) awaitAssert(clusterView.members.map(_.address) should ===(allButVictim.map(address).toSet)) } @@ -184,14 +183,14 @@ abstract class UnreachableNodeJoinsAgainSpec extends MultiNodeClusterSpec(Unreac }""") .withFallback(system.settings.config) - Await.ready(system.whenTerminated, 10 seconds) + Await.ready(system.whenTerminated, 10.seconds) // create new ActorSystem with same host:port val freshSystem = ActorSystem(system.name, freshConfig) try { Cluster(freshSystem).join(masterAddress) - within(30 seconds) { + within(30.seconds) { awaitAssert(Cluster(freshSystem).readView.members.map(_.address) should contain(victimAddress)) awaitAssert(Cluster(freshSystem).readView.members.size should ===(expectedNumberOfMembers)) awaitAssert(Cluster(freshSystem).readView.members.unsorted.map(_.status) should ===(Set(MemberStatus.Up))) @@ -213,7 +212,7 @@ abstract class UnreachableNodeJoinsAgainSpec extends MultiNodeClusterSpec(Unreac awaitMembersUp(expectedNumberOfMembers) // don't end the test until the freshSystem is done runOn(master) { - expectMsg(20 seconds, EndActor.End) + expectMsg(20.seconds, EndActor.End) } endBarrier() } diff --git a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/routing/ClusterRoundRobinSpec.scala b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/routing/ClusterRoundRobinSpec.scala index e49c82e0e60..a88e0b9f3be 100644 --- a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/routing/ClusterRoundRobinSpec.scala +++ b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/routing/ClusterRoundRobinSpec.scala @@ -17,7 +17,6 @@ import scala.concurrent.Await import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import org.apache.pekko import pekko.actor.Actor @@ -132,7 +131,7 @@ abstract class ClusterRoundRobinSpec def receiveReplies(routeeType: RouteeType, expectedReplies: Int): Map[Address, Int] = { val zero = Map.empty[Address, Int] ++ roles.map(address(_) -> 0) - receiveWhile(5 seconds, messages = expectedReplies) { + receiveWhile(5.seconds, messages = expectedReplies) { case Reply(`routeeType`, ref) => fullAddress(ref) }.foldLeft(zero) { case (replyMap, address) => replyMap + (address -> (replyMap(address) + 1)) diff --git a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/routing/UseRoleIgnoredSpec.scala b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/routing/UseRoleIgnoredSpec.scala index d0dec303a13..ed60042e03d 100644 --- a/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/routing/UseRoleIgnoredSpec.scala +++ b/cluster/src/multi-jvm/scala/org/apache/pekko/cluster/routing/UseRoleIgnoredSpec.scala @@ -15,7 +15,6 @@ package org.apache.pekko.cluster.routing import scala.concurrent.Await import scala.concurrent.duration._ -import scala.language.postfixOps import com.typesafe.config.ConfigFactory @@ -75,7 +74,7 @@ abstract class UseRoleIgnoredSpec def receiveReplies(routeeType: RouteeType, expectedReplies: Int): Map[Address, Int] = { val zero = Map.empty[Address, Int] ++ roles.map(address(_) -> 0) - receiveWhile(5 seconds, messages = expectedReplies) { + receiveWhile(5.seconds, messages = expectedReplies) { case Reply(`routeeType`, ref) => fullAddress(ref) }.foldLeft(zero) { case (replyMap, address) => replyMap + (address -> (replyMap(address) + 1)) diff --git a/cluster/src/test/scala/org/apache/pekko/cluster/ClusterConfigSpec.scala b/cluster/src/test/scala/org/apache/pekko/cluster/ClusterConfigSpec.scala index f17380cbbf3..64e617155b7 100644 --- a/cluster/src/test/scala/org/apache/pekko/cluster/ClusterConfigSpec.scala +++ b/cluster/src/test/scala/org/apache/pekko/cluster/ClusterConfigSpec.scala @@ -17,7 +17,6 @@ import scala.concurrent.duration._ import scala.annotation.nowarn import com.typesafe.config.ConfigFactory -import language.postfixOps import org.apache.pekko import pekko.actor.Address @@ -38,21 +37,21 @@ class ClusterConfigSpec extends PekkoSpec { LogInfo should ===(true) FailureDetectorConfig.getDouble("threshold") should ===(8.0 +- 0.0001) FailureDetectorConfig.getInt("max-sample-size") should ===(1000) - FailureDetectorConfig.getMillisDuration("min-std-deviation") should ===(100 millis) - FailureDetectorConfig.getMillisDuration("acceptable-heartbeat-pause") should ===(3 seconds) + FailureDetectorConfig.getMillisDuration("min-std-deviation") should ===(100.millis) + FailureDetectorConfig.getMillisDuration("acceptable-heartbeat-pause") should ===(3.seconds) FailureDetectorImplementationClass should ===(classOf[PhiAccrualFailureDetector].getName) SeedNodes should ===(Vector.empty[Address]) - SeedNodeTimeout should ===(5 seconds) - RetryUnsuccessfulJoinAfter should ===(10 seconds) + SeedNodeTimeout should ===(5.seconds) + RetryUnsuccessfulJoinAfter should ===(10.seconds) ShutdownAfterUnsuccessfulJoinSeedNodes should ===(Duration.Undefined) - PeriodicTasksInitialDelay should ===(1 seconds) - GossipInterval should ===(1 second) - GossipTimeToLive should ===(2 seconds) - HeartbeatInterval should ===(1 second) + PeriodicTasksInitialDelay should ===(1.seconds) + GossipInterval should ===(1.second) + GossipTimeToLive should ===(2.seconds) + HeartbeatInterval should ===(1.second) MonitoredByNrOfMembers should ===(9) - HeartbeatExpectedResponseAfter should ===(1 seconds) - LeaderActionsInterval should ===(1 second) - UnreachableNodesReaperInterval should ===(1 second) + HeartbeatExpectedResponseAfter should ===(1.seconds) + LeaderActionsInterval should ===(1.second) + UnreachableNodesReaperInterval should ===(1.second) PublishStatsInterval should ===(Duration.Undefined) DownRemovalMargin should ===(Duration.Zero) MinNrOfMembers should ===(1) @@ -64,7 +63,7 @@ class ClusterConfigSpec extends PekkoSpec { UseDispatcher should ===(Dispatchers.InternalDispatcherId) GossipDifferentViewProbability should ===(0.8 +- 0.0001) ReduceGossipDifferentViewProbability should ===(400) - SchedulerTickDuration should ===(33 millis) + SchedulerTickDuration should ===(33.millis) SchedulerTicksPerWheel should ===(512) } diff --git a/docs/src/test/scala/docs/actor/ActorDocSpec.scala b/docs/src/test/scala/docs/actor/ActorDocSpec.scala index da97a4f7d2e..b31577bf57d 100644 --- a/docs/src/test/scala/docs/actor/ActorDocSpec.scala +++ b/docs/src/test/scala/docs/actor/ActorDocSpec.scala @@ -15,8 +15,6 @@ package docs.actor import jdocs.actor.ImmutableMessage -import language.postfixOps - //#imports1 import org.apache.pekko import pekko.actor.Actor @@ -336,7 +334,6 @@ final case class Give(thing: Any) //#fiddle_code import org.apache.pekko.actor.{ Actor, ActorRef, ActorSystem, PoisonPill, Props } -import language.postfixOps import scala.concurrent.duration._ case object Ping @@ -400,10 +397,10 @@ class ActorDocSpec extends PekkoSpec(""" system.eventStream.subscribe(testActor, classOf[Logging.Info]) myActor ! "test" - expectMsgPF(1 second) { case Logging.Info(_, _, "received test") => true } + expectMsgPF(1.second) { case Logging.Info(_, _, "received test") => true } myActor ! "unknown" - expectMsgPF(1 second) { case Logging.Info(_, _, "received unknown message") => true } + expectMsgPF(1.second) { case Logging.Info(_, _, "received unknown message") => true } system.eventStream.unsubscribe(testActor) system.eventStream.publish(TestEvent.UnMute(filter)) @@ -420,7 +417,7 @@ class ActorDocSpec extends PekkoSpec(""" val ponger = system.actorOf(Props(classOf[Ponger], pinger), "ponger") import system.dispatcher - system.scheduler.scheduleOnce(500 millis) { + system.scheduler.scheduleOnce(500.millis) { ponger ! Ping } @@ -546,9 +543,9 @@ class ActorDocSpec extends PekkoSpec(""" // #using-explicit-timeout import scala.concurrent.duration._ import org.apache.pekko.pattern.ask - val future = myActor.ask("hello")(5 seconds) + val future = myActor.ask("hello")(5.seconds) // #using-explicit-timeout - Await.result(future, 5 seconds) should be("hello") + Await.result(future, 5.seconds) should be("hello") } "using receiveTimeout" in { @@ -557,11 +554,11 @@ class ActorDocSpec extends PekkoSpec(""" import scala.concurrent.duration._ class MyActor extends Actor { // To set an initial delay - context.setReceiveTimeout(30 milliseconds) + context.setReceiveTimeout(30.milliseconds) def receive = { case "Hello" => // To set in a response to a message - context.setReceiveTimeout(100 milliseconds) + context.setReceiveTimeout(100.milliseconds) case ReceiveTimeout => // To turn it off context.setReceiveTimeout(Duration.Undefined) @@ -671,8 +668,8 @@ class ActorDocSpec extends PekkoSpec(""" import scala.concurrent.Await try { - val stopped: Future[Boolean] = gracefulStop(actorRef, 5 seconds, Manager.Shutdown) - Await.result(stopped, 6 seconds) + val stopped: Future[Boolean] = gracefulStop(actorRef, 5.seconds, Manager.Shutdown) + Await.result(stopped, 6.seconds) // the actor has been stopped } catch { // the actor wasn't stopped within 5 seconds diff --git a/docs/src/test/scala/docs/actor/FSMDocSpec.scala b/docs/src/test/scala/docs/actor/FSMDocSpec.scala index b5f7f4067b1..000858facc5 100644 --- a/docs/src/test/scala/docs/actor/FSMDocSpec.scala +++ b/docs/src/test/scala/docs/actor/FSMDocSpec.scala @@ -13,8 +13,6 @@ package docs.actor -import language.postfixOps - import org.apache.pekko.testkit.{ PekkoSpec => MyFavoriteTestFrameWorkPlusPekkoTestKit } import org.apache.pekko.util.ByteString @@ -81,7 +79,7 @@ class FSMDocSpec extends MyFavoriteTestFrameWorkPlusPekkoTestKit { // #transition-elided // #when-syntax - when(Active, stateTimeout = 1 second) { + when(Active, stateTimeout = 1.second) { case Event(Flush | StateTimeout, t: Todo) => goto(Idle).using(t.copy(queue = Vector.empty)) } @@ -120,13 +118,13 @@ class FSMDocSpec extends MyFavoriteTestFrameWorkPlusPekkoTestKit { // #modifier-syntax when(SomeState) { case Event(msg, _) => - goto(Processing).using(newData).forMax(5 seconds).replying(WillDo) + goto(Processing).using(newData).forMax(5.seconds).replying(WillDo) } // #modifier-syntax // #transition-syntax onTransition { - case Idle -> Active => startTimerWithFixedDelay("timeout", Tick, 1 second) + case Idle -> Active => startTimerWithFixedDelay("timeout", Tick, 1.second) case Active -> _ => cancelTimer("timeout") case x -> Idle => log.info("entering Idle from " + x) } diff --git a/docs/src/test/scala/docs/actor/FaultHandlingDocSample.scala b/docs/src/test/scala/docs/actor/FaultHandlingDocSample.scala index 74c6ba09aa3..4a005e1817c 100644 --- a/docs/src/test/scala/docs/actor/FaultHandlingDocSample.scala +++ b/docs/src/test/scala/docs/actor/FaultHandlingDocSample.scala @@ -13,8 +13,6 @@ package docs.actor -import language.postfixOps - //#all //#imports import org.apache.pekko @@ -57,7 +55,7 @@ object FaultHandlingDocSample extends App { class Listener extends Actor with ActorLogging { import Worker._ // If we don't get any progress within 15 seconds then the service is unavailable - context.setReceiveTimeout(15 seconds) + context.setReceiveTimeout(15.seconds) def receive = { case Progress(percent) => @@ -90,7 +88,7 @@ object Worker { class Worker extends Actor with ActorLogging { import Worker._ import CounterService._ - implicit val askTimeout: Timeout = Timeout(5 seconds) + implicit val askTimeout: Timeout = Timeout(5.seconds) // Stop the CounterService child if it throws ServiceUnavailable override val supervisorStrategy = OneForOneStrategy() { @@ -107,7 +105,7 @@ class Worker extends Actor with ActorLogging { def receive = LoggingReceive { case Start if progressListener.isEmpty => progressListener = Some(sender()) - context.system.scheduler.scheduleWithFixedDelay(Duration.Zero, 1 second, self, Do) + context.system.scheduler.scheduleWithFixedDelay(Duration.Zero, 1.second, self, Do) case Do => counterService ! Increment(1) @@ -147,7 +145,7 @@ class CounterService extends Actor { // Restart the storage child when StorageException is thrown. // After 3 restarts within 5 seconds it will be stopped. - override val supervisorStrategy = OneForOneStrategy(maxNrOfRetries = 3, withinTimeRange = 5 seconds) { + override val supervisorStrategy = OneForOneStrategy(maxNrOfRetries = 3, withinTimeRange = 5.seconds) { case _: Storage.StorageException => Restart } @@ -200,7 +198,7 @@ class CounterService extends Actor { // Tell the counter that there is no storage for the moment counter.foreach { _ ! UseStorage(None) } // Try to re-establish storage after while - context.system.scheduler.scheduleOnce(10 seconds, self, Reconnect) + context.system.scheduler.scheduleOnce(10.seconds, self, Reconnect) case Reconnect => // Re-establish storage after the scheduled delay diff --git a/docs/src/test/scala/docs/actor/FaultHandlingDocSpec.scala b/docs/src/test/scala/docs/actor/FaultHandlingDocSpec.scala index 71166a83071..aebbfcb1129 100644 --- a/docs/src/test/scala/docs/actor/FaultHandlingDocSpec.scala +++ b/docs/src/test/scala/docs/actor/FaultHandlingDocSpec.scala @@ -13,7 +13,6 @@ package docs.actor -import language.postfixOps import org.apache.pekko.actor.{ ActorRef, ActorSystem, Props, Terminated } import FaultHandlingDocSpec._ @@ -39,7 +38,7 @@ object FaultHandlingDocSpec { import scala.concurrent.duration._ override val supervisorStrategy = - OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) { + OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1.minute) { case _: ArithmeticException => Resume case _: NullPointerException => Restart case _: IllegalArgumentException => Stop @@ -62,7 +61,7 @@ object FaultHandlingDocSpec { import scala.concurrent.duration._ override val supervisorStrategy = - OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) { + OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1.minute) { case _: ArithmeticException => Resume case _: NullPointerException => Restart case _: IllegalArgumentException => Stop @@ -86,7 +85,7 @@ object FaultHandlingDocSpec { import scala.concurrent.duration._ override val supervisorStrategy = - OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) { + OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1.minute) { case _: ArithmeticException => Resume case t => super.supervisorStrategy.decider.applyOrElse(t, (_: Any) => Escalate) diff --git a/docs/src/test/scala/docs/actor/SchedulerDocSpec.scala b/docs/src/test/scala/docs/actor/SchedulerDocSpec.scala index ab9e0603351..768dad0ac31 100644 --- a/docs/src/test/scala/docs/actor/SchedulerDocSpec.scala +++ b/docs/src/test/scala/docs/actor/SchedulerDocSpec.scala @@ -15,8 +15,6 @@ package docs.actor import docs.actor.SchedulerDocSpec.TickActor -import language.postfixOps - //#imports1 import org.apache.pekko import pekko.actor.Actor @@ -44,14 +42,14 @@ class SchedulerDocSpec extends PekkoSpec(Map("pekko.loglevel" -> "INFO")) { import system.dispatcher // Schedules to send the "foo"-message to the testActor after 50ms - system.scheduler.scheduleOnce(50 milliseconds, testActor, "foo") + system.scheduler.scheduleOnce(50.milliseconds, testActor, "foo") // #schedule-one-off-message - expectMsg(1 second, "foo") + expectMsg(1.second, "foo") // #schedule-one-off-thunk // Schedules a function to be executed (send a message to the testActor) after 50ms - system.scheduler.scheduleOnce(50 milliseconds) { + system.scheduler.scheduleOnce(50.milliseconds) { testActor ! System.currentTimeMillis } // #schedule-one-off-thunk diff --git a/docs/src/test/scala/docs/actor/SharedMutableStateDocSpec.scala b/docs/src/test/scala/docs/actor/SharedMutableStateDocSpec.scala index a77345d1905..f61aa1145a6 100644 --- a/docs/src/test/scala/docs/actor/SharedMutableStateDocSpec.scala +++ b/docs/src/test/scala/docs/actor/SharedMutableStateDocSpec.scala @@ -21,7 +21,6 @@ class SharedMutableStateDocSpec { import org.apache.pekko.util.Timeout import scala.concurrent.Future import scala.concurrent.duration._ - import scala.language.postfixOps import scala.collection.mutable case class Message(msg: String) diff --git a/docs/src/test/scala/docs/cluster/TransformationBackend.scala b/docs/src/test/scala/docs/cluster/TransformationBackend.scala index 0ef0272abd1..04ec10fbc2a 100644 --- a/docs/src/test/scala/docs/cluster/TransformationBackend.scala +++ b/docs/src/test/scala/docs/cluster/TransformationBackend.scala @@ -13,7 +13,6 @@ package scala.docs.cluster -import language.postfixOps import scala.concurrent.duration._ import org.apache.pekko.actor.Actor import org.apache.pekko.actor.ActorRef diff --git a/docs/src/test/scala/docs/cluster/TransformationFrontend.scala b/docs/src/test/scala/docs/cluster/TransformationFrontend.scala index bc03091317b..244a1e9dccf 100644 --- a/docs/src/test/scala/docs/cluster/TransformationFrontend.scala +++ b/docs/src/test/scala/docs/cluster/TransformationFrontend.scala @@ -13,7 +13,6 @@ package scala.docs.cluster -import language.postfixOps import scala.util.Success import scala.concurrent.duration._ import org.apache.pekko.actor.Actor diff --git a/docs/src/test/scala/docs/dispatcher/DispatcherDocSpec.scala b/docs/src/test/scala/docs/dispatcher/DispatcherDocSpec.scala index 5b258bd375a..137782bc2c8 100644 --- a/docs/src/test/scala/docs/dispatcher/DispatcherDocSpec.scala +++ b/docs/src/test/scala/docs/dispatcher/DispatcherDocSpec.scala @@ -13,8 +13,6 @@ package docs.dispatcher -import language.postfixOps - import org.apache.pekko.testkit.PekkoSpec import org.apache.pekko.event.Logging import org.apache.pekko.event.LoggingAdapter diff --git a/docs/src/test/scala/docs/duration/Sample.scala b/docs/src/test/scala/docs/duration/Sample.scala index e9e4c79ee48..a1b2307f22f 100644 --- a/docs/src/test/scala/docs/duration/Sample.scala +++ b/docs/src/test/scala/docs/duration/Sample.scala @@ -13,8 +13,6 @@ package docs.duration -import language.postfixOps - object Scala { // #dsl import scala.concurrent.duration._ @@ -24,7 +22,7 @@ object Scala { val diff = fivesec - threemillis assert(diff < fivesec) val fourmillis = threemillis * 4 / 3 // you cannot write it the other way around - val n = threemillis / (1 millisecond) + val n = threemillis / (1.millisecond) // #dsl // #deadline diff --git a/docs/src/test/scala/docs/future/FutureDocSpec.scala b/docs/src/test/scala/docs/future/FutureDocSpec.scala index e6dfd16a560..636bb793e19 100644 --- a/docs/src/test/scala/docs/future/FutureDocSpec.scala +++ b/docs/src/test/scala/docs/future/FutureDocSpec.scala @@ -13,7 +13,6 @@ package docs.future -import language.postfixOps import org.apache.pekko import pekko.testkit._ import pekko.actor.{ Actor, ActorRef, Props, Status } @@ -116,7 +115,7 @@ object FutureDocSpec { import org.apache.pekko.pattern.{ ask, pipe } implicit val ec: ExecutionContext = context.dispatcher - implicit val timeout: Timeout = Timeout(5 seconds) + implicit val timeout: Timeout = Timeout(5.seconds) def receive = { case GetUserData => @@ -200,7 +199,7 @@ class FutureDocSpec extends PekkoSpec { } future.foreach(println) // #future-eval - Await.result(future, 3 seconds) should be("HelloWorld") + Await.result(future, 3.seconds) should be("HelloWorld") } "demonstrate usage of map" in { @@ -213,7 +212,7 @@ class FutureDocSpec extends PekkoSpec { } f2.foreach(println) // #map - val result = Await.result(f2, 3 seconds) + val result = Await.result(f2, 3.seconds) result should be(10) f1.value should be(Some(Success("HelloWorld"))) } @@ -231,7 +230,7 @@ class FutureDocSpec extends PekkoSpec { } f3.foreach(println) // #wrong-nested-map - Await.ready(f3, 3 seconds) + Await.ready(f3, 3.seconds) } "demonstrate usage of flatMap" in { @@ -247,7 +246,7 @@ class FutureDocSpec extends PekkoSpec { } f3.foreach(println) // #flat-map - val result = Await.result(f3, 3 seconds) + val result = Await.result(f3, 3.seconds) result should be(30) } @@ -265,9 +264,9 @@ class FutureDocSpec extends PekkoSpec { failedFilter.foreach(println) // #filter - val result = Await.result(future2, 3 seconds) + val result = Await.result(future2, 3.seconds) result should be(4) - val result2 = Await.result(failedFilter, 3 seconds) + val result2 = Await.result(failedFilter, 3.seconds) result2 should be(0) // Can only be 0 when there was a MatchError } @@ -285,7 +284,7 @@ class FutureDocSpec extends PekkoSpec { f.foreach(println) // #for-comprehension - val result = Await.result(f, 3 seconds) + val result = Await.result(f, 3.seconds) result should be(24) } @@ -303,12 +302,12 @@ class FutureDocSpec extends PekkoSpec { val f1 = ask(actor1, msg1) val f2 = ask(actor2, msg2) - val a = Await.result(f1, 3 seconds).asInstanceOf[Int] - val b = Await.result(f2, 3 seconds).asInstanceOf[Int] + val a = Await.result(f1, 3.seconds).asInstanceOf[Int] + val b = Await.result(f2, 3.seconds).asInstanceOf[Int] val f3 = ask(actor3, a + b) - val result = Await.result(f3, 3 seconds).asInstanceOf[Int] + val result = Await.result(f3, 3.seconds).asInstanceOf[Int] // #composing-wrong result should be(3) } @@ -335,7 +334,7 @@ class FutureDocSpec extends PekkoSpec { f3.foreach(println) // #composing - val result = Await.result(f3, 3 seconds).asInstanceOf[Int] + val result = Await.result(f3, 3.seconds).asInstanceOf[Int] result should be(3) } @@ -353,7 +352,7 @@ class FutureDocSpec extends PekkoSpec { val oddSum = futureList.map(_.sum) oddSum.foreach(println) // #sequence-ask - Await.result(oddSum, 3 seconds).asInstanceOf[Int] should be(10000) + Await.result(oddSum, 3.seconds).asInstanceOf[Int] should be(10000) } "demonstrate usage of sequence" in { @@ -362,7 +361,7 @@ class FutureDocSpec extends PekkoSpec { val oddSum = futureList.map(_.sum) oddSum.foreach(println) // #sequence - Await.result(oddSum, 3 seconds).asInstanceOf[Int] should be(10000) + Await.result(oddSum, 3.seconds).asInstanceOf[Int] should be(10000) } "demonstrate usage of traverse" in { @@ -371,7 +370,7 @@ class FutureDocSpec extends PekkoSpec { val oddSum = futureList.map(_.sum) oddSum.foreach(println) // #traverse - Await.result(oddSum, 3 seconds).asInstanceOf[Int] should be(10000) + Await.result(oddSum, 3.seconds).asInstanceOf[Int] should be(10000) } "demonstrate usage of fold" in { @@ -381,7 +380,7 @@ class FutureDocSpec extends PekkoSpec { val futureSum = Future.foldLeft(futures)(0)(_ + _) futureSum.foreach(println) // #fold - Await.result(futureSum, 3 seconds) should be(1001000) + Await.result(futureSum, 3.seconds) should be(1001000) } "demonstrate usage of reduce" in { @@ -391,7 +390,7 @@ class FutureDocSpec extends PekkoSpec { val futureSum = Future.reduceLeft(futures)(_ + _) futureSum.foreach(println) // #reduce - Await.result(futureSum, 3 seconds) should be(1001000) + Await.result(futureSum, 3.seconds) should be(1001000) } "demonstrate usage of recover" in { @@ -419,7 +418,7 @@ class FutureDocSpec extends PekkoSpec { } future.foreach(println) // #try-recover - Await.result(future, 3 seconds) should be(0) + Await.result(future, 3.seconds) should be(0) } "demonstrate usage of zip" in { @@ -429,7 +428,7 @@ class FutureDocSpec extends PekkoSpec { val future3 = future1.zip(future2).map { case (a, b) => a + " " + b } future3.foreach(println) // #zip - Await.result(future3, 3 seconds) should be("foo bar") + Await.result(future3, 3.seconds) should be("foo bar") } "demonstrate usage of andThen" in { @@ -447,7 +446,7 @@ class FutureDocSpec extends PekkoSpec { } result.foreach(println) // #and-then - Await.result(result, 3 seconds) should be("foo bar") + Await.result(result, 3.seconds) should be("foo bar") } "demonstrate usage of fallbackTo" in { @@ -458,7 +457,7 @@ class FutureDocSpec extends PekkoSpec { val future4 = future1.fallbackTo(future2).fallbackTo(future3) future4.foreach(println) // #fallback-to - Await.result(future4, 3 seconds) should be("foo") + Await.result(future4, 3.seconds) should be("foo") } "demonstrate usage of onComplete" in { @@ -471,7 +470,7 @@ class FutureDocSpec extends PekkoSpec { case Failure(failure) => doSomethingOnFailure(failure) } // #onComplete - Await.result(future, 3 seconds) should be("foo") + Await.result(future, 3.seconds) should be("foo") } "demonstrate usage of Future.successful & Future.failed & Future.promise" in { @@ -486,9 +485,9 @@ class FutureDocSpec extends PekkoSpec { val theFuture = promise.future promise.success("hello") // #promise - Await.result(future, 3 seconds) should be("Yay!") - intercept[IllegalArgumentException] { Await.result(otherFuture, 3 seconds) } - Await.result(theFuture, 3 seconds) should be("hello") + Await.result(future, 3.seconds) should be("Yay!") + intercept[IllegalArgumentException] { Await.result(otherFuture, 3.seconds) } + Await.result(theFuture, 3.seconds) should be("hello") } "demonstrate usage of pattern.after" in { @@ -501,7 +500,7 @@ class FutureDocSpec extends PekkoSpec { val future = Future { Thread.sleep(1000); "foo" } val result = Future.firstCompletedOf(Seq(future, delayed)) // #after - intercept[IllegalStateException] { Await.result(result, 2 second) } + intercept[IllegalStateException] { Await.result(result, 2.second) } } "demonstrate pattern.retry" in { @@ -523,10 +522,10 @@ class FutureDocSpec extends PekkoSpec { } // Return a new future that will retry up to 10 times - val retried: Future[Int] = pekko.pattern.retry(() => futureToAttempt(), attempts = 10, 100 milliseconds) + val retried: Future[Int] = pekko.pattern.retry(() => futureToAttempt(), attempts = 10, 100.milliseconds) // #retry - Await.result(retried, 1 second) should ===(5) + Await.result(retried, 1.second) should ===(5) } "demonstrate context.dispatcher" in { diff --git a/docs/src/test/scala/docs/persistence/PersistenceDocSpec.scala b/docs/src/test/scala/docs/persistence/PersistenceDocSpec.scala index da694744690..90f1f6b9387 100644 --- a/docs/src/test/scala/docs/persistence/PersistenceDocSpec.scala +++ b/docs/src/test/scala/docs/persistence/PersistenceDocSpec.scala @@ -18,7 +18,6 @@ import org.apache.pekko.pattern.{ BackoffOpts, BackoffSupervisor } import org.apache.pekko.persistence._ import scala.concurrent.duration._ -import scala.language.postfixOps object PersistenceDocSpec { diff --git a/docs/src/test/scala/docs/stream/operators/sourceorflow/FoldAsync.scala b/docs/src/test/scala/docs/stream/operators/sourceorflow/FoldAsync.scala index 18ba1cc2598..dfc6476e8a6 100644 --- a/docs/src/test/scala/docs/stream/operators/sourceorflow/FoldAsync.scala +++ b/docs/src/test/scala/docs/stream/operators/sourceorflow/FoldAsync.scala @@ -29,8 +29,7 @@ object FoldAsync extends App { // #foldAsync case class Histogram(low: Long = 0, high: Long = 0) { def add(i: Int): Future[Histogram] = - if (i < 100) Future { copy(low = low + 1) } - else Future { copy(high = high + 1) } + if (i < 100) Future { copy(low = low + 1) } else Future { copy(high = high + 1) } } Source(1 to 150).foldAsync(Histogram())((acc, n) => acc.add(n)).runForeach(println) diff --git a/docs/src/test/scala/docs/testkit/TestKitUsageSpec.scala b/docs/src/test/scala/docs/testkit/TestKitUsageSpec.scala index 75456696492..432504fae7b 100644 --- a/docs/src/test/scala/docs/testkit/TestKitUsageSpec.scala +++ b/docs/src/test/scala/docs/testkit/TestKitUsageSpec.scala @@ -13,8 +13,6 @@ package docs.testkit -import language.postfixOps - //#testkit-usage import scala.util.Random @@ -61,7 +59,7 @@ class TestKitUsageSpec "An EchoActor" should { "Respond with the same message it receives" in { - within(500 millis) { + within(500.millis) { echoRef ! "test" expectMsg("test") } @@ -69,7 +67,7 @@ class TestKitUsageSpec } "A ForwardingActor" should { "Forward a message it receives" in { - within(500 millis) { + within(500.millis) { forwardRef ! "test" expectMsg("test") } @@ -78,7 +76,7 @@ class TestKitUsageSpec "A FilteringActor" should { "Filter all messages, except expected messagetypes it receives" in { var messages = Seq[String]() - within(500 millis) { + within(500.millis) { filterRef ! "test" expectMsg("test") filterRef ! 1 @@ -89,7 +87,7 @@ class TestKitUsageSpec filterRef ! "text" filterRef ! 1 - receiveWhile(500 millis) { + receiveWhile(500.millis) { case msg: String => messages = msg +: messages } } @@ -99,7 +97,7 @@ class TestKitUsageSpec } "A SequencingActor" should { "receive an interesting message at some point " in { - within(500 millis) { + within(500.millis) { ignoreMsg { case msg: String => msg != "something" } diff --git a/docs/src/test/scala/docs/testkit/TestkitDocSpec.scala b/docs/src/test/scala/docs/testkit/TestkitDocSpec.scala index 93a1b92ff90..6b41bb39891 100644 --- a/docs/src/test/scala/docs/testkit/TestkitDocSpec.scala +++ b/docs/src/test/scala/docs/testkit/TestkitDocSpec.scala @@ -13,7 +13,6 @@ package docs.testkit -import language.postfixOps import scala.util.Success import org.apache.pekko.testkit._ @@ -164,7 +163,7 @@ class TestKitDocSpec extends PekkoSpec with DefaultTimeout with ImplicitSender { assert(fsm.stateName == 1) assert(fsm.isTimerActive("test") == false) - fsm.startTimerWithFixedDelay("test", 12, 10 millis) + fsm.startTimerWithFixedDelay("test", 12, 10.millis) assert(fsm.isTimerActive("test") == true) fsm.cancelTimer("test") assert(fsm.isTimerActive("test") == false) @@ -191,7 +190,7 @@ class TestKitDocSpec extends PekkoSpec with DefaultTimeout with ImplicitSender { system.eventStream.subscribe(testActor, classOf[UnhandledMessage]) val ref = TestActorRef[MyActor] ref.receive(Unknown) - expectMsg(1 second, UnhandledMessage(Unknown, system.deadLetters, ref)) + expectMsg(1.second, UnhandledMessage(Unknown, system.deadLetters, ref)) // #test-unhandled } @@ -215,7 +214,7 @@ class TestKitDocSpec extends PekkoSpec with DefaultTimeout with ImplicitSender { import scala.concurrent.duration._ val worker = system.actorOf(Props[Worker]()) - within(200 millis) { + within(200.millis) { worker ! "some work" expectMsg("some result") expectNoMessage() // will block for the rest of the 200ms @@ -239,8 +238,8 @@ class TestKitDocSpec extends PekkoSpec with DefaultTimeout with ImplicitSender { val actor = system.actorOf(Props[MyDoubleEcho]()) actor ! ((probe1.ref, probe2.ref)) actor ! "hello" - probe1.expectMsg(500 millis, "hello") - probe2.expectMsg(500 millis, "hello") + probe1.expectMsg(500.millis, "hello") + probe2.expectMsg(500.millis, "hello") // #test-probe // #test-special-probe @@ -285,7 +284,7 @@ class TestKitDocSpec extends PekkoSpec with DefaultTimeout with ImplicitSender { // #test-probe-reply val probe = TestProbe() val future = probe.ref ? "hello" - probe.expectMsg(0 millis, "hello") // TestActor runs on CallingThreadDispatcher + probe.expectMsg(0.millis, "hello") // TestActor runs on CallingThreadDispatcher probe.reply("world") assert(future.isCompleted && future.value.contains(Success("world"))) // #test-probe-reply @@ -372,7 +371,7 @@ class TestKitDocSpec extends PekkoSpec with DefaultTimeout with ImplicitSender { intercept[AssertionError] { // #test-within-probe val probe = TestProbe() - within(1 second) { + within(1.second) { probe.expectMsg("hello") } // #test-within-probe diff --git a/multi-node-testkit/src/main/scala/org/apache/pekko/remote/testconductor/Conductor.scala b/multi-node-testkit/src/main/scala/org/apache/pekko/remote/testconductor/Conductor.scala index 60620238438..9520ec7ba0b 100644 --- a/multi-node-testkit/src/main/scala/org/apache/pekko/remote/testconductor/Conductor.scala +++ b/multi-node-testkit/src/main/scala/org/apache/pekko/remote/testconductor/Conductor.scala @@ -26,7 +26,6 @@ import scala.util.control.NoStackTrace import RemoteConnection.getAddrString import io.netty.channel.{ Channel, ChannelHandlerContext, ChannelInboundHandlerAdapter } import io.netty.channel.ChannelHandler.Sharable -import language.postfixOps import org.apache.pekko import pekko.ConfigurationException @@ -371,7 +370,7 @@ private[pekko] class ServerFSM(val controller: ActorRef, val channel: Channel) channel.close() } - when(Initial, stateTimeout = 10 seconds) { + when(Initial, stateTimeout = 10.seconds) { case Event(Hello(name, address), _) => roleName = RoleName(name) controller ! NodeInfo(roleName, address, self) diff --git a/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/javadsl/CommandHandlerWithReply.scala b/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/javadsl/CommandHandlerWithReply.scala index 4d9a1440d09..14fc4b540a4 100644 --- a/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/javadsl/CommandHandlerWithReply.scala +++ b/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/javadsl/CommandHandlerWithReply.scala @@ -252,7 +252,8 @@ final class CommandHandlerWithReplyBuilderByState[Command, Event, S <: State, St */ def onCommand(predicate: Predicate[Command], handler: JFunction[Command, ReplyEffect[Event, State]]) : CommandHandlerWithReplyBuilderByState[Command, Event, S, State] = { - addCase(cmd => predicate.test(cmd), + addCase( + cmd => predicate.test(cmd), new BiFunction[S, Command, ReplyEffect[Event, State]] { override def apply(state: S, cmd: Command): ReplyEffect[Event, State] = handler(cmd) }) diff --git a/persistence/src/test/scala/org/apache/pekko/persistence/AtLeastOnceDeliveryFailureSpec.scala b/persistence/src/test/scala/org/apache/pekko/persistence/AtLeastOnceDeliveryFailureSpec.scala index 5b405b495cd..4471fe1db9a 100644 --- a/persistence/src/test/scala/org/apache/pekko/persistence/AtLeastOnceDeliveryFailureSpec.scala +++ b/persistence/src/test/scala/org/apache/pekko/persistence/AtLeastOnceDeliveryFailureSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.persistence import java.util.concurrent.ThreadLocalRandom import scala.concurrent.duration._ -import scala.language.postfixOps import com.typesafe.config.ConfigFactory @@ -199,6 +198,6 @@ class AtLeastOnceDeliveryFailureSpec } def expectDone() = within(numMessages.seconds) { - expectMsgType[Done].ints.sorted should ===(1 to numMessages toVector) + expectMsgType[Done].ints.sorted should ===((1 to numMessages).toVector) } } diff --git a/persistence/src/test/scala/org/apache/pekko/persistence/SnapshotFailureRobustnessSpec.scala b/persistence/src/test/scala/org/apache/pekko/persistence/SnapshotFailureRobustnessSpec.scala index 0369188db90..5bd3f60b296 100644 --- a/persistence/src/test/scala/org/apache/pekko/persistence/SnapshotFailureRobustnessSpec.scala +++ b/persistence/src/test/scala/org/apache/pekko/persistence/SnapshotFailureRobustnessSpec.scala @@ -19,7 +19,6 @@ import java.util.UUID import scala.concurrent.Future import scala.concurrent.duration._ -import scala.language.postfixOps import com.typesafe.config.Config @@ -146,7 +145,7 @@ class SnapshotFailureRobustnessSpec } expectMsg("kablama-2") expectMsg(RecoveryCompleted) - expectNoMessage(1 second) + expectNoMessage(1.second) } finally { system.eventStream.unsubscribe(testActor, classOf[Logging.Error]) system.eventStream.publish(TestEvent.UnMute(EventFilter.error(start = "Error loading snapshot ["))) diff --git a/persistence/src/test/scala/org/apache/pekko/persistence/fsm/PersistentFSMSpec.scala b/persistence/src/test/scala/org/apache/pekko/persistence/fsm/PersistentFSMSpec.scala index 6b1a9c5eab9..3cca19dfc68 100644 --- a/persistence/src/test/scala/org/apache/pekko/persistence/fsm/PersistentFSMSpec.scala +++ b/persistence/src/test/scala/org/apache/pekko/persistence/fsm/PersistentFSMSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.persistence.fsm import java.io.File import scala.concurrent.duration._ -import scala.language.postfixOps import scala.reflect.ClassTag import scala.annotation.nowarn @@ -62,7 +61,7 @@ abstract class PersistentFSMSpec(config: Config) extends PersistenceSpec(config) expectMsg(CurrentState(fsmRef, LookingAround, None)) expectMsg(EmptyShoppingCart) - expectMsg(Transition(fsmRef, LookingAround, Shopping, Some(1 second))) + expectMsg(Transition(fsmRef, LookingAround, Shopping, Some(1.second))) expectMsg(NonEmptyShoppingCart(List(shirt))) expectMsg(NonEmptyShoppingCart(List(shirt, shoes))) expectMsg(NonEmptyShoppingCart(List(shirt, shoes, coat))) @@ -88,11 +87,11 @@ abstract class PersistentFSMSpec(config: Config) extends PersistenceSpec(config) expectMsg(CurrentState(fsmRef, LookingAround, None)) - expectMsg(Transition(fsmRef, LookingAround, Shopping, Some(1 second))) + expectMsg(Transition(fsmRef, LookingAround, Shopping, Some(1.second))) val adjustedMin = 1.second - (System.nanoTime - before).nanos within(min = adjustedMin, max = remainingOrDefault) { - expectMsg(Transition(fsmRef, Shopping, Inactive, Some(2 seconds))) + expectMsg(Transition(fsmRef, Shopping, Inactive, Some(2.seconds))) } expectTerminated(fsmRef) @@ -118,7 +117,7 @@ abstract class PersistentFSMSpec(config: Config) extends PersistenceSpec(config) expectMsg(CurrentState(fsmRef, LookingAround, None)) expectMsg(EmptyShoppingCart) - expectMsg(Transition(fsmRef, LookingAround, Shopping, Some(1 second))) + expectMsg(Transition(fsmRef, LookingAround, Shopping, Some(1.second))) expectMsg(NonEmptyShoppingCart(List(shirt))) expectMsg(NonEmptyShoppingCart(List(shirt, shoes))) @@ -138,7 +137,7 @@ abstract class PersistentFSMSpec(config: Config) extends PersistenceSpec(config) recoveredFsmRef ! GetCurrentCart recoveredFsmRef ! Leave - expectMsg(CurrentState(recoveredFsmRef, Shopping, Some(1 second))) + expectMsg(CurrentState(recoveredFsmRef, Shopping, Some(1.second))) expectMsg(NonEmptyShoppingCart(List(shirt, shoes))) expectMsg(NonEmptyShoppingCart(List(shirt, shoes, coat))) @@ -168,7 +167,7 @@ abstract class PersistentFSMSpec(config: Config) extends PersistenceSpec(config) fsmRef ! Leave expectMsg(CurrentState(fsmRef, LookingAround, None)) - expectMsg(Transition(fsmRef, LookingAround, Shopping, Some(1 second))) + expectMsg(Transition(fsmRef, LookingAround, Shopping, Some(1.second))) expectMsg(Transition(fsmRef, Shopping, Paid, None)) reportActorProbe.expectMsg(PurchaseWasMade(List(shirt, shoes, coat))) expectTerminated(fsmRef) @@ -192,7 +191,7 @@ abstract class PersistentFSMSpec(config: Config) extends PersistenceSpec(config) fsmRef ! Leave expectMsg(CurrentState(fsmRef, LookingAround, None)) - expectMsg(Transition(fsmRef, LookingAround, Shopping, Some(1 second))) + expectMsg(Transition(fsmRef, LookingAround, Shopping, Some(1.second))) reportActorProbe.expectMsg(ShoppingCardDiscarded) expectTerminated(fsmRef) } @@ -209,9 +208,9 @@ abstract class PersistentFSMSpec(config: Config) extends PersistenceSpec(config) fsmRef ! AddItem(shirt) expectMsg(CurrentState(fsmRef, LookingAround, None)) - expectMsg(Transition(fsmRef, LookingAround, Shopping, Some(1 second))) + expectMsg(Transition(fsmRef, LookingAround, Shopping, Some(1.second))) - expectNoMessage(0.6 seconds) // arbitrarily chosen delay, less than the timeout, before stopping the FSM + expectNoMessage(0.6.seconds) // arbitrarily chosen delay, less than the timeout, before stopping the FSM fsmRef ! PoisonPill expectTerminated(fsmRef) @@ -221,14 +220,14 @@ abstract class PersistentFSMSpec(config: Config) extends PersistenceSpec(config) // this isn't when it got into that state, but close enough val before = System.nanoTime - expectMsg(CurrentState(recoveredFsmRef, Shopping, Some(1 second))) + expectMsg(CurrentState(recoveredFsmRef, Shopping, Some(1.second))) val adjustedMin = 1.second - (System.nanoTime - before).nanos within(min = adjustedMin, max = remainingOrDefault) { - expectMsg(Transition(recoveredFsmRef, Shopping, Inactive, Some(2 seconds))) + expectMsg(Transition(recoveredFsmRef, Shopping, Inactive, Some(2.seconds))) } - expectNoMessage(0.6 seconds) // arbitrarily chosen delay, less than the timeout, before stopping the FSM + expectNoMessage(0.6.seconds) // arbitrarily chosen delay, less than the timeout, before stopping the FSM recoveredFsmRef ! PoisonPill expectTerminated(recoveredFsmRef) @@ -236,7 +235,7 @@ abstract class PersistentFSMSpec(config: Config) extends PersistenceSpec(config) watch(recoveredFsmRef) recoveredFsmRef ! SubscribeTransitionCallBack(testActor) - expectMsg(CurrentState(recoveredFsmRef, Inactive, Some(2 seconds))) + expectMsg(CurrentState(recoveredFsmRef, Inactive, Some(2.seconds))) expectTerminated(recoveredFsmRef) } @@ -330,7 +329,7 @@ abstract class PersistentFSMSpec(config: Config) extends PersistenceSpec(config) expectMsg(NonEmptyShoppingCart(List(shirt, shoes, coat))) expectMsg(NonEmptyShoppingCart(List(shirt, shoes, coat))) - expectNoMessage(1 second) + expectNoMessage(1.second) fsmRef ! PoisonPill expectTerminated(fsmRef) @@ -499,14 +498,14 @@ object PersistentFSMSpec { when(LookingAround) { case Event(AddItem(item), _) => - goto(Shopping).applying(ItemAdded(item)).forMax(1 seconds) + goto(Shopping).applying(ItemAdded(item)).forMax(1.seconds) case Event(GetCurrentCart, data) => stay().replying(data) } when(Shopping) { case Event(AddItem(item), _) => - stay().applying(ItemAdded(item)).forMax(1 seconds) + stay().applying(ItemAdded(item)).forMax(1.seconds) case Event(Buy, _) => // #customer-andthen-example goto(Paid).applying(OrderExecuted).andThen { @@ -529,12 +528,12 @@ object PersistentFSMSpec { case Event(GetCurrentCart, data) => stay().replying(data) case Event(StateTimeout, _) => - goto(Inactive).forMax(2 seconds) + goto(Inactive).forMax(2.seconds) } when(Inactive) { case Event(AddItem(item), _) => - goto(Shopping).applying(ItemAdded(item)).forMax(1 seconds) + goto(Shopping).applying(ItemAdded(item)).forMax(1.seconds) case Event(StateTimeout, _) => stop().applying(OrderDiscarded).andThen { case _ => reportActor ! ShoppingCardDiscarded diff --git a/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/NewRemoteActorSpec.scala b/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/NewRemoteActorSpec.scala index eea68699424..f6bdb7ea5b2 100644 --- a/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/NewRemoteActorSpec.scala +++ b/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/NewRemoteActorSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.remote import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import testkit.MultiNodeConfig import org.apache.pekko @@ -122,7 +121,7 @@ abstract class NewRemoteActorSpec(multiNodeConfig: NewRemoteActorMultiJvmSpec) enterBarrier("done") } - "be able to shutdown system when using remote deployed actor" in within(20 seconds) { + "be able to shutdown system when using remote deployed actor" in within(20.seconds) { runOn(leader) { val actor = system.actorOf(Props[SomeActor](), "service-hello3") actor.isInstanceOf[RemoteActorRef] should ===(true) diff --git a/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/RemoteDeliverySpec.scala b/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/RemoteDeliverySpec.scala index 1a209b4d8c0..8833f161155 100644 --- a/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/RemoteDeliverySpec.scala +++ b/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/RemoteDeliverySpec.scala @@ -14,7 +14,6 @@ package org.apache.pekko.remote import scala.concurrent.duration._ -import scala.language.postfixOps import com.typesafe.config.ConfigFactory @@ -63,7 +62,7 @@ abstract class RemoteDeliverySpec(multiNodeConfig: RemoteDeliveryConfig) override def initialParticipants = roles.size - def identify(role: RoleName, actorName: String): ActorRef = within(10 seconds) { + def identify(role: RoleName, actorName: String): ActorRef = within(10.seconds) { system.actorSelection(node(role) / "user" / actorName) ! Identify(actorName) expectMsgType[ActorIdentity].ref.get } diff --git a/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/RemoteDeploymentDeathWatchSpec.scala b/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/RemoteDeploymentDeathWatchSpec.scala index 301cdcc3073..5d1a4dcc4c7 100644 --- a/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/RemoteDeploymentDeathWatchSpec.scala +++ b/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/RemoteDeploymentDeathWatchSpec.scala @@ -19,7 +19,6 @@ import scala.concurrent.Await import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import org.apache.pekko import pekko.actor.Actor @@ -92,7 +91,7 @@ abstract class RemoteDeploymentDeathWatchSpec(multiNodeConfig: RemoteDeploymentD "An actor system that deploys actors on another node" must { - "be able to shutdown when remote node crash" taggedAs LongRunningTest in within(20 seconds) { + "be able to shutdown when remote node crash" taggedAs LongRunningTest in within(20.seconds) { runOn(second) { // remote deployment to third val hello = system.actorOf(Props[Hello](), "hello") diff --git a/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/RemoteNodeDeathWatchSpec.scala b/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/RemoteNodeDeathWatchSpec.scala index 77a4a3d3ace..73bea9484b7 100644 --- a/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/RemoteNodeDeathWatchSpec.scala +++ b/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/RemoteNodeDeathWatchSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.remote import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import org.apache.pekko import pekko.actor.Actor @@ -146,7 +145,7 @@ abstract class RemoteNodeDeathWatchSpec(multiNodeConfig: RemoteNodeDeathWatchCon val subject = identify(second, "subject1") watcher ! WatchIt(subject) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) subject ! "hello1" enterBarrier("hello1-message-sent") enterBarrier("watch-established-1") @@ -160,7 +159,7 @@ abstract class RemoteNodeDeathWatchSpec(multiNodeConfig: RemoteNodeDeathWatchCon enterBarrier("actors-started-1") enterBarrier("hello1-message-sent") - expectMsg(3 seconds, "hello1") + expectMsg(3.seconds, "hello1") enterBarrier("watch-established-1") sleep() @@ -190,12 +189,12 @@ abstract class RemoteNodeDeathWatchSpec(multiNodeConfig: RemoteNodeDeathWatchCon val subject = identify(second, "subject2") watcher ! WatchIt(subject) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) enterBarrier("watch-2") sleep() watcher ! UnwatchIt(subject) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) enterBarrier("unwatch-2") } @@ -225,12 +224,12 @@ abstract class RemoteNodeDeathWatchSpec(multiNodeConfig: RemoteNodeDeathWatchCon val other = if (myself == first) second else first val subject = identify(other, "subject3") watcher ! WatchIt(subject) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) enterBarrier("watch-3") sleep() watcher ! UnwatchIt(subject) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) enterBarrier("unwatch-3") } @@ -260,17 +259,17 @@ abstract class RemoteNodeDeathWatchSpec(multiNodeConfig: RemoteNodeDeathWatchCon val subject1 = identify(other, "s1") val subject2 = identify(other, "s2") watcher1 ! WatchIt(subject1) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) watcher2 ! WatchIt(subject2) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) enterBarrier("watch-4") sleep() watcher1 ! UnwatchIt(subject1) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) enterBarrier("unwatch-s1-4") system.stop(s1) - expectNoMessage(2 seconds) + expectNoMessage(2.seconds) enterBarrier("stop-s1-4") system.stop(s2) @@ -308,16 +307,16 @@ abstract class RemoteNodeDeathWatchSpec(multiNodeConfig: RemoteNodeDeathWatchCon val b3 = identify(second, "b3") a1 ! WatchIt(b1) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) a1 ! WatchIt(b2) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) a2 ! WatchIt(b2) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) a3 ! WatchIt(b3) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) sleep() a2 ! UnwatchIt(b2) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) enterBarrier("watch-established-5") @@ -347,33 +346,33 @@ abstract class RemoteNodeDeathWatchSpec(multiNodeConfig: RemoteNodeDeathWatchCon val a3 = identify(first, "a3") b1 ! WatchIt(a1) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) b1 ! WatchIt(a2) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) b2 ! WatchIt(a2) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) b3 ! WatchIt(a3) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) b3 ! WatchIt(a3) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) sleep() b2 ! UnwatchIt(a2) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) enterBarrier("watch-established-5") enterBarrier("stopped-5") - p1.receiveN(2, 5 seconds).collect { case WrappedTerminated(t) => t.actor }.toSet should ===(Set(a1, a2)) - p3.expectMsgType[WrappedTerminated](5 seconds).t.actor should ===(a3) - p2.expectNoMessage(2 seconds) + p1.receiveN(2, 5.seconds).collect { case WrappedTerminated(t) => t.actor }.toSet should ===(Set(a1, a2)) + p3.expectMsgType[WrappedTerminated](5.seconds).t.actor should ===(a3) + p2.expectNoMessage(2.seconds) enterBarrier("terminated-verified-5") // verify that things are cleaned up, and heartbeating is stopped assertCleanup() expectNoMessage(2.seconds) - p1.expectNoMessage(100 millis) - p2.expectNoMessage(100 millis) - p3.expectNoMessage(100 millis) + p1.expectNoMessage(100.millis) + p2.expectNoMessage(100.millis) + p3.expectNoMessage(100.millis) assertCleanup() } @@ -395,15 +394,15 @@ abstract class RemoteNodeDeathWatchSpec(multiNodeConfig: RemoteNodeDeathWatchCon val subject = identify(second, "subject6") watcher ! WatchIt(subject) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) watcher2 ! WatchIt(subject) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) subject ! "hello6" // testing with this watch/unwatch of watcher2 to make sure that the unwatch doesn't // remove the first watch watcher2 ! UnwatchIt(subject) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) enterBarrier("watch-established-6") @@ -411,7 +410,7 @@ abstract class RemoteNodeDeathWatchSpec(multiNodeConfig: RemoteNodeDeathWatchCon log.info("exit second") testConductor.exit(second, 0).await - expectMsgType[WrappedTerminated](15 seconds).t.actor should ===(subject) + expectMsgType[WrappedTerminated](15.seconds).t.actor should ===(subject) // verify that things are cleaned up, and heartbeating is stopped assertCleanup() @@ -423,7 +422,7 @@ abstract class RemoteNodeDeathWatchSpec(multiNodeConfig: RemoteNodeDeathWatchCon system.actorOf(Props(classOf[ProbeActor], testActor), "subject6") enterBarrier("actors-started-6") - expectMsg(3 seconds, "hello6") + expectMsg(3.seconds, "hello6") enterBarrier("watch-established-6") } @@ -442,7 +441,7 @@ abstract class RemoteNodeDeathWatchSpec(multiNodeConfig: RemoteNodeDeathWatchCon val subject = identify(first, "subject7") watcher ! WatchIt(subject) - expectMsg(1 second, Ack) + expectMsg(1.second, Ack) subject ! "hello7" enterBarrier("watch-established-7") } @@ -451,7 +450,7 @@ abstract class RemoteNodeDeathWatchSpec(multiNodeConfig: RemoteNodeDeathWatchCon system.actorOf(Props(classOf[ProbeActor], testActor), "subject7") enterBarrier("actors-started-7") - expectMsg(3 seconds, "hello7") + expectMsg(3.seconds, "hello7") enterBarrier("watch-established-7") sleep() @@ -459,7 +458,7 @@ abstract class RemoteNodeDeathWatchSpec(multiNodeConfig: RemoteNodeDeathWatchCon testConductor.exit(third, 0).await // verify that things are cleaned up, and heartbeating is stopped - assertCleanup(20 seconds) + assertCleanup(20.seconds) expectNoMessage(2.seconds) assertCleanup() } diff --git a/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/artery/RemoteRestartedQuarantinedSpec.scala b/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/artery/RemoteRestartedQuarantinedSpec.scala index e7bf806767f..dffea04a02a 100644 --- a/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/artery/RemoteRestartedQuarantinedSpec.scala +++ b/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/artery/RemoteRestartedQuarantinedSpec.scala @@ -15,7 +15,6 @@ package org.apache.pekko.remote.artery import scala.concurrent.Await import scala.concurrent.duration._ -import scala.language.postfixOps import com.typesafe.config.ConfigFactory @@ -110,7 +109,7 @@ abstract class RemoteRestartedQuarantinedSpec extends RemotingMultiNodeSpec(Remo enterBarrier("before-quarantined") enterBarrier("quarantined") - expectMsgPF(10 seconds) { + expectMsgPF(10.seconds) { case ThisActorSystemQuarantinedEvent(_, _) => } diff --git a/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/classic/RemoteNodeShutdownAndComesBackSpec.scala b/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/classic/RemoteNodeShutdownAndComesBackSpec.scala index f0b14b0d230..04a69451249 100644 --- a/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/classic/RemoteNodeShutdownAndComesBackSpec.scala +++ b/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/classic/RemoteNodeShutdownAndComesBackSpec.scala @@ -15,7 +15,6 @@ package org.apache.pekko.remote.classic import scala.concurrent.Await import scala.concurrent.duration._ -import scala.language.postfixOps import com.typesafe.config.ConfigFactory @@ -114,7 +113,7 @@ abstract class RemoteNodeShutdownAndComesBackSpec extends RemotingMultiNodeSpec( awaitAssert { val p = TestProbe() system.actorSelection(RootActorPath(secondAddress) / "user" / "subject").tell(Identify("subject"), p.ref) - p.expectMsgPF(1 second) { + p.expectMsgPF(1.second) { case ActorIdentity("subject", Some(_)) => true } } diff --git a/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/routing/RemoteRoundRobinSpec.scala b/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/routing/RemoteRoundRobinSpec.scala index 9266aaa57be..98fc82c8de1 100644 --- a/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/routing/RemoteRoundRobinSpec.scala +++ b/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/routing/RemoteRoundRobinSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.remote.routing import scala.collection.immutable import scala.concurrent.Await import scala.concurrent.duration._ -import scala.language.postfixOps import com.typesafe.config.ConfigFactory @@ -111,7 +110,7 @@ class RemoteRoundRobinSpec(multiNodeConfig: RemoteRoundRobinConfig) actor ! "hit" } - val replies: Map[Address, Int] = receiveWhile(5 seconds, messages = connectionCount * iterationCount) { + val replies: Map[Address, Int] = receiveWhile(5.seconds, messages = connectionCount * iterationCount) { case ref: ActorRef => info(s"reply from $ref") ref.path.address @@ -136,7 +135,7 @@ class RemoteRoundRobinSpec(multiNodeConfig: RemoteRoundRobinConfig) } "A remote round robin pool with resizer" must { - "be locally instantiated on a remote node after several resize rounds" in within(5 seconds) { + "be locally instantiated on a remote node after several resize rounds" in within(5.seconds) { runOn(first, second, third) { enterBarrier("start", "broadcast-end", "end") @@ -199,7 +198,7 @@ class RemoteRoundRobinSpec(multiNodeConfig: RemoteRoundRobinConfig) actor ! "hit" } - val replies: Map[Address, Int] = receiveWhile(5 seconds, messages = connectionCount * iterationCount) { + val replies: Map[Address, Int] = receiveWhile(5.seconds, messages = connectionCount * iterationCount) { case ref: ActorRef => ref.path.address }.foldLeft(Map(node(first).address -> 0, node(second).address -> 0, node(third).address -> 0)) { case (replyMap, address) => replyMap + (address -> (replyMap(address) + 1)) diff --git a/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/testconductor/TestConductorSpec.scala b/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/testconductor/TestConductorSpec.scala index 5b495779a76..eee8ef87db4 100644 --- a/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/testconductor/TestConductorSpec.scala +++ b/remote-tests/src/multi-jvm/scala/org/apache/pekko/remote/testconductor/TestConductorSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.remote.testconductor import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import org.apache.pekko import pekko.actor.{ Actor, ActorIdentity, Deploy, Identify, Props } @@ -83,8 +82,8 @@ class TestConductorSpec extends RemotingMultiNodeSpec(TestConductorMultiJvmSpec) for (i <- 0 to 9) echo ! i } - within(0.5 seconds, 2 seconds) { - expectMsg(500 millis, 0) + within(0.5.seconds, 2.seconds) { + expectMsg(500.millis, 0) receiveN(9) should ===(1 to 9) } @@ -102,11 +101,11 @@ class TestConductorSpec extends RemotingMultiNodeSpec(TestConductorMultiJvmSpec) } val (min, max) = - if (isNode(leader)) (0 seconds, 500 millis) - else (0.3 seconds, 3 seconds) + if (isNode(leader)) (0.seconds, 500.millis) + else (0.3.seconds, 3.seconds) within(min, max) { - expectMsg(500 millis, 10) + expectMsg(500.millis, 10) receiveN(9) should ===(11 to 19) } diff --git a/remote-tests/src/test/scala/org/apache/pekko/remote/testconductor/BarrierSpec.scala b/remote-tests/src/test/scala/org/apache/pekko/remote/testconductor/BarrierSpec.scala index 55249e13d7e..7047f44a096 100644 --- a/remote-tests/src/test/scala/org/apache/pekko/remote/testconductor/BarrierSpec.scala +++ b/remote-tests/src/test/scala/org/apache/pekko/remote/testconductor/BarrierSpec.scala @@ -17,8 +17,6 @@ import java.net.{ InetAddress, InetSocketAddress } import scala.concurrent.duration._ -import language.postfixOps - import org.apache.pekko import pekko.actor._ import pekko.testkit.{ EventFilter, ImplicitSender, PekkoSpec, TestProbe, TimingTest } @@ -60,9 +58,9 @@ class BarrierSpec extends PekkoSpec(BarrierSpec.config) with ImplicitSender { val b = getBarrier() b ! NodeInfo(A, AddressFromURIString("pekko://sys"), system.deadLetters) b ! ClientDisconnected(B) - expectNoMessage(1 second) + expectNoMessage(1.second) b ! ClientDisconnected(A) - expectNoMessage(1 second) + expectNoMessage(1.second) } "fail entering barrier when nobody registered" taggedAs TimingTest in { @@ -78,7 +76,7 @@ class BarrierSpec extends PekkoSpec(BarrierSpec.config) with ImplicitSender { barrier ! NodeInfo(B, AddressFromURIString("pekko://sys"), b.ref) a.send(barrier, EnterBarrier("bar2", None)) noMsg(a, b) - within(2 seconds) { + within(2.seconds) { b.send(barrier, EnterBarrier("bar2", None)) a.expectMsg(ToClient(BarrierResult("bar2", true))) b.expectMsg(ToClient(BarrierResult("bar2", true))) @@ -94,7 +92,7 @@ class BarrierSpec extends PekkoSpec(BarrierSpec.config) with ImplicitSender { barrier ! NodeInfo(C, AddressFromURIString("pekko://sys"), c.ref) b.send(barrier, EnterBarrier("bar3", None)) noMsg(a, b, c) - within(2 seconds) { + within(2.seconds) { c.send(barrier, EnterBarrier("bar3", None)) a.expectMsg(ToClient(BarrierResult("bar3", true))) b.expectMsg(ToClient(BarrierResult("bar3", true))) @@ -113,12 +111,12 @@ class BarrierSpec extends PekkoSpec(BarrierSpec.config) with ImplicitSender { barrier ! RemoveClient(A) barrier ! ClientDisconnected(A) noMsg(a, b, c) - b.within(2 seconds) { + b.within(2.seconds) { barrier ! RemoveClient(C) b.expectMsg(ToClient(BarrierResult("bar4", true))) } barrier ! ClientDisconnected(C) - expectNoMessage(1 second) + expectNoMessage(1.second) } "leave barrier when last “arrived” is removed" taggedAs TimingTest in { @@ -232,7 +230,7 @@ class BarrierSpec extends PekkoSpec(BarrierSpec.config) with ImplicitSender { barrier ! nodeB a.send(barrier, EnterBarrier("bar10", None)) EventFilter[BarrierTimeout](occurrences = 1).intercept { - val msg = expectMsgType[Failed](7 seconds) + val msg = expectMsgType[Failed](7.seconds) msg match { case Failed(_, thr: BarrierTimeout) if thr == BarrierTimeout(Data(Set(nodeA, nodeB), "bar10", a.ref :: Nil, thr.data.deadline)) => @@ -263,7 +261,7 @@ class BarrierSpec extends PekkoSpec(BarrierSpec.config) with ImplicitSender { } "finally have no failure messages left" taggedAs TimingTest in { - expectNoMessage(1 second) + expectNoMessage(1.second) } } @@ -288,9 +286,9 @@ class BarrierSpec extends PekkoSpec(BarrierSpec.config) with ImplicitSender { b ! NodeInfo(A, AddressFromURIString("pekko://sys"), testActor) expectMsg(ToClient(Done)) b ! ClientDisconnected(B) - expectNoMessage(1 second) + expectNoMessage(1.second) b ! ClientDisconnected(A) - expectNoMessage(1 second) + expectNoMessage(1.second) } } @@ -310,7 +308,7 @@ class BarrierSpec extends PekkoSpec(BarrierSpec.config) with ImplicitSender { b.expectMsg(ToClient(Done)) a.send(barrier, EnterBarrier("bar11", None)) noMsg(a, b) - within(2 seconds) { + within(2.seconds) { b.send(barrier, EnterBarrier("bar11", None)) a.expectMsg(ToClient(BarrierResult("bar11", true))) b.expectMsg(ToClient(BarrierResult("bar11", true))) @@ -330,7 +328,7 @@ class BarrierSpec extends PekkoSpec(BarrierSpec.config) with ImplicitSender { c.expectMsg(ToClient(Done)) b.send(barrier, EnterBarrier("bar12", None)) noMsg(a, b, c) - within(2 seconds) { + within(2.seconds) { c.send(barrier, EnterBarrier("bar12", None)) a.expectMsg(ToClient(BarrierResult("bar12", true))) b.expectMsg(ToClient(BarrierResult("bar12", true))) @@ -353,12 +351,12 @@ class BarrierSpec extends PekkoSpec(BarrierSpec.config) with ImplicitSender { barrier ! Remove(A) barrier ! ClientDisconnected(A) noMsg(a, b, c) - b.within(2 seconds) { + b.within(2.seconds) { barrier ! Remove(C) b.expectMsg(ToClient(BarrierResult("bar13", true))) } barrier ! ClientDisconnected(C) - expectNoMessage(1 second) + expectNoMessage(1.second) } } @@ -441,7 +439,7 @@ class BarrierSpec extends PekkoSpec(BarrierSpec.config) with ImplicitSender { barrier ! nodeB a.expectMsg(ToClient(Done)) b.expectMsg(ToClient(Done)) - a.send(barrier, EnterBarrier("bar18", Option(2 seconds))) + a.send(barrier, EnterBarrier("bar18", Option(2.seconds))) EventFilter[BarrierTimeout](occurrences = 1).intercept { Thread.sleep(4000) } @@ -490,11 +488,11 @@ class BarrierSpec extends PekkoSpec(BarrierSpec.config) with ImplicitSender { barrier ! nodeB a.expectMsg(ToClient(Done)) b.expectMsg(ToClient(Done)) - a.send(barrier, EnterBarrier("bar20", Option(2 seconds))) + a.send(barrier, EnterBarrier("bar20", Option(2.seconds))) EventFilter[FailedBarrier](occurrences = 1).intercept { b.send(barrier, FailBarrier("bar20")) a.expectMsg(ToClient(BarrierResult("bar20", false))) - b.expectNoMessage(1 second) + b.expectNoMessage(1.second) } a.send(barrier, EnterBarrier("bar21", None)) b.send(barrier, EnterBarrier("bar21", None)) @@ -515,8 +513,8 @@ class BarrierSpec extends PekkoSpec(BarrierSpec.config) with ImplicitSender { a.expectMsg(ToClient(Done)) b.expectMsg(ToClient(Done)) c.expectMsg(ToClient(Done)) - a.send(barrier, EnterBarrier("bar22", Option(10 seconds))) - b.send(barrier, EnterBarrier("bar22", Option(2 seconds))) + a.send(barrier, EnterBarrier("bar22", Option(10.seconds))) + b.send(barrier, EnterBarrier("bar22", Option(2.seconds))) EventFilter[BarrierTimeout](occurrences = 1).intercept { Thread.sleep(4000) } @@ -539,8 +537,8 @@ class BarrierSpec extends PekkoSpec(BarrierSpec.config) with ImplicitSender { a.expectMsg(ToClient(Done)) b.expectMsg(ToClient(Done)) c.expectMsg(ToClient(Done)) - a.send(barrier, EnterBarrier("bar23", Option(2 seconds))) - b.send(barrier, EnterBarrier("bar23", Option(10 seconds))) + a.send(barrier, EnterBarrier("bar23", Option(2.seconds))) + b.send(barrier, EnterBarrier("bar23", Option(10.seconds))) EventFilter[BarrierTimeout](occurrences = 1).intercept { Thread.sleep(4000) } @@ -552,7 +550,7 @@ class BarrierSpec extends PekkoSpec(BarrierSpec.config) with ImplicitSender { } "finally have no failure messages left" taggedAs TimingTest in { - expectNoMessage(1 second) + expectNoMessage(1.second) } } @@ -592,7 +590,7 @@ class BarrierSpec extends PekkoSpec(BarrierSpec.config) with ImplicitSender { } private def noMsg(probes: TestProbe*): Unit = { - expectNoMessage(1 second) + expectNoMessage(1.second) probes.foreach(_.msgAvailable should ===(false)) } diff --git a/remote/src/test/scala/org/apache/pekko/remote/RemoteConfigSpec.scala b/remote/src/test/scala/org/apache/pekko/remote/RemoteConfigSpec.scala index 62434d809ef..a8518459128 100644 --- a/remote/src/test/scala/org/apache/pekko/remote/RemoteConfigSpec.scala +++ b/remote/src/test/scala/org/apache/pekko/remote/RemoteConfigSpec.scala @@ -18,8 +18,6 @@ import io.netty.buffer.PooledByteBufAllocator import scala.concurrent.duration._ import scala.annotation.nowarn -import language.postfixOps - import org.apache.pekko import pekko.remote.transport.PekkoProtocolSettings import pekko.remote.transport.netty.{ NettyTransportSettings, SSLSettings } @@ -43,21 +41,21 @@ class RemoteConfigSpec extends PekkoSpec(""" LogSend should ===(false) UntrustedMode should ===(false) TrustedSelectionPaths should ===(Set.empty[String]) - ShutdownTimeout.duration should ===(10 seconds) - FlushWait should ===(2 seconds) - StartupTimeout.duration should ===(10 seconds) - RetryGateClosedFor should ===(5 seconds) + ShutdownTimeout.duration should ===(10.seconds) + FlushWait should ===(2.seconds) + StartupTimeout.duration should ===(10.seconds) + RetryGateClosedFor should ===(5.seconds) Dispatcher should ===("pekko.remote.default-remote-dispatcher") UsePassiveConnections should ===(true) - BackoffPeriod should ===(5 millis) + BackoffPeriod should ===(5.millis) LogBufferSizeExceeding should ===(50000) - SysMsgAckTimeout should ===(0.3 seconds) - SysResendTimeout should ===(2 seconds) + SysMsgAckTimeout should ===(0.3.seconds) + SysResendTimeout should ===(2.seconds) SysResendLimit should ===(200) SysMsgBufferSize should ===(20000) - InitialSysMsgDeliveryTimeout should ===(3 minutes) - QuarantineDuration should ===(5 days) - CommandAckTimeout.duration should ===(30 seconds) + InitialSysMsgDeliveryTimeout should ===(3.minutes) + QuarantineDuration should ===(5.days) + CommandAckTimeout.duration should ===(30.seconds) Transports.size should ===(1) Transports.head._1 should ===(classOf[pekko.remote.transport.netty.NettyTransport].getName) Transports.head._2 should ===(Nil) @@ -67,13 +65,13 @@ class RemoteConfigSpec extends PekkoSpec(""" "trttl" -> classOf[pekko.remote.transport.ThrottlerProvider].getName)) WatchFailureDetectorImplementationClass should ===(classOf[PhiAccrualFailureDetector].getName) - WatchHeartBeatInterval should ===(1 seconds) - WatchHeartbeatExpectedResponseAfter should ===(1 seconds) - WatchUnreachableReaperInterval should ===(1 second) + WatchHeartBeatInterval should ===(1.seconds) + WatchHeartbeatExpectedResponseAfter should ===(1.seconds) + WatchUnreachableReaperInterval should ===(1.second) WatchFailureDetectorConfig.getDouble("threshold") should ===(10.0 +- 0.0001) WatchFailureDetectorConfig.getInt("max-sample-size") should ===(200) - WatchFailureDetectorConfig.getMillisDuration("acceptable-heartbeat-pause") should ===(10 seconds) - WatchFailureDetectorConfig.getMillisDuration("min-std-deviation") should ===(100 millis) + WatchFailureDetectorConfig.getMillisDuration("acceptable-heartbeat-pause") should ===(10.seconds) + WatchFailureDetectorConfig.getMillisDuration("min-std-deviation") should ===(100.millis) remoteSettings.config.getString("pekko.remote.classic.log-frame-size-exceeding") should ===("off") } diff --git a/remote/src/test/scala/org/apache/pekko/remote/artery/RemoteWatcherSpec.scala b/remote/src/test/scala/org/apache/pekko/remote/artery/RemoteWatcherSpec.scala index 8f57457a0d9..f8cc5fbf21d 100644 --- a/remote/src/test/scala/org/apache/pekko/remote/artery/RemoteWatcherSpec.scala +++ b/remote/src/test/scala/org/apache/pekko/remote/artery/RemoteWatcherSpec.scala @@ -14,7 +14,6 @@ package org.apache.pekko.remote.artery import scala.concurrent.duration._ -import scala.language.postfixOps import com.typesafe.config.ConfigFactory @@ -124,48 +123,48 @@ class RemoteWatcherSpec monitorA ! Stats // (a1->b1), (a1->b2), (a2->b2) expectMsg(Stats.counts(watching = 3, watchingNodes = 1)) - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA ! HeartbeatTick expectMsg(ArteryHeartbeat) - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA ! HeartbeatTick expectMsg(ArteryHeartbeat) - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA.tell(heartbeatRspB, monitorB) monitorA ! HeartbeatTick expectMsg(ArteryHeartbeat) - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA ! UnwatchRemote(b1, a1) // still (a1->b2) and (a2->b2) left monitorA ! Stats expectMsg(Stats.counts(watching = 2, watchingNodes = 1)) - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA ! HeartbeatTick expectMsg(ArteryHeartbeat) - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA ! UnwatchRemote(b2, a2) // still (a1->b2) left monitorA ! Stats expectMsg(Stats.counts(watching = 1, watchingNodes = 1)) - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA ! HeartbeatTick expectMsg(ArteryHeartbeat) - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA ! UnwatchRemote(b2, a1) // all unwatched monitorA ! Stats expectMsg(Stats.empty) - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA ! HeartbeatTick - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA ! HeartbeatTick - expectNoMessage(100 millis) + expectNoMessage(100.millis) // make sure nothing floods over to next test - expectNoMessage(2 seconds) + expectNoMessage(2.seconds) } "generate AddressTerminated when missing heartbeats" taggedAs LongRunningTest in { @@ -185,24 +184,24 @@ class RemoteWatcherSpec monitorA ! HeartbeatTick expectMsg(ArteryHeartbeat) monitorA.tell(heartbeatRspB, monitorB) - expectNoMessage(1 second) + expectNoMessage(1.second) monitorA ! HeartbeatTick expectMsg(ArteryHeartbeat) monitorA.tell(heartbeatRspB, monitorB) - within(10 seconds) { + within(10.seconds) { awaitAssert { monitorA ! HeartbeatTick expectMsg(ArteryHeartbeat) // but no HeartbeatRsp monitorA ! ReapUnreachableTick - p.expectMsg(1 second, TestRemoteWatcher.AddressTerm(b.path.address)) - q.expectMsg(1 second, TestRemoteWatcher.Quarantined(b.path.address, Some(remoteAddressUid))) + p.expectMsg(1.second, TestRemoteWatcher.AddressTerm(b.path.address)) + q.expectMsg(1.second, TestRemoteWatcher.Quarantined(b.path.address, Some(remoteAddressUid))) } } // make sure nothing floods over to next test - expectNoMessage(2 seconds) + expectNoMessage(2.seconds) } "generate AddressTerminated when missing first heartbeat" taggedAs LongRunningTest in { @@ -224,20 +223,20 @@ class RemoteWatcherSpec expectMsg(ArteryHeartbeat) // no HeartbeatRsp sent - within(20 seconds) { + within(20.seconds) { awaitAssert { monitorA ! HeartbeatTick expectMsg(ArteryHeartbeat) // but no HeartbeatRsp monitorA ! ReapUnreachableTick - p.expectMsg(1 second, TestRemoteWatcher.AddressTerm(b.path.address)) + p.expectMsg(1.second, TestRemoteWatcher.AddressTerm(b.path.address)) // no real quarantine when missing first heartbeat, uid unknown - q.expectMsg(1 second, TestRemoteWatcher.Quarantined(b.path.address, None)) + q.expectMsg(1.second, TestRemoteWatcher.Quarantined(b.path.address, None)) } } // make sure nothing floods over to next test - expectNoMessage(2 seconds) + expectNoMessage(2.seconds) } "generate AddressTerminated for new watch after broken connection that was re-established and broken again" taggedAs LongRunningTest in { @@ -257,19 +256,19 @@ class RemoteWatcherSpec monitorA ! HeartbeatTick expectMsg(ArteryHeartbeat) monitorA.tell(heartbeatRspB, monitorB) - expectNoMessage(1 second) + expectNoMessage(1.second) monitorA ! HeartbeatTick expectMsg(ArteryHeartbeat) monitorA.tell(heartbeatRspB, monitorB) - within(10 seconds) { + within(10.seconds) { awaitAssert { monitorA ! HeartbeatTick expectMsg(ArteryHeartbeat) // but no HeartbeatRsp monitorA ! ReapUnreachableTick - p.expectMsg(1 second, TestRemoteWatcher.AddressTerm(b.path.address)) - q.expectMsg(1 second, TestRemoteWatcher.Quarantined(b.path.address, Some(remoteAddressUid))) + p.expectMsg(1.second, TestRemoteWatcher.AddressTerm(b.path.address)) + q.expectMsg(1.second, TestRemoteWatcher.Quarantined(b.path.address, Some(remoteAddressUid))) } } @@ -279,7 +278,7 @@ class RemoteWatcherSpec monitorA ! Stats expectMsg(Stats.empty) } - expectNoMessage(2 seconds) + expectNoMessage(2.seconds) // assume that connection comes up again, or remote system is restarted val c = createRemoteActor(Props[MyActor](), "c6") @@ -289,37 +288,37 @@ class RemoteWatcherSpec monitorA ! HeartbeatTick expectMsg(ArteryHeartbeat) monitorA.tell(heartbeatRspB, monitorB) - expectNoMessage(1 second) + expectNoMessage(1.second) monitorA ! HeartbeatTick expectMsg(ArteryHeartbeat) monitorA.tell(heartbeatRspB, monitorB) monitorA ! HeartbeatTick expectMsg(ArteryHeartbeat) monitorA ! ReapUnreachableTick - p.expectNoMessage(1 second) + p.expectNoMessage(1.second) monitorA ! HeartbeatTick expectMsg(ArteryHeartbeat) monitorA.tell(heartbeatRspB, monitorB) monitorA ! HeartbeatTick expectMsg(ArteryHeartbeat) monitorA ! ReapUnreachableTick - p.expectNoMessage(1 second) - q.expectNoMessage(1 second) + p.expectNoMessage(1.second) + q.expectNoMessage(1.second) // then stop heartbeating again, should generate new AddressTerminated - within(10 seconds) { + within(10.seconds) { awaitAssert { monitorA ! HeartbeatTick expectMsg(ArteryHeartbeat) // but no HeartbeatRsp monitorA ! ReapUnreachableTick - p.expectMsg(1 second, TestRemoteWatcher.AddressTerm(c.path.address)) - q.expectMsg(1 second, TestRemoteWatcher.Quarantined(c.path.address, Some(remoteAddressUid))) + p.expectMsg(1.second, TestRemoteWatcher.AddressTerm(c.path.address)) + q.expectMsg(1.second, TestRemoteWatcher.Quarantined(c.path.address, Some(remoteAddressUid))) } } // make sure nothing floods over to next test - expectNoMessage(2 seconds) + expectNoMessage(2.seconds) } } diff --git a/remote/src/test/scala/org/apache/pekko/remote/classic/RemoteInitErrorSpec.scala b/remote/src/test/scala/org/apache/pekko/remote/classic/RemoteInitErrorSpec.scala index 5d374eaa11e..09bb9e7cdf6 100644 --- a/remote/src/test/scala/org/apache/pekko/remote/classic/RemoteInitErrorSpec.scala +++ b/remote/src/test/scala/org/apache/pekko/remote/classic/RemoteInitErrorSpec.scala @@ -15,7 +15,6 @@ package org.apache.pekko.remote.classic import scala.collection.mutable.Set import scala.concurrent.duration._ -import scala.language.postfixOps import scala.util.control.NonFatal import com.typesafe.config.ConfigFactory @@ -62,7 +61,7 @@ class RemoteInitErrorSpec extends AnyWordSpec with Matchers { fail("initialization should fail due to invalid IP address") } catch { case NonFatal(_) => { - eventually(timeout(30 seconds), interval(800 milliseconds)) { + eventually(timeout(30.seconds), interval(800.milliseconds)) { val current = currentThreadIds() // no new threads should remain compared to the start state (current.diff(start)) should be(empty) diff --git a/remote/src/test/scala/org/apache/pekko/remote/classic/RemoteWatcherSpec.scala b/remote/src/test/scala/org/apache/pekko/remote/classic/RemoteWatcherSpec.scala index d5ba9b048f0..f0569189eca 100644 --- a/remote/src/test/scala/org/apache/pekko/remote/classic/RemoteWatcherSpec.scala +++ b/remote/src/test/scala/org/apache/pekko/remote/classic/RemoteWatcherSpec.scala @@ -14,7 +14,6 @@ package org.apache.pekko.remote.classic import scala.concurrent.duration._ -import scala.language.postfixOps import scala.annotation.nowarn @@ -140,48 +139,48 @@ class RemoteWatcherSpec extends PekkoSpec(""" monitorA ! Stats // (a1->b1), (a1->b2), (a2->b2) expectMsg(Stats.counts(watching = 3, watchingNodes = 1)) - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA ! HeartbeatTick expectMsg(Heartbeat) - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA ! HeartbeatTick expectMsg(Heartbeat) - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA.tell(heartbeatRspB, monitorB) monitorA ! HeartbeatTick expectMsg(Heartbeat) - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA ! UnwatchRemote(b1, a1) // still (a1->b2) and (a2->b2) left monitorA ! Stats expectMsg(Stats.counts(watching = 2, watchingNodes = 1)) - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA ! HeartbeatTick expectMsg(Heartbeat) - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA ! UnwatchRemote(b2, a2) // still (a1->b2) left monitorA ! Stats expectMsg(Stats.counts(watching = 1, watchingNodes = 1)) - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA ! HeartbeatTick expectMsg(Heartbeat) - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA ! UnwatchRemote(b2, a1) // all unwatched monitorA ! Stats expectMsg(Stats.empty) - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA ! HeartbeatTick - expectNoMessage(100 millis) + expectNoMessage(100.millis) monitorA ! HeartbeatTick - expectNoMessage(100 millis) + expectNoMessage(100.millis) // make sure nothing floods over to next test - expectNoMessage(2 seconds) + expectNoMessage(2.seconds) } "generate AddressTerminated when missing heartbeats" taggedAs LongRunningTest in { @@ -201,24 +200,24 @@ class RemoteWatcherSpec extends PekkoSpec(""" monitorA ! HeartbeatTick expectMsg(Heartbeat) monitorA.tell(heartbeatRspB, monitorB) - expectNoMessage(1 second) + expectNoMessage(1.second) monitorA ! HeartbeatTick expectMsg(Heartbeat) monitorA.tell(heartbeatRspB, monitorB) - within(10 seconds) { + within(10.seconds) { awaitAssert { monitorA ! HeartbeatTick expectMsg(Heartbeat) // but no HeartbeatRsp monitorA ! ReapUnreachableTick - p.expectMsg(1 second, TestRemoteWatcher.AddressTerm(b.path.address)) - q.expectMsg(1 second, TestRemoteWatcher.Quarantined(b.path.address, Some(remoteAddressUid))) + p.expectMsg(1.second, TestRemoteWatcher.AddressTerm(b.path.address)) + q.expectMsg(1.second, TestRemoteWatcher.Quarantined(b.path.address, Some(remoteAddressUid))) } } // make sure nothing floods over to next test - expectNoMessage(2 seconds) + expectNoMessage(2.seconds) } "generate AddressTerminated when missing first heartbeat" taggedAs LongRunningTest in { @@ -240,20 +239,20 @@ class RemoteWatcherSpec extends PekkoSpec(""" expectMsg(Heartbeat) // no HeartbeatRsp sent - within(20 seconds) { + within(20.seconds) { awaitAssert { monitorA ! HeartbeatTick expectMsg(Heartbeat) // but no HeartbeatRsp monitorA ! ReapUnreachableTick - p.expectMsg(1 second, TestRemoteWatcher.AddressTerm(b.path.address)) + p.expectMsg(1.second, TestRemoteWatcher.AddressTerm(b.path.address)) // no real quarantine when missing first heartbeat, uid unknown - q.expectMsg(1 second, TestRemoteWatcher.Quarantined(b.path.address, None)) + q.expectMsg(1.second, TestRemoteWatcher.Quarantined(b.path.address, None)) } } // make sure nothing floods over to next test - expectNoMessage(2 seconds) + expectNoMessage(2.seconds) } "generate AddressTerminated for new watch after broken connection that was re-established and broken again" taggedAs LongRunningTest in { @@ -273,19 +272,19 @@ class RemoteWatcherSpec extends PekkoSpec(""" monitorA ! HeartbeatTick expectMsg(Heartbeat) monitorA.tell(heartbeatRspB, monitorB) - expectNoMessage(1 second) + expectNoMessage(1.second) monitorA ! HeartbeatTick expectMsg(Heartbeat) monitorA.tell(heartbeatRspB, monitorB) - within(10 seconds) { + within(10.seconds) { awaitAssert { monitorA ! HeartbeatTick expectMsg(Heartbeat) // but no HeartbeatRsp monitorA ! ReapUnreachableTick - p.expectMsg(1 second, TestRemoteWatcher.AddressTerm(b.path.address)) - q.expectMsg(1 second, TestRemoteWatcher.Quarantined(b.path.address, Some(remoteAddressUid))) + p.expectMsg(1.second, TestRemoteWatcher.AddressTerm(b.path.address)) + q.expectMsg(1.second, TestRemoteWatcher.Quarantined(b.path.address, Some(remoteAddressUid))) } } @@ -295,7 +294,7 @@ class RemoteWatcherSpec extends PekkoSpec(""" monitorA ! Stats expectMsg(Stats.empty) } - expectNoMessage(2 seconds) + expectNoMessage(2.seconds) // assume that connection comes up again, or remote system is restarted val c = createRemoteActor(Props[MyActor](), "c6") @@ -305,37 +304,37 @@ class RemoteWatcherSpec extends PekkoSpec(""" monitorA ! HeartbeatTick expectMsg(Heartbeat) monitorA.tell(heartbeatRspB, monitorB) - expectNoMessage(1 second) + expectNoMessage(1.second) monitorA ! HeartbeatTick expectMsg(Heartbeat) monitorA.tell(heartbeatRspB, monitorB) monitorA ! HeartbeatTick expectMsg(Heartbeat) monitorA ! ReapUnreachableTick - p.expectNoMessage(1 second) + p.expectNoMessage(1.second) monitorA ! HeartbeatTick expectMsg(Heartbeat) monitorA.tell(heartbeatRspB, monitorB) monitorA ! HeartbeatTick expectMsg(Heartbeat) monitorA ! ReapUnreachableTick - p.expectNoMessage(1 second) - q.expectNoMessage(1 second) + p.expectNoMessage(1.second) + q.expectNoMessage(1.second) // then stop heartbeating again, should generate new AddressTerminated - within(10 seconds) { + within(10.seconds) { awaitAssert { monitorA ! HeartbeatTick expectMsg(Heartbeat) // but no HeartbeatRsp monitorA ! ReapUnreachableTick - p.expectMsg(1 second, TestRemoteWatcher.AddressTerm(c.path.address)) - q.expectMsg(1 second, TestRemoteWatcher.Quarantined(c.path.address, Some(remoteAddressUid))) + p.expectMsg(1.second, TestRemoteWatcher.AddressTerm(c.path.address)) + q.expectMsg(1.second, TestRemoteWatcher.Quarantined(c.path.address, Some(remoteAddressUid))) } } // make sure nothing floods over to next test - expectNoMessage(2 seconds) + expectNoMessage(2.seconds) } } diff --git a/slf4j/src/test/scala/org/apache/pekko/event/slf4j/Slf4jLoggerSpec.scala b/slf4j/src/test/scala/org/apache/pekko/event/slf4j/Slf4jLoggerSpec.scala index 612874a0b66..ecc699cce17 100644 --- a/slf4j/src/test/scala/org/apache/pekko/event/slf4j/Slf4jLoggerSpec.scala +++ b/slf4j/src/test/scala/org/apache/pekko/event/slf4j/Slf4jLoggerSpec.scala @@ -19,7 +19,6 @@ import java.nio.charset.StandardCharsets import scala.concurrent.duration._ import ch.qos.logback.core.OutputStreamAppender -import language.postfixOps import org.scalatest.BeforeAndAfterEach import org.slf4j.{ Marker, MarkerFactory } @@ -100,7 +99,7 @@ class Slf4jLoggerSpec extends PekkoSpec(Slf4jLoggerSpec.config) with BeforeAndAf "log error with stackTrace" in { producer ! new RuntimeException("Simulated error") - awaitCond(outputString.contains("----"), 5 seconds) + awaitCond(outputString.contains("----"), 5.seconds) val s = outputString s should include("pekkoSource=pekko://Slf4jLoggerSpec/user/logProducer") s should include("pekkoAddress=pekko://Slf4jLoggerSpec") @@ -116,7 +115,7 @@ class Slf4jLoggerSpec extends PekkoSpec(Slf4jLoggerSpec.config) with BeforeAndAf "log info with parameters" in { producer ! (("test x={} y={}", 3, 17)) - awaitCond(outputString.contains("----"), 5 seconds) + awaitCond(outputString.contains("----"), 5.seconds) val s = outputString s should include("pekkoSource=pekko://Slf4jLoggerSpec/user/logProducer") s should include("pekkoAddress=pekko://Slf4jLoggerSpec") @@ -129,7 +128,7 @@ class Slf4jLoggerSpec extends PekkoSpec(Slf4jLoggerSpec.config) with BeforeAndAf "log info with marker" in { producer ! StringWithMarker("security-wise interesting message", LogMarker("SECURITY")) - awaitCond(outputString.contains("----"), 5 seconds) + awaitCond(outputString.contains("----"), 5.seconds) val s = outputString s should include("marker=[SECURITY]") s should include("msg=[security-wise interesting message]") @@ -138,7 +137,7 @@ class Slf4jLoggerSpec extends PekkoSpec(Slf4jLoggerSpec.config) with BeforeAndAf "log info with marker and properties" in { producer ! StringWithMarker("interesting message", LogMarker("testMarker", Map("p1" -> 1, "p2" -> "B"))) - awaitCond(outputString.contains("----"), 5 seconds) + awaitCond(outputString.contains("----"), 5.seconds) val s = outputString s should include("marker=[testMarker]") s should include("p1=1") @@ -151,7 +150,7 @@ class Slf4jLoggerSpec extends PekkoSpec(Slf4jLoggerSpec.config) with BeforeAndAf slf4jMarker.add(MarkerFactory.getMarker("ADDED")) // slf4j markers can have children producer ! StringWithSlf4jMarker("security-wise interesting message", slf4jMarker) - awaitCond(outputString.contains("----"), 5 seconds) + awaitCond(outputString.contains("----"), 5.seconds) val s = outputString s should include("marker=[SLF [ ADDED ]]") s should include("msg=[security-wise interesting message]") @@ -164,7 +163,7 @@ class Slf4jLoggerSpec extends PekkoSpec(Slf4jLoggerSpec.config) with BeforeAndAf slf4jMarker, Map("ticketNumber" -> 3671, "ticketDesc" -> "Custom MDC Values")) - awaitCond(outputString.contains("----"), 5 seconds) + awaitCond(outputString.contains("----"), 5.seconds) val s = outputString s should include("marker=[SLF [ ADDED ]]") s should include("ticketDesc=Custom MDC Values") @@ -176,7 +175,7 @@ class Slf4jLoggerSpec extends PekkoSpec(Slf4jLoggerSpec.config) with BeforeAndAf "Message with custom MDC values", Map("ticketNumber" -> 3671, "ticketDesc" -> "Custom MDC Values")) - awaitCond(outputString.contains("----"), 5 seconds) + awaitCond(outputString.contains("----"), 5.seconds) val s = outputString s should include("pekkoSource=pekko://Slf4jLoggerSpec/user/logProducer") s should include("level=[INFO]") @@ -189,7 +188,7 @@ class Slf4jLoggerSpec extends PekkoSpec(Slf4jLoggerSpec.config) with BeforeAndAf "support null marker" in { producer ! StringWithMarker("security-wise interesting message", null) - awaitCond(outputString.contains("----"), 5 seconds) + awaitCond(outputString.contains("----"), 5.seconds) val s = outputString s should include("msg=[security-wise interesting message]") } @@ -197,7 +196,7 @@ class Slf4jLoggerSpec extends PekkoSpec(Slf4jLoggerSpec.config) with BeforeAndAf "Support null values in custom MDC" in { producer ! StringWithMDC("Message with null custom MDC values", Map("ticketNumber" -> 3671, "ticketDesc" -> null)) - awaitCond(outputString.contains("----"), 5 seconds) + awaitCond(outputString.contains("----"), 5.seconds) val s = outputString s should include("pekkoSource=pekko://Slf4jLoggerSpec/user/logProducer") s should include("level=[INFO]") @@ -211,7 +210,7 @@ class Slf4jLoggerSpec extends PekkoSpec(Slf4jLoggerSpec.config) with BeforeAndAf "include system info in pekkoSource when creating Logging with system" in { val log = Logging(system, "org.apache.pekko.event.slf4j.Slf4jLoggerSpec.MyLogSource") log.info("test") - awaitCond(outputString.contains("----"), 5 seconds) + awaitCond(outputString.contains("----"), 5.seconds) val s = outputString s should include("pekkoSource=org.apache.pekko.event.slf4j.Slf4jLoggerSpec.MyLogSource(pekko://Slf4jLoggerSpec)") s should include("logger=[org.apache.pekko.event.slf4j.Slf4jLoggerSpec.MyLogSource(pekko://Slf4jLoggerSpec)]") @@ -220,7 +219,7 @@ class Slf4jLoggerSpec extends PekkoSpec(Slf4jLoggerSpec.config) with BeforeAndAf "not include system info in pekkoSource when creating Logging with system.eventStream" in { val log = Logging(system.eventStream, "org.apache.pekko.event.slf4j.Slf4jLoggerSpec.MyLogSource") log.info("test") - awaitCond(outputString.contains("----"), 5 seconds) + awaitCond(outputString.contains("----"), 5.seconds) val s = outputString s should include("pekkoSource=org.apache.pekko.event.slf4j.Slf4jLoggerSpec.MyLogSource") s should include("logger=[org.apache.pekko.event.slf4j.Slf4jLoggerSpec.MyLogSource]") @@ -229,7 +228,7 @@ class Slf4jLoggerSpec extends PekkoSpec(Slf4jLoggerSpec.config) with BeforeAndAf "use short class name and include system info in pekkoSource when creating Logging with system and class" in { val log = Logging(system, classOf[MyLogSource]) log.info("test") - awaitCond(outputString.contains("----"), 5 seconds) + awaitCond(outputString.contains("----"), 5.seconds) val s = outputString s should include("pekkoSource=Slf4jLoggerSpec$MyLogSource(pekko://Slf4jLoggerSpec)") s should include("logger=[org.apache.pekko.event.slf4j.Slf4jLoggerSpec$MyLogSource]") @@ -238,7 +237,7 @@ class Slf4jLoggerSpec extends PekkoSpec(Slf4jLoggerSpec.config) with BeforeAndAf "use short class name in pekkoSource when creating Logging with system.eventStream and class" in { val log = Logging(system.eventStream, classOf[MyLogSource]) log.info("test") - awaitCond(outputString.contains("----"), 5 seconds) + awaitCond(outputString.contains("----"), 5.seconds) val s = outputString s should include("pekkoSource=Slf4jLoggerSpec$MyLogSource") s should include("logger=[org.apache.pekko.event.slf4j.Slf4jLoggerSpec$MyLogSource]") @@ -247,7 +246,7 @@ class Slf4jLoggerSpec extends PekkoSpec(Slf4jLoggerSpec.config) with BeforeAndAf "include actorSystem name in sourceActorSystem" in { val log = Logging(system.eventStream, classOf[MyLogSource]) log.info("test") - awaitCond(outputString.contains("----"), 5 seconds) + awaitCond(outputString.contains("----"), 5.seconds) val s = outputString s should include("sourceActorSystem=Slf4jLoggerSpec") } diff --git a/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/GraphZipLatestSpec.scala b/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/GraphZipLatestSpec.scala index fdea832c4ec..13ada514766 100644 --- a/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/GraphZipLatestSpec.scala +++ b/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/GraphZipLatestSpec.scala @@ -14,7 +14,6 @@ package org.apache.pekko.stream.scaladsl import scala.concurrent.duration._ -import scala.language.postfixOps import org.scalacheck.Gen import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks @@ -48,7 +47,7 @@ class GraphZipLatestSpec extends StreamSpec with ScalaCheckPropertyChecks with S bools.sendNext(true) // does not emit yet - probe.expectNoMessage(0 seconds) + probe.expectNoMessage(0.seconds) // an element pushed on the other source ints.sendNext(1) @@ -94,7 +93,7 @@ class GraphZipLatestSpec extends StreamSpec with ScalaCheckPropertyChecks with S // another request does not emit a duplicate probe.request(1) - probe.expectNoMessage(0 seconds) + probe.expectNoMessage(0.seconds) bools.sendComplete() probe.expectComplete() @@ -116,7 +115,7 @@ class GraphZipLatestSpec extends StreamSpec with ScalaCheckPropertyChecks with S // another request does not emit a duplicate probe.request(1) - probe.expectNoMessage(0 seconds) + probe.expectNoMessage(0.seconds) as.sendComplete() probe.expectComplete() diff --git a/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/GraphZipLatestWithSpec.scala b/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/GraphZipLatestWithSpec.scala index 6468d9f43ea..3fad74ae1f5 100644 --- a/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/GraphZipLatestWithSpec.scala +++ b/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/GraphZipLatestWithSpec.scala @@ -14,7 +14,6 @@ package org.apache.pekko.stream.scaladsl import scala.concurrent.duration._ -import scala.language.postfixOps import org.apache.pekko import pekko.stream._ @@ -57,7 +56,7 @@ class GraphZipLatestWithSpec extends TwoStreamsSetup { RunnableGraph .fromGraph(GraphDSL.create() { implicit b => val zipLatest = b.add(ZipLatestWith((_: Int) + (_: Int))) - val never = Source.single(3).initialDelay(1 day) + val never = Source.single(3).initialDelay(1.day) Source(1 to 2).concat(never) ~> zipLatest.in0 Source.fromPublisher(upstreamProbe) ~> zipLatest.in1 zipLatest.out ~> Sink.fromSubscriber(downstreamProbe) @@ -92,7 +91,7 @@ class GraphZipLatestWithSpec extends TwoStreamsSetup { RunnableGraph .fromGraph(GraphDSL.create() { implicit b => val zip = b.add(ZipLatestWith[Int, Int, Int]((_: Int) / (_: Int))) - val never = Source.single(2).initialDelay(1 day) + val never = Source.single(2).initialDelay(1.day) Source.single(1).concat(never) ~> zip.in0 Source(-2 to 2) ~> zip.in1 diff --git a/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/SinkForeachAsyncSpec.scala b/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/SinkForeachAsyncSpec.scala index dcb2e62b822..64df36cc8cd 100644 --- a/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/SinkForeachAsyncSpec.scala +++ b/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/SinkForeachAsyncSpec.scala @@ -21,7 +21,6 @@ import scala.concurrent.Await import scala.concurrent.ExecutionContext import scala.concurrent.Future import scala.concurrent.duration._ -import scala.language.postfixOps import scala.util.control.NoStackTrace import org.apache.pekko @@ -121,7 +120,7 @@ class SinkForeachAsyncSpec extends StreamSpec { assert(!threeCalled) assert(!fourCalled) - probe.expectNoMessage(2 seconds) + probe.expectNoMessage(2.seconds) latch(2).countDown() probe.expectMsg(2) @@ -129,14 +128,14 @@ class SinkForeachAsyncSpec extends StreamSpec { assert(!threeCalled) assert(!fourCalled) - probe.expectNoMessage(2 seconds) + probe.expectNoMessage(2.seconds) latch(3).countDown() probe.expectMsg(3) assert(!fourCalled) - probe.expectNoMessage(2 seconds) + probe.expectNoMessage(2.seconds) latch(4).countDown() probe.expectMsg(4) diff --git a/stream-typed-tests/src/test/scala/org/apache/pekko/stream/MapAsyncPartitionedSpec.scala b/stream-typed-tests/src/test/scala/org/apache/pekko/stream/MapAsyncPartitionedSpec.scala index 0b5a01a20ba..46800577765 100644 --- a/stream-typed-tests/src/test/scala/org/apache/pekko/stream/MapAsyncPartitionedSpec.scala +++ b/stream-typed-tests/src/test/scala/org/apache/pekko/stream/MapAsyncPartitionedSpec.scala @@ -32,7 +32,6 @@ import java.util.concurrent.Executors import scala.annotation.nowarn import scala.concurrent.duration.{ DurationInt, FiniteDuration } import scala.concurrent.{ blocking, ExecutionContext, Future } -import scala.language.postfixOps import scala.util.Random private object MapAsyncPartitionedSpec { @@ -93,8 +92,8 @@ class MapAsyncPartitionedSpec import MapAsyncPartitionedSpec.TestData._ override implicit def patienceConfig: PatienceConfig = PatienceConfig( - timeout = 5 seconds, - interval = 100 millis) + timeout = 5.seconds, + interval = 100.millis) private implicit val system: ActorSystem[_] = ActorSystem(Behaviors.empty, "test-system") private implicit val ec: ExecutionContext = ExecutionContext.fromExecutor(Executors.newCachedThreadPool()) @@ -116,11 +115,11 @@ class MapAsyncPartitionedSpec it should "process elements in parallel by partition" in { val elements = List( - TestKeyValue(key = 1, delay = 1000 millis, value = "1.a"), - TestKeyValue(key = 2, delay = 700 millis, value = "2.a"), - TestKeyValue(key = 1, delay = 500 millis, value = "1.b"), - TestKeyValue(key = 2, delay = 900 millis, value = "2.b"), - TestKeyValue(key = 1, delay = 500 millis, value = "1.c")) + TestKeyValue(key = 1, delay = 1000.millis, value = "1.a"), + TestKeyValue(key = 2, delay = 700.millis, value = "2.a"), + TestKeyValue(key = 1, delay = 500.millis, value = "1.b"), + TestKeyValue(key = 2, delay = 900.millis, value = "2.b"), + TestKeyValue(key = 1, delay = 500.millis, value = "1.c")) val result = Source(elements) @@ -222,9 +221,9 @@ class MapAsyncPartitionedSpec it should "handle nulls" in { val elements = List( - TestKeyValue(key = 1, delay = 1000 millis, value = "1.a"), - TestKeyValue(key = 2, delay = 700 millis, value = "2.a"), - TestKeyValue(key = 1, delay = 500 millis, value = null)) + TestKeyValue(key = 1, delay = 1000.millis, value = "1.a"), + TestKeyValue(key = 2, delay = 700.millis, value = "2.a"), + TestKeyValue(key = 1, delay = 500.millis, value = null)) @nowarn("msg=never used") def fun(v: TestKeyValue, p: Int): Future[String] = Future.successful(v.value) @@ -254,11 +253,11 @@ class MapAsyncPartitionedSpec it should "process elements in parallel by partition" in { val elements = List( - TestKeyValue(key = 1, delay = 1000 millis, value = "1.a"), - TestKeyValue(key = 2, delay = 700 millis, value = "2.a"), - TestKeyValue(key = 1, delay = 500 millis, value = "1.b"), - TestKeyValue(key = 1, delay = 500 millis, value = "1.c"), - TestKeyValue(key = 2, delay = 900 millis, value = "2.b")) + TestKeyValue(key = 1, delay = 1000.millis, value = "1.a"), + TestKeyValue(key = 2, delay = 700.millis, value = "2.a"), + TestKeyValue(key = 1, delay = 500.millis, value = "1.b"), + TestKeyValue(key = 1, delay = 500.millis, value = "1.c"), + TestKeyValue(key = 2, delay = 900.millis, value = "2.b")) def processElement(e: TestKeyValue, p: Int)(implicit ec: ExecutionContext): Future[(Int, (String, Instant))] = Future { @@ -374,9 +373,9 @@ class MapAsyncPartitionedSpec it should "handle nulls" in { val elements = List( - TestKeyValue(key = 1, delay = 1000 millis, value = "1.a"), - TestKeyValue(key = 2, delay = 700 millis, value = "2.a"), - TestKeyValue(key = 1, delay = 500 millis, value = null)) + TestKeyValue(key = 1, delay = 1000.millis, value = "1.a"), + TestKeyValue(key = 2, delay = 700.millis, value = "2.a"), + TestKeyValue(key = 1, delay = 500.millis, value = null)) @nowarn("msg=never used") def fun(v: TestKeyValue, p: Int): Future[String] = Future.successful(v.value) diff --git a/stream/src/main/scala/org/apache/pekko/stream/javadsl/Flow.scala b/stream/src/main/scala/org/apache/pekko/stream/javadsl/Flow.scala index 1eb248c0c0e..d8b6d2f813b 100755 --- a/stream/src/main/scala/org/apache/pekko/stream/javadsl/Flow.scala +++ b/stream/src/main/scala/org/apache/pekko/stream/javadsl/Flow.scala @@ -93,7 +93,8 @@ object Flow { viaFlow: Flow[FOut, FViaOut, FViaMat], combine: function.Function2[FMat, FViaMat, Mat] ): Flow[FIn, Optional[FViaOut], Mat] = - scaladsl.Flow.optionalVia(flow.map(_.toScala).asScala, viaFlow.asScala)(combinerToScala(combine)).map(_.toJava).asJava + scaladsl.Flow.optionalVia(flow.map(_.toScala).asScala, viaFlow.asScala)(combinerToScala(combine)).map( + _.toJava).asJava /** Create a `Flow` which can process elements of type `T`. */ def of[T](@unused clazz: Class[T]): javadsl.Flow[T, T, NotUsed] = create[T]() diff --git a/stream/src/main/scala/org/apache/pekko/stream/javadsl/Source.scala b/stream/src/main/scala/org/apache/pekko/stream/javadsl/Source.scala index 7ad5bd0df73..5241f8b7c20 100755 --- a/stream/src/main/scala/org/apache/pekko/stream/javadsl/Source.scala +++ b/stream/src/main/scala/org/apache/pekko/stream/javadsl/Source.scala @@ -161,7 +161,8 @@ object Source { viaFlow: Flow[SOut, FOut, FMat], combine: function.Function2[SMat, FMat, Mat] ): Source[Optional[FOut], Mat] = - scaladsl.Source.optionalVia(source.map(_.toScala).asScala, viaFlow.asScala)(combinerToScala(combine)).map(_.toJava).asJava + scaladsl.Source.optionalVia(source.map(_.toScala).asScala, viaFlow.asScala)(combinerToScala(combine)).map( + _.toJava).asJava /** * Helper to create [[Source]] from `Iterable`. diff --git a/testkit/src/main/scala/org/apache/pekko/testkit/CallingThreadDispatcher.scala b/testkit/src/main/scala/org/apache/pekko/testkit/CallingThreadDispatcher.scala index 291969ff52e..272670a64cd 100644 --- a/testkit/src/main/scala/org/apache/pekko/testkit/CallingThreadDispatcher.scala +++ b/testkit/src/main/scala/org/apache/pekko/testkit/CallingThreadDispatcher.scala @@ -23,7 +23,6 @@ import scala.concurrent.duration.Duration import scala.util.control.NonFatal import com.typesafe.config.Config -import language.postfixOps import org.apache.pekko import pekko.actor.{ @@ -179,7 +178,7 @@ class CallingThreadDispatcher(_configurator: MessageDispatcherConfigurator) exte hasMessageHint: Boolean, hasSystemMessageHint: Boolean): Boolean = false - protected[pekko] override def shutdownTimeout = 1 second + protected[pekko] override def shutdownTimeout = 1.second protected[pekko] override def register(actor: ActorCell): Unit = { super.register(actor) diff --git a/testkit/src/main/scala/org/apache/pekko/testkit/TestKit.scala b/testkit/src/main/scala/org/apache/pekko/testkit/TestKit.scala index 1b43f585011..5c04c40a5ac 100644 --- a/testkit/src/main/scala/org/apache/pekko/testkit/TestKit.scala +++ b/testkit/src/main/scala/org/apache/pekko/testkit/TestKit.scala @@ -21,7 +21,6 @@ import scala.annotation.tailrec import scala.collection.immutable import scala.concurrent.Await import scala.concurrent.duration._ -import scala.language.postfixOps import scala.reflect.ClassTag import scala.util.control.NonFatal @@ -441,7 +440,7 @@ trait TestKitBase { /** * Same as calling `within(0 seconds, max)(f)`. */ - def within[T](max: FiniteDuration)(f: => T): T = within(0 seconds, max)(f) + def within[T](max: FiniteDuration)(f: => T): T = within(0.seconds, max)(f) /** * Same as `expectMsg(remainingOrDefault, obj)`, but correctly treating the timeFactor. diff --git a/testkit/src/test/scala/org/apache/pekko/testkit/PekkoSpec.scala b/testkit/src/test/scala/org/apache/pekko/testkit/PekkoSpec.scala index 807b2f556fd..70263b213e0 100644 --- a/testkit/src/test/scala/org/apache/pekko/testkit/PekkoSpec.scala +++ b/testkit/src/test/scala/org/apache/pekko/testkit/PekkoSpec.scala @@ -15,7 +15,6 @@ package org.apache.pekko.testkit import scala.concurrent.Future import scala.concurrent.duration._ -import scala.language.postfixOps import com.typesafe.config.Config import com.typesafe.config.ConfigFactory import org.scalactic.CanEqual @@ -126,7 +125,7 @@ abstract class PekkoSpec(_system: ActorSystem) def spawn(dispatcherId: String = Dispatchers.DefaultDispatcherId)(body: => Unit): Unit = Future(body)(system.dispatchers.lookup(dispatcherId)) - override def expectedTestDuration: FiniteDuration = 60 seconds + override def expectedTestDuration: FiniteDuration = 60.seconds def muteDeadLetters(messageClasses: Class[_]*)(sys: ActorSystem = system): Unit = if (!sys.log.isDebugEnabled) { diff --git a/testkit/src/test/scala/org/apache/pekko/testkit/PekkoSpecSpec.scala b/testkit/src/test/scala/org/apache/pekko/testkit/PekkoSpecSpec.scala index 93442cc279b..38820635e16 100644 --- a/testkit/src/test/scala/org/apache/pekko/testkit/PekkoSpecSpec.scala +++ b/testkit/src/test/scala/org/apache/pekko/testkit/PekkoSpecSpec.scala @@ -18,7 +18,6 @@ import scala.concurrent.duration._ import scala.annotation.nowarn import com.typesafe.config.ConfigFactory -import language.postfixOps import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec @@ -59,7 +58,7 @@ class PekkoSpecSpec extends AnyWordSpec with Matchers { val spec = new PekkoSpec(localSystem) { refs = Seq(testActor, localSystem.actorOf(Props.empty, "name")) } refs.foreach(_.isTerminated should not be true) TestKit.shutdownActorSystem(localSystem) - spec.awaitCond(refs.forall(_.isTerminated), 2 seconds) + spec.awaitCond(refs.forall(_.isTerminated), 2.seconds) } "stop correctly when sending PoisonPill to rootGuardian" in { @@ -70,7 +69,7 @@ class PekkoSpecSpec extends AnyWordSpec with Matchers { system.actorSelection("/") ! PoisonPill - Await.ready(latch, 2 seconds) + Await.ready(latch, 2.seconds) } "enqueue unread messages from testActor to deadLetters" in { @@ -95,14 +94,14 @@ class PekkoSpecSpec extends AnyWordSpec with Matchers { * may happen that the system.stop() suspends the testActor before it had * a chance to put the message into its private queue */ - probe.receiveWhile(1 second) { + probe.receiveWhile(1.second) { case null => } val latch = new TestLatch(1)(system) system.registerOnTermination(latch.countDown()) TestKit.shutdownActorSystem(system) - Await.ready(latch, 2 seconds) + Await.ready(latch, 2.seconds) Await.result(davyJones ? "Die!", timeout.duration) should ===("finally gone") // this will typically also contain log messages which were sent after the logger shutdown diff --git a/testkit/src/test/scala/org/apache/pekko/testkit/TestActorRefSpec.scala b/testkit/src/test/scala/org/apache/pekko/testkit/TestActorRefSpec.scala index 004dc16f46a..d69615bb3e0 100644 --- a/testkit/src/test/scala/org/apache/pekko/testkit/TestActorRefSpec.scala +++ b/testkit/src/test/scala/org/apache/pekko/testkit/TestActorRefSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.testkit import scala.concurrent.{ Await, Promise } import scala.concurrent.duration._ -import language.postfixOps import org.scalatest.BeforeAndAfterEach import org.apache.pekko @@ -190,7 +189,7 @@ class TestActorRefSpec extends PekkoSpec("disp1.type=Dispatcher") with BeforeAnd } })) a.!(PoisonPill)(testActor) - expectMsgPF(5 seconds) { + expectMsgPF(5.seconds) { case WrappedTerminated(Terminated(`a`)) => true } a.isTerminated should ===(true) @@ -210,7 +209,7 @@ class TestActorRefSpec extends PekkoSpec("disp1.type=Dispatcher") with BeforeAnd }), self, "child") override def supervisorStrategy = - OneForOneStrategy(maxNrOfRetries = 5, withinTimeRange = 1 second)(List(classOf[ActorKilledException])) + OneForOneStrategy(maxNrOfRetries = 5, withinTimeRange = 1.second)(List(classOf[ActorKilledException])) def receiveT = { case "sendKill" => ref ! Kill } })) diff --git a/testkit/src/test/scala/org/apache/pekko/testkit/TestFSMRefSpec.scala b/testkit/src/test/scala/org/apache/pekko/testkit/TestFSMRefSpec.scala index ca1aaef7db3..00292062b10 100644 --- a/testkit/src/test/scala/org/apache/pekko/testkit/TestFSMRefSpec.scala +++ b/testkit/src/test/scala/org/apache/pekko/testkit/TestFSMRefSpec.scala @@ -15,8 +15,6 @@ package org.apache.pekko.testkit import scala.concurrent.duration._ -import language.postfixOps - import org.apache.pekko.actor._ class TestFSMRefSpec extends PekkoSpec { @@ -45,8 +43,8 @@ class TestFSMRefSpec extends PekkoSpec { fsm.setState(stateData = "buh") fsm.stateName should ===(1) fsm.stateData should ===("buh") - fsm.setState(timeout = 100 millis) - within(80 millis, 500 millis) { + fsm.setState(timeout = 100.millis) + within(80.millis, 500.millis) { awaitCond(fsm.stateName == 2 && fsm.stateData == "timeout") } } @@ -59,7 +57,7 @@ class TestFSMRefSpec extends PekkoSpec { } }, "test-fsm-ref-2") fsm.isTimerActive("test") should ===(false) - fsm.startTimerWithFixedDelay("test", 12, 10 millis) + fsm.startTimerWithFixedDelay("test", 12, 10.millis) fsm.isTimerActive("test") should ===(true) fsm.cancelTimer("test") fsm.isTimerActive("test") should ===(false) diff --git a/testkit/src/test/scala/org/apache/pekko/testkit/TestProbeSpec.scala b/testkit/src/test/scala/org/apache/pekko/testkit/TestProbeSpec.scala index 7872c3483e3..6ad662f40fb 100644 --- a/testkit/src/test/scala/org/apache/pekko/testkit/TestProbeSpec.scala +++ b/testkit/src/test/scala/org/apache/pekko/testkit/TestProbeSpec.scala @@ -19,7 +19,6 @@ import scala.concurrent.Await import scala.concurrent.duration._ import scala.util.Try -import language.postfixOps import org.scalatest.concurrent.Eventually import org.apache.pekko @@ -33,7 +32,7 @@ class TestProbeSpec extends PekkoSpec with DefaultTimeout with Eventually { "reply to futures" in { val tk = TestProbe() val future = tk.ref ? "hello" - tk.expectMsg(0 millis, "hello") // TestActor runs on CallingThreadDispatcher + tk.expectMsg(0.millis, "hello") // TestActor runs on CallingThreadDispatcher tk.lastMessage.sender ! "world" future.isCompleted should be(true) Await.result(future, timeout.duration) should ===("world") @@ -43,18 +42,18 @@ class TestProbeSpec extends PekkoSpec with DefaultTimeout with Eventually { val tk1 = TestProbe() val tk2 = TestProbe() tk1.ref.!("hello")(tk2.ref) - tk1.expectMsg(0 millis, "hello") + tk1.expectMsg(0.millis, "hello") tk1.lastMessage.sender ! "world" - tk2.expectMsg(0 millis, "world") + tk2.expectMsg(0.millis, "world") } "properly send and reply to messages" in { val probe1 = TestProbe() val probe2 = TestProbe() probe1.send(probe2.ref, "hello") - probe2.expectMsg(0 millis, "hello") + probe2.expectMsg(0.millis, "hello") probe2.lastMessage.sender ! "world" - probe1.expectMsg(0 millis, "some hint here", "world") + probe1.expectMsg(0.millis, "some hint here", "world") } "create a child when invoking actorOf" in { @@ -110,7 +109,7 @@ class TestProbeSpec extends PekkoSpec with DefaultTimeout with Eventually { val hint = "some hint" assertFailureMessageContains(hint) { - probe.expectMsg(0 millis, hint, "hello") + probe.expectMsg(0.millis, hint, "hello") } } @@ -120,7 +119,7 @@ class TestProbeSpec extends PekkoSpec with DefaultTimeout with Eventually { assertFailureMessageContains(hint) { probe.ref ! "hello" - probe.expectMsg(0 millis, hint, "bye") + probe.expectMsg(0.millis, hint, "bye") } } @@ -155,9 +154,9 @@ class TestProbeSpec extends PekkoSpec with DefaultTimeout with Eventually { expectMsgAnyClassOf(classOf[Int]) should ===(42) expectMsgAllClassOf(classOf[Int]) should ===(Seq(42)) expectMsgAllConformingOf(classOf[Int]) should ===(Seq(42)) - expectMsgAllConformingOf(5 seconds, classOf[Int]) should ===(Seq(42)) + expectMsgAllConformingOf(5.seconds, classOf[Int]) should ===(Seq(42)) expectMsgAllClassOf(classOf[Int]) should ===(Seq(42)) - expectMsgAllClassOf(5 seconds, classOf[Int]) should ===(Seq(42)) + expectMsgAllClassOf(5.seconds, classOf[Int]) should ===(Seq(42)) } "be able to fish for messages" in { @@ -172,7 +171,7 @@ class TestProbeSpec extends PekkoSpec with DefaultTimeout with Eventually { case _ => false } - probe.expectMsg(1 second, "done") + probe.expectMsg(1.second, "done") } "be able to fish for specific messages" in { @@ -188,7 +187,7 @@ class TestProbeSpec extends PekkoSpec with DefaultTimeout with Eventually { msg should be("fishForMe") - probe.expectMsg(1 second, "done") + probe.expectMsg(1.second, "done") } "be able to ignore primitive types" in {