From e6bcbdeabd1a83932f32d07266a8044951f3a57f Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Mon, 30 Sep 2024 23:26:38 +0100 Subject: [PATCH 1/6] replace more uses of Util.immutableSeq --- actor/src/main/scala/org/apache/pekko/actor/ActorPath.scala | 4 ++-- .../src/main/scala/org/apache/pekko/actor/ActorSystem.scala | 5 +++-- .../org/apache/pekko/cluster/client/ClusterClient.scala | 3 +-- .../scala/org/apache/pekko/cluster/ClusterSettings.scala | 6 +++--- .../main/scala/org/apache/pekko/remote/RemoteDeployer.scala | 4 ++-- .../main/scala/org/apache/pekko/remote/RemoteSettings.scala | 4 ++-- .../pekko/remote/artery/tcp/ssl/SSLEngineConfig.scala | 4 ++-- .../apache/pekko/remote/routing/RemoteRouterConfig.scala | 6 +++--- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/actor/src/main/scala/org/apache/pekko/actor/ActorPath.scala b/actor/src/main/scala/org/apache/pekko/actor/ActorPath.scala index 71f0b09b083..dac7974ee29 100644 --- a/actor/src/main/scala/org/apache/pekko/actor/ActorPath.scala +++ b/actor/src/main/scala/org/apache/pekko/actor/ActorPath.scala @@ -21,7 +21,7 @@ import scala.collection.immutable import scala.annotation.nowarn import org.apache.pekko -import pekko.japi.Util.immutableSeq +import pekko.util.ccompat.JavaConverters._ /** * Java API @@ -206,7 +206,7 @@ sealed trait ActorPath extends Comparable[ActorPath] with Serializable { /** * Java API: Recursively create a descendant’s path by appending all child names. */ - def descendant(names: java.lang.Iterable[String]): ActorPath = /(immutableSeq(names)) + def descendant(names: java.lang.Iterable[String]): ActorPath = /(names.asScala) /** * Sequence of names for this path from root to this. Performance implication: has to allocate a list. diff --git a/actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala b/actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala index e7b9f6aa676..42183921236 100644 --- a/actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala +++ b/actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala @@ -43,6 +43,7 @@ import pekko.util._ import pekko.util.FutureConverters._ import pekko.util.OptionConverters._ import pekko.util.Helpers.toRootLowerCase +import pekko.util.ccompat.JavaConverters._ object BootstrapSetup { @@ -564,7 +565,7 @@ abstract class ActorSystem extends ActorRefFactory with ClassicActorSystemProvid /** * Java API: Recursively create a descendant’s path by appending all child names. */ - def descendant(names: java.lang.Iterable[String]): ActorPath = /(immutableSeq(names)) + def descendant(names: java.lang.Iterable[String]): ActorPath = /(names.asScala) /** * Start-up time in milliseconds since the epoch. @@ -1210,7 +1211,7 @@ private[pekko] class ActorSystemImpl( */ def loadExtensions(key: String, throwOnLoadFail: Boolean): Unit = { - immutableSeq(settings.config.getStringList(key)).foreach { fqcn => + settings.config.getStringList(key).asScala.foreach { fqcn => dynamicAccess.getObjectFor[AnyRef](fqcn).recoverWith { case firstProblem => dynamicAccess.createInstanceFor[AnyRef](fqcn, Nil).recoverWith { case _ => Failure(firstProblem) } diff --git a/cluster-tools/src/main/scala/org/apache/pekko/cluster/client/ClusterClient.scala b/cluster-tools/src/main/scala/org/apache/pekko/cluster/client/ClusterClient.scala index bd7cfe71f49..670d7264e93 100644 --- a/cluster-tools/src/main/scala/org/apache/pekko/cluster/client/ClusterClient.scala +++ b/cluster-tools/src/main/scala/org/apache/pekko/cluster/client/ClusterClient.scala @@ -47,7 +47,6 @@ import pekko.cluster.ClusterEvent._ import pekko.cluster.Member import pekko.cluster.MemberStatus import pekko.cluster.pubsub._ -import pekko.japi.Util.immutableSeq import pekko.remote.DeadlineFailureDetector import pekko.routing.ConsistentHash import pekko.routing.MurmurHash @@ -72,7 +71,7 @@ object ClusterClientSettings { * the default configuration `pekko.cluster.client`. */ def apply(config: Config): ClusterClientSettings = { - val initialContacts = immutableSeq(config.getStringList("initial-contacts")).map(ActorPath.fromString).toSet + val initialContacts = config.getStringList("initial-contacts").asScala.map(ActorPath.fromString).toSet new ClusterClientSettings( initialContacts, establishingGetContactsInterval = config.getDuration("establishing-get-contacts-interval", MILLISECONDS).millis, diff --git a/cluster/src/main/scala/org/apache/pekko/cluster/ClusterSettings.scala b/cluster/src/main/scala/org/apache/pekko/cluster/ClusterSettings.scala index 2056d00f869..da0db6a54c5 100644 --- a/cluster/src/main/scala/org/apache/pekko/cluster/ClusterSettings.scala +++ b/cluster/src/main/scala/org/apache/pekko/cluster/ClusterSettings.scala @@ -23,9 +23,9 @@ import org.apache.pekko import pekko.actor.Address import pekko.actor.AddressFromURIString import pekko.annotation.InternalApi -import pekko.japi.Util.immutableSeq import pekko.util.Helpers.{ toRootLowerCase, ConfigOps, Requiring } import pekko.util.Version +import pekko.util.ccompat.JavaConverters._ object ClusterSettings { type DataCenter = String @@ -87,7 +87,7 @@ final class ClusterSettings(val config: Config, val systemName: String) { } val SeedNodes: immutable.IndexedSeq[Address] = - immutableSeq(cc.getStringList("seed-nodes")).map { + cc.getStringList("seed-nodes").asScala.map { case AddressFromURIString(address) => address case _ => throw new RuntimeException() // compiler exhaustiveness check pleaser }.toVector @@ -161,7 +161,7 @@ final class ClusterSettings(val config: Config, val systemName: String) { val SelfDataCenter: DataCenter = cc.getString("multi-data-center.self-data-center") val Roles: Set[String] = { - val configuredRoles = immutableSeq(cc.getStringList("roles")).toSet.requiring( + val configuredRoles = cc.getStringList("roles").asScala.toSet.requiring( _.forall(!_.startsWith(DcRolePrefix)), s"Roles must not start with '$DcRolePrefix' as that is reserved for the cluster self-data-center setting") diff --git a/remote/src/main/scala/org/apache/pekko/remote/RemoteDeployer.scala b/remote/src/main/scala/org/apache/pekko/remote/RemoteDeployer.scala index d23c44eeda4..e6729c2caf2 100644 --- a/remote/src/main/scala/org/apache/pekko/remote/RemoteDeployer.scala +++ b/remote/src/main/scala/org/apache/pekko/remote/RemoteDeployer.scala @@ -18,10 +18,10 @@ import com.typesafe.config._ import org.apache.pekko import pekko.ConfigurationException import pekko.actor._ -import pekko.japi.Util.immutableSeq import pekko.remote.routing.RemoteRouterConfig import pekko.routing._ import pekko.routing.Pool +import pekko.util.ccompat.JavaConverters._ @SerialVersionUID(1L) final case class RemoteScope(node: Address) extends Scope { @@ -41,7 +41,7 @@ private[pekko] class RemoteDeployer(_settings: ActorSystem.Settings, _pm: Dynami case AddressFromURIString(r) => Some(deploy.copy(scope = RemoteScope(r))) case str if !str.isEmpty => throw new ConfigurationException(s"unparseable remote node name [$str]") case _ => - val nodes = immutableSeq(deploy.config.getStringList("target.nodes")).map(AddressFromURIString(_)) + val nodes = deploy.config.getStringList("target.nodes").asScala.map(AddressFromURIString(_)) if (nodes.isEmpty || deploy.routerConfig == NoRouter) d else deploy.routerConfig match { diff --git a/remote/src/main/scala/org/apache/pekko/remote/RemoteSettings.scala b/remote/src/main/scala/org/apache/pekko/remote/RemoteSettings.scala index f106284ca56..95b03247ff1 100644 --- a/remote/src/main/scala/org/apache/pekko/remote/RemoteSettings.scala +++ b/remote/src/main/scala/org/apache/pekko/remote/RemoteSettings.scala @@ -62,7 +62,7 @@ final class RemoteSettings(val config: Config) { if (Artery.Enabled) Artery.UntrustedMode else UntrustedMode @deprecated("Classic remoting is deprecated, use Artery", "Akka 2.6.0") val TrustedSelectionPaths: Set[String] = - immutableSeq(getStringList("pekko.remote.classic.trusted-selection-paths")).toSet + getStringList("pekko.remote.classic.trusted-selection-paths").asScala.toSet @deprecated("Classic remoting is deprecated, use Artery", "Akka 2.6.0") val RemoteLifecycleEventsLogLevel: LogLevel = toRootLowerCase( @@ -211,7 +211,7 @@ final class RemoteSettings(val config: Config) { } val AcceptProtocolNames: Set[String] = { - val set = immutableSeq(getStringList("pekko.remote.accept-protocol-names")).toSet + val set = getStringList("pekko.remote.accept-protocol-names").asScala.toSet if (set.isEmpty) { throw new ConfigurationException("pekko.remote.accept-protocol-names setting must not be empty. " + "The setting is an array and the only acceptable values are \"pekko\" and \"akka\".") diff --git a/remote/src/main/scala/org/apache/pekko/remote/artery/tcp/ssl/SSLEngineConfig.scala b/remote/src/main/scala/org/apache/pekko/remote/artery/tcp/ssl/SSLEngineConfig.scala index 545e0ed1be1..cc9cc702116 100644 --- a/remote/src/main/scala/org/apache/pekko/remote/artery/tcp/ssl/SSLEngineConfig.scala +++ b/remote/src/main/scala/org/apache/pekko/remote/artery/tcp/ssl/SSLEngineConfig.scala @@ -15,7 +15,7 @@ package org.apache.pekko.remote.artery.tcp.ssl import org.apache.pekko import pekko.annotation.InternalApi -import pekko.japi.Util.immutableSeq +import pekko.util.ccompat.JavaConverters._ import com.typesafe.config.Config import scala.concurrent.duration.FiniteDuration @@ -30,7 +30,7 @@ private[tcp] class SSLEngineConfig(config: Config) { private[tcp] val SSLProtocol: String = config.getString("protocol") private[tcp] val SSLEnabledAlgorithms: Set[String] = - immutableSeq(config.getStringList("enabled-algorithms")).toSet + config.getStringList("enabled-algorithms").asScala.toSet private[tcp] val SSLRequireMutualAuthentication: Boolean = { if (config.hasPath("require-mutual-authentication")) config.getBoolean("require-mutual-authentication") diff --git a/remote/src/main/scala/org/apache/pekko/remote/routing/RemoteRouterConfig.scala b/remote/src/main/scala/org/apache/pekko/remote/routing/RemoteRouterConfig.scala index 19ebe2c3c90..ddbc53a0e89 100644 --- a/remote/src/main/scala/org/apache/pekko/remote/routing/RemoteRouterConfig.scala +++ b/remote/src/main/scala/org/apache/pekko/remote/routing/RemoteRouterConfig.scala @@ -26,7 +26,6 @@ import pekko.actor.Address import pekko.actor.Deploy import pekko.actor.Props import pekko.actor.SupervisorStrategy -import pekko.japi.Util.immutableSeq import pekko.remote.RemoteScope import pekko.routing.ActorRefRoutee import pekko.routing.Pool @@ -35,6 +34,7 @@ import pekko.routing.Routee import pekko.routing.Router import pekko.routing.RouterActor import pekko.routing.RouterConfig +import pekko.util.ccompat.JavaConverters._ /** * [[pekko.routing.RouterConfig]] implementation for remote deployment on defined @@ -47,8 +47,8 @@ final case class RemoteRouterConfig(local: Pool, nodes: Iterable[Address]) exten require(nodes.nonEmpty, "Must specify list of remote target.nodes") - def this(local: Pool, nodes: java.lang.Iterable[Address]) = this(local, immutableSeq(nodes)) - def this(local: Pool, nodes: Array[Address]) = this(local, nodes: Iterable[Address]) + def this(local: Pool, nodes: java.lang.Iterable[Address]) = this(local, nodes.asScala.toSeq) + def this(local: Pool, nodes: Array[Address]) = this(local, nodes.toSeq) // need this iterator as instance variable since Resizer may call createRoutees several times @nowarn @transient private val nodeAddressIter: Iterator[Address] = Stream.continually(nodes).flatten.iterator From 623fe68f9ffaadfa44dbda7759472c250acdc293 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Mon, 30 Sep 2024 23:42:01 +0100 Subject: [PATCH 2/6] Update ClusterClient.scala --- .../scala/org/apache/pekko/cluster/client/ClusterClient.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cluster-tools/src/main/scala/org/apache/pekko/cluster/client/ClusterClient.scala b/cluster-tools/src/main/scala/org/apache/pekko/cluster/client/ClusterClient.scala index 670d7264e93..2388c6d03a3 100644 --- a/cluster-tools/src/main/scala/org/apache/pekko/cluster/client/ClusterClient.scala +++ b/cluster-tools/src/main/scala/org/apache/pekko/cluster/client/ClusterClient.scala @@ -51,7 +51,8 @@ import pekko.remote.DeadlineFailureDetector import pekko.routing.ConsistentHash import pekko.routing.MurmurHash import pekko.util.MessageBuffer -import pekko.util.ccompat._ +import pekko.util.ccompat.ccompatUsedUntil213 +import pekko.util.ccompat.JavaConverters._ @ccompatUsedUntil213 @deprecated( From 469bdc7f0f94a4e92c464db4759de77bac4c891a Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Mon, 30 Sep 2024 23:54:52 +0100 Subject: [PATCH 3/6] more changes --- .../org/apache/pekko/remote/artery/ArterySettings.scala | 3 +-- .../pekko/remote/transport/netty/NettySSLSupport.scala | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/remote/src/main/scala/org/apache/pekko/remote/artery/ArterySettings.scala b/remote/src/main/scala/org/apache/pekko/remote/artery/ArterySettings.scala index d96b8ffff0a..85c54c74bcd 100644 --- a/remote/src/main/scala/org/apache/pekko/remote/artery/ArterySettings.scala +++ b/remote/src/main/scala/org/apache/pekko/remote/artery/ArterySettings.scala @@ -23,7 +23,6 @@ import com.typesafe.config.ConfigFactory import org.apache.pekko import pekko.NotUsed -import pekko.japi.Util.immutableSeq import pekko.stream.ActorMaterializerSettings import pekko.util.Helpers.ConfigOps import pekko.util.Helpers.Requiring @@ -79,7 +78,7 @@ private[pekko] final class ArterySettings private (config: Config) { val SSLEngineProviderClassName: String = config.getString("ssl.ssl-engine-provider") val UntrustedMode: Boolean = getBoolean("untrusted-mode") - val TrustedSelectionPaths: Set[String] = immutableSeq(getStringList("trusted-selection-paths")).toSet + val TrustedSelectionPaths: Set[String] = getStringList("trusted-selection-paths").asScala.toSet val LogReceive: Boolean = getBoolean("log-received-messages") val LogSend: Boolean = getBoolean("log-sent-messages") diff --git a/remote/src/main/scala/org/apache/pekko/remote/transport/netty/NettySSLSupport.scala b/remote/src/main/scala/org/apache/pekko/remote/transport/netty/NettySSLSupport.scala index 1d93406b5bd..92a4f9ae67e 100644 --- a/remote/src/main/scala/org/apache/pekko/remote/transport/netty/NettySSLSupport.scala +++ b/remote/src/main/scala/org/apache/pekko/remote/transport/netty/NettySSLSupport.scala @@ -17,8 +17,8 @@ import scala.annotation.nowarn import com.typesafe.config.Config import org.apache.pekko -import pekko.japi.Util._ -import pekko.util.ccompat._ +import pekko.util.ccompat.ccompatUsedUntil213 +import pekko.util.ccompat.JavaConverters._ import io.netty.channel.Channel import io.netty.handler.ssl.SslHandler @@ -40,7 +40,7 @@ private[pekko] class SSLSettings(config: Config) { val SSLTrustStorePassword = getString("trust-store-password") - val SSLEnabledAlgorithms = immutableSeq(getStringList("enabled-algorithms")).to(Set) + val SSLEnabledAlgorithms = getStringList("enabled-algorithms").asScala.to(Set) val SSLProtocol = getString("protocol") From 66e2cb79c86461956bec9dfa36fbb2bc01723ab5 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Tue, 1 Oct 2024 00:10:21 +0100 Subject: [PATCH 4/6] Update NettySSLSupport.scala --- .../apache/pekko/remote/transport/netty/NettySSLSupport.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote/src/main/scala/org/apache/pekko/remote/transport/netty/NettySSLSupport.scala b/remote/src/main/scala/org/apache/pekko/remote/transport/netty/NettySSLSupport.scala index 92a4f9ae67e..8551cddc5f3 100644 --- a/remote/src/main/scala/org/apache/pekko/remote/transport/netty/NettySSLSupport.scala +++ b/remote/src/main/scala/org/apache/pekko/remote/transport/netty/NettySSLSupport.scala @@ -40,7 +40,7 @@ private[pekko] class SSLSettings(config: Config) { val SSLTrustStorePassword = getString("trust-store-password") - val SSLEnabledAlgorithms = getStringList("enabled-algorithms").asScala.to(Set) + val SSLEnabledAlgorithms = getStringList("enabled-algorithms").asScala.toSet val SSLProtocol = getString("protocol") From 63b0f338a48fb928d2c4e77310831a62bf004477 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Tue, 1 Oct 2024 00:28:53 +0100 Subject: [PATCH 5/6] Update ClusterClient.scala --- .../scala/org/apache/pekko/cluster/client/ClusterClient.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cluster-tools/src/main/scala/org/apache/pekko/cluster/client/ClusterClient.scala b/cluster-tools/src/main/scala/org/apache/pekko/cluster/client/ClusterClient.scala index 2388c6d03a3..e859c4ee235 100644 --- a/cluster-tools/src/main/scala/org/apache/pekko/cluster/client/ClusterClient.scala +++ b/cluster-tools/src/main/scala/org/apache/pekko/cluster/client/ClusterClient.scala @@ -47,12 +47,12 @@ import pekko.cluster.ClusterEvent._ import pekko.cluster.Member import pekko.cluster.MemberStatus import pekko.cluster.pubsub._ +import pekko.japi.Util.immutableSeq import pekko.remote.DeadlineFailureDetector import pekko.routing.ConsistentHash import pekko.routing.MurmurHash import pekko.util.MessageBuffer import pekko.util.ccompat.ccompatUsedUntil213 -import pekko.util.ccompat.JavaConverters._ @ccompatUsedUntil213 @deprecated( @@ -72,7 +72,7 @@ object ClusterClientSettings { * the default configuration `pekko.cluster.client`. */ def apply(config: Config): ClusterClientSettings = { - val initialContacts = config.getStringList("initial-contacts").asScala.map(ActorPath.fromString).toSet + val initialContacts = immutableSeq(config.getStringList("initial-contacts")).map(ActorPath.fromString).toSet new ClusterClientSettings( initialContacts, establishingGetContactsInterval = config.getDuration("establishing-get-contacts-interval", MILLISECONDS).millis, From ca03745a2c1998efd5df9b4a433565706d17f7de Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Tue, 1 Oct 2024 00:53:06 +0100 Subject: [PATCH 6/6] Update ClusterClient.scala --- .../org/apache/pekko/cluster/client/ClusterClient.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cluster-tools/src/main/scala/org/apache/pekko/cluster/client/ClusterClient.scala b/cluster-tools/src/main/scala/org/apache/pekko/cluster/client/ClusterClient.scala index e859c4ee235..3ddea3dfb2d 100644 --- a/cluster-tools/src/main/scala/org/apache/pekko/cluster/client/ClusterClient.scala +++ b/cluster-tools/src/main/scala/org/apache/pekko/cluster/client/ClusterClient.scala @@ -47,12 +47,12 @@ import pekko.cluster.ClusterEvent._ import pekko.cluster.Member import pekko.cluster.MemberStatus import pekko.cluster.pubsub._ -import pekko.japi.Util.immutableSeq import pekko.remote.DeadlineFailureDetector import pekko.routing.ConsistentHash import pekko.routing.MurmurHash import pekko.util.MessageBuffer -import pekko.util.ccompat.ccompatUsedUntil213 +import pekko.util.ccompat._ +import pekko.util.ccompat.JavaConverters._ @ccompatUsedUntil213 @deprecated( @@ -72,7 +72,7 @@ object ClusterClientSettings { * the default configuration `pekko.cluster.client`. */ def apply(config: Config): ClusterClientSettings = { - val initialContacts = immutableSeq(config.getStringList("initial-contacts")).map(ActorPath.fromString).toSet + val initialContacts = config.getStringList("initial-contacts").asScala.map(ActorPath.fromString).toSet new ClusterClientSettings( initialContacts, establishingGetContactsInterval = config.getDuration("establishing-get-contacts-interval", MILLISECONDS).millis,