Skip to content

Commit

Permalink
replace more uses of Util.immutableSeq
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning committed Sep 30, 2024
1 parent 090390a commit e6bcbde
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions actor/src/main/scala/org/apache/pekko/actor/ActorPath.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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\".")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit e6bcbde

Please sign in to comment.