Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ object BehaviorTestKitSpec {
replyTo ! Done
Behaviors.same
case CreateMessageAdapter(messageClass, f, replyTo) =>
val adaptor = context.messageAdapter(f)(ClassTag(messageClass))
implicit val ct: ClassTag[Any] = ClassTag(messageClass)
val adaptor = context.messageAdapter[Any](f.asInstanceOf[Any => Command])
replyTo.foreach(_ ! adaptor.unsafeUpcast)
Behaviors.same
case Log(what) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import scala.concurrent.duration._
import scala.jdk.CollectionConverters._
import scala.util.Try
import scala.util.control.NonFatal

import com.github.dockerjava.api.DockerClient
import com.github.dockerjava.api.async.ResultCallback
import com.github.dockerjava.api.command.CreateContainerCmd
Expand All @@ -29,10 +30,11 @@ import com.github.dockerjava.httpclient5.ApacheDockerHttpClient
import org.apache.pekko
import pekko.actor.Props
import pekko.io.dns.internal.DnsClient
import pekko.testkit.PekkoSpec
import pekko.util.Timeout

import pekko.testkit.PekkoSpec
import org.scalatest.concurrent.Eventually

import com.typesafe.config.Config

abstract class DockerBindDnsService(config: Config) extends PekkoSpec(config) with Eventually {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package org.apache.pekko.util

import java.nio.ByteOrder

import org.scalatest.wordspec.AnyWordSpec
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec

class SWARUtilSpec extends AnyWordSpec with Matchers {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ abstract class ActorContextSpec extends ScalaTestWithActorTestKit with AnyWordSp
def decoration[T: ClassTag]: Behavior[T] => Behavior[T]

implicit class BehaviorDecorator[T](behavior: Behavior[T])(implicit ev: ClassTag[T]) {
def decorate: Behavior[T] = decoration[T](ev)(behavior)
def decorate: Behavior[T] = decoration[T].apply(behavior)
}

"An ActorContext" must {
Expand Down Expand Up @@ -661,7 +661,8 @@ abstract class ActorContextSpec extends ScalaTestWithActorTestKit with AnyWordSp

"not allow null messages" in {
// Scala 3 doesn't generate an implicit `ClassTag[Null]` (https://github.com/lampepfl/dotty/issues/9586)
val actor = spawn(decoration(ClassTag.Null)(Behaviors.empty[Null]))
@nowarn("msg=never used") implicit val ct: ClassTag[Null] = ClassTag.Null
val actor = spawn(decoration[Null].apply(Behaviors.empty[Null]))
intercept[InvalidMessageException] {
actor ! null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import pekko.annotation.InternalApi
@InternalApi private[receptionist] object Platform {
type Aux[P] = AbstractServiceKey { type Protocol = P }

type Service[K <: Aux[_]] = K match {
type Service[K <: Aux[?]] = K match {
case Aux[t] => ActorRef[t]
}

type Subscriber[K <: Aux[_]] = K match {
type Subscriber[K <: Aux[?]] = K match {
case Aux[t] => ActorRef[ReceptionistMessages.Listing[t]]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ class SuperviseBehavior[T] private[pekko] (
*
* Only exceptions of the given type (and their subclasses) will be handled by this supervision behavior.
*/
def onFailure[Thr <: Throwable](clazz: Class[Thr], strategy: SupervisorStrategy): SuperviseBehavior[T] =
onFailure(strategy)(ClassTag(clazz))
def onFailure[Thr <: Throwable](clazz: Class[Thr], strategy: SupervisorStrategy): SuperviseBehavior[T] = {
implicit val ct: ClassTag[Thr] = ClassTag(clazz)
onFailure(strategy)
}

private[pekko] def unwrap: Behavior[T] = wrapped
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ object ProducerController {
messageClass: Class[A],
producerId: String,
durableQueueBehavior: Optional[Behavior[DurableProducerQueue.Command[A]]]): Behavior[Command[A]] = {
apply(producerId, durableQueueBehavior.toScala)(ClassTag(messageClass))
implicit val ct: ClassTag[A] = ClassTag(messageClass)
apply(producerId, durableQueueBehavior.toScala)
}

/**
Expand All @@ -305,7 +306,8 @@ object ProducerController {
producerId: String,
durableQueueBehavior: Optional[Behavior[DurableProducerQueue.Command[A]]],
settings: Settings): Behavior[Command[A]] = {
apply(producerId, durableQueueBehavior.toScala, settings)(ClassTag(messageClass))
implicit val ct: ClassTag[A] = ClassTag(messageClass)
apply(producerId, durableQueueBehavior.toScala, settings)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ object WorkPullingProducerController {
producerId: String,
workerServiceKey: ServiceKey[ConsumerController.Command[A]],
durableQueueBehavior: Optional[Behavior[DurableProducerQueue.Command[A]]]): Behavior[Command[A]] = {
apply(producerId, workerServiceKey, durableQueueBehavior.toScala)(ClassTag(messageClass))
implicit val ct: ClassTag[A] = ClassTag(messageClass)
apply(producerId, workerServiceKey, durableQueueBehavior.toScala)
}

/**
Expand All @@ -253,6 +254,7 @@ object WorkPullingProducerController {
workerServiceKey: ServiceKey[ConsumerController.Command[A]],
durableQueueBehavior: Optional[Behavior[DurableProducerQueue.Command[A]]],
settings: Settings): Behavior[Command[A]] = {
apply(producerId, workerServiceKey, durableQueueBehavior.toScala, settings)(ClassTag(messageClass))
implicit val ct: ClassTag[A] = ClassTag(messageClass)
apply(producerId, workerServiceKey, durableQueueBehavior.toScala, settings)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ object EventStream {
/**
* Java API.
*/
def this(clazz: Class[E], subscriber: ActorRef[E]) = this(subscriber)(ClassTag(clazz))
def this(clazz: Class[E], subscriber: ActorRef[E]) =
this(subscriber)(ClassTag(clazz))

/**
* INTERNAL API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ import org.slf4j.LoggerFactory
timer
}

protected[this] def mkTimer(): TimerSchedulerCrossDslSupport[T] = new TimerSchedulerImpl[T](this)
protected def mkTimer(): TimerSchedulerCrossDslSupport[T] = new TimerSchedulerImpl[T](this)

override private[pekko] def hasTimer: Boolean = _timer.isDefined

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ import org.slf4j.event.Level
* INTERNAL API
*/
@InternalApi private[pekko] object Supervisor {
def apply[T, Thr <: Throwable: ClassTag](initialBehavior: Behavior[T], strategy: SupervisorStrategy): Behavior[T] = {
def apply[T, Thr <: Throwable](initialBehavior: Behavior[T], strategy: SupervisorStrategy)(
implicit ev: ClassTag[Thr]): Behavior[T] = {
if (initialBehavior.isInstanceOf[scaladsl.AbstractBehavior[?]] ||
initialBehavior
.isInstanceOf[javadsl.AbstractBehavior[?]]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ import pekko.japi.pf.PFBuilder
*/
object Behaviors {

private[this] val _two2same = new JapiFunction2[ActorContext[Any], Any, Behavior[Any]] {
private val _two2same = new JapiFunction2[ActorContext[Any], Any, Behavior[Any]] {
override def apply(context: ActorContext[Any], msg: Any): Behavior[Any] = same
}
private[this] def two2same[T] = _two2same.asInstanceOf[JapiFunction2[ActorContext[T], T, Behavior[T]]]
private def two2same[T] = _two2same.asInstanceOf[JapiFunction2[ActorContext[T], T, Behavior[T]]]

/**
* `setup` is a factory for a behavior. Creation of the behavior instance is deferred until
Expand Down Expand Up @@ -234,8 +234,10 @@ object Behaviors {
* @param monitor The messages will also be sent to this `ActorRef`
* @param behavior The inner behavior that is decorated
*/
def monitor[T](interceptMessageClass: Class[T], monitor: ActorRef[T], behavior: Behavior[T]): Behavior[T] =
scaladsl.Behaviors.monitor(monitor, behavior)(ClassTag(interceptMessageClass))
def monitor[T](interceptMessageClass: Class[T], monitor: ActorRef[T], behavior: Behavior[T]): Behavior[T] = {
implicit val ct: ClassTag[T] = ClassTag(interceptMessageClass)
scaladsl.Behaviors.monitor(monitor, behavior)
}

/**
* Behavior decorator that logs all messages to the [[pekko.actor.typed.Behavior]] using the provided
Expand Down Expand Up @@ -332,8 +334,10 @@ object Behaviors {
def transformMessages[Outer, Inner](
interceptMessageClass: Class[Outer],
behavior: Behavior[Inner],
selector: JFunction[PFBuilder[Outer, Inner], PFBuilder[Outer, Inner]]): Behavior[Outer] =
BehaviorImpl.transformMessages(behavior, selector.apply(new PFBuilder).build())(ClassTag(interceptMessageClass))
selector: JFunction[PFBuilder[Outer, Inner], PFBuilder[Outer, Inner]]): Behavior[Outer] = {
implicit val ct: ClassTag[Outer] = ClassTag(interceptMessageClass)
BehaviorImpl.transformMessages(behavior, selector.apply(new PFBuilder).build())
}

/**
* Support for scheduled `self` messages in an actor.
Expand Down Expand Up @@ -413,7 +417,8 @@ object Behaviors {
asScalaMap(mdcForMessage.apply(message))
}

WithMdcBehaviorInterceptor[T](asScalaMap(staticMdc), mdcForMessageFun, behavior)(ClassTag(interceptMessageClass))
implicit val ct: ClassTag[T] = ClassTag(interceptMessageClass)
WithMdcBehaviorInterceptor[T](asScalaMap(staticMdc), mdcForMessageFun, behavior)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ object Topic {
/**
* Java API: Create a topic actor behavior for the given topic name and message class
*/
def create[T](messageClass: Class[T], topicName: String): Behavior[Command[T]] =
apply[T](topicName)(ClassTag(messageClass))
def create[T](messageClass: Class[T], topicName: String): Behavior[Command[T]] = {
implicit val ct: ClassTag[T] = ClassTag(messageClass)
apply[T](topicName)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ object AskPattern {
// We do not currently use the implicit scheduler, but want to require it
// because it might be needed when we move to a 'native' typed runtime, see #24219
ref match {
case a: InternalRecipientRef[Req] => askClassic[Req, Res](a, timeout, replyTo)
case a =>
case a: (InternalRecipientRef[Req] @unchecked) => askClassic[Req, Res](a, timeout, replyTo)
case a =>
throw new IllegalStateException(
"Only expect references to be RecipientRef, ActorRefAdapter or ActorSystemAdapter until " +
"native system is implemented: " + a.getClass)
Expand All @@ -144,7 +144,7 @@ object AskPattern {
private final class PromiseRef[U](target: InternalRecipientRef[?], timeout: Timeout) {

// Note: _promiseRef mustn't have a type pattern, since it can be null
private[this] val (_ref: ActorRef[U], _future: Future[U], _promiseRef) =
private val (_ref: ActorRef[U], _future: Future[U], _promiseRef) =
if (target.isTerminated)
(
adapt.ActorRefAdapter[U](target.provider.deadLetters),
Expand Down
36 changes: 18 additions & 18 deletions actor/src/main/scala-3/org/apache/pekko/util/ByteIterator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -256,28 +256,28 @@ object ByteIterator {
override def getShort(implicit byteOrder: ByteOrder): Short = {
val cur = current
if cur.len >= java.lang.Short.BYTES then {
val r = cur.getShort(byteOrder)
val r = cur.getShort(using byteOrder)
normalize()
r
} else super.getShort(byteOrder)
} else super.getShort(using byteOrder)
}

override def getInt(implicit byteOrder: ByteOrder): Int = {
val cur = current
if cur.len >= java.lang.Integer.BYTES then {
val r = cur.getInt(byteOrder)
val r = cur.getInt(using byteOrder)
normalize()
r
} else super.getInt(byteOrder)
} else super.getInt(using byteOrder)
}

override def getLong(implicit byteOrder: ByteOrder): Long = {
val cur = current
if cur.len >= java.lang.Long.BYTES then {
val r = cur.getLong(byteOrder)
val r = cur.getLong(using byteOrder)
normalize()
r
} else super.getLong(byteOrder)
} else super.getLong(using byteOrder)
}

final override def len: Int = iterators.foldLeft(0) { _ + _.len }
Expand Down Expand Up @@ -417,19 +417,19 @@ object ByteIterator {
getToArray(xs, offset, n, 1) { getByte } { current.getBytes(_, _, _) }

def getShorts(xs: Array[Short], offset: Int, n: Int)(implicit byteOrder: ByteOrder): this.type =
getToArray(xs, offset, n, 2) { getShort(byteOrder) } { current.getShorts(_, _, _)(byteOrder) }
getToArray(xs, offset, n, 2) { getShort(using byteOrder) } { current.getShorts(_, _, _)(using byteOrder) }

def getInts(xs: Array[Int], offset: Int, n: Int)(implicit byteOrder: ByteOrder): this.type =
getToArray(xs, offset, n, 4) { getInt(byteOrder) } { current.getInts(_, _, _)(byteOrder) }
getToArray(xs, offset, n, 4) { getInt(using byteOrder) } { current.getInts(_, _, _)(using byteOrder) }

def getLongs(xs: Array[Long], offset: Int, n: Int)(implicit byteOrder: ByteOrder): this.type =
getToArray(xs, offset, n, 8) { getLong(byteOrder) } { current.getLongs(_, _, _)(byteOrder) }
getToArray(xs, offset, n, 8) { getLong(using byteOrder) } { current.getLongs(_, _, _)(using byteOrder) }

def getFloats(xs: Array[Float], offset: Int, n: Int)(implicit byteOrder: ByteOrder): this.type =
getToArray(xs, offset, n, 8) { getFloat(byteOrder) } { current.getFloats(_, _, _)(byteOrder) }
getToArray(xs, offset, n, 8) { getFloat(using byteOrder) } { current.getFloats(_, _, _)(using byteOrder) }

def getDoubles(xs: Array[Double], offset: Int, n: Int)(implicit byteOrder: ByteOrder): this.type =
getToArray(xs, offset, n, 8) { getDouble(byteOrder) } { current.getDoubles(_, _, _)(byteOrder) }
getToArray(xs, offset, n, 8) { getDouble(using byteOrder) } { current.getDoubles(_, _, _)(using byteOrder) }

/** For performance sensitive code, call copyToBuffer() directly on ByteString (it's optimised there) */
override def copyToBuffer(buffer: ByteBuffer): Int = {
Expand Down Expand Up @@ -649,10 +649,10 @@ abstract class ByteIterator extends BufferedIterator[Byte] {
}

def getFloat(implicit byteOrder: ByteOrder): Float =
java.lang.Float.intBitsToFloat(getInt(byteOrder))
java.lang.Float.intBitsToFloat(getInt(using byteOrder))

def getDouble(implicit byteOrder: ByteOrder): Double =
java.lang.Double.longBitsToDouble(getLong(byteOrder))
java.lang.Double.longBitsToDouble(getLong(using byteOrder))

/**
* Get a specific number of Bytes from this iterator. In contrast to
Expand Down Expand Up @@ -690,7 +690,7 @@ abstract class ByteIterator extends BufferedIterator[Byte] {
* Get a number of Shorts from this iterator.
*/
def getShorts(xs: Array[Short])(implicit byteOrder: ByteOrder): this.type =
getShorts(xs, 0, xs.length)(byteOrder)
getShorts(xs, 0, xs.length)(using byteOrder)

/**
* Get a number of Shorts from this iterator.
Expand All @@ -701,7 +701,7 @@ abstract class ByteIterator extends BufferedIterator[Byte] {
* Get a number of Ints from this iterator.
*/
def getInts(xs: Array[Int])(implicit byteOrder: ByteOrder): this.type =
getInts(xs, 0, xs.length)(byteOrder)
getInts(xs, 0, xs.length)(using byteOrder)

/**
* Get a number of Ints from this iterator.
Expand All @@ -712,7 +712,7 @@ abstract class ByteIterator extends BufferedIterator[Byte] {
* Get a number of Longs from this iterator.
*/
def getLongs(xs: Array[Long])(implicit byteOrder: ByteOrder): this.type =
getLongs(xs, 0, xs.length)(byteOrder)
getLongs(xs, 0, xs.length)(using byteOrder)

/**
* Get a number of Longs from this iterator.
Expand All @@ -723,7 +723,7 @@ abstract class ByteIterator extends BufferedIterator[Byte] {
* Get a number of Floats from this iterator.
*/
def getFloats(xs: Array[Float])(implicit byteOrder: ByteOrder): this.type =
getFloats(xs, 0, xs.length)(byteOrder)
getFloats(xs, 0, xs.length)(using byteOrder)

/**
* Get a number of Floats from this iterator.
Expand All @@ -734,7 +734,7 @@ abstract class ByteIterator extends BufferedIterator[Byte] {
* Get a number of Doubles from this iterator.
*/
def getDoubles(xs: Array[Double])(implicit byteOrder: ByteOrder): this.type =
getDoubles(xs, 0, xs.length)(byteOrder)
getDoubles(xs, 0, xs.length)(using byteOrder)

/**
* Get a number of Doubles from this iterator.
Expand Down
2 changes: 1 addition & 1 deletion actor/src/main/scala/org/apache/pekko/actor/Actor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ object Status {
* }}}
*/
trait ActorLogging { this: Actor =>
private var _log: LoggingAdapter = _
private var _log: LoggingAdapter = null

def log: LoggingAdapter = {
// only used in Actor, i.e. thread safe
Expand Down
6 changes: 3 additions & 3 deletions actor/src/main/scala/org/apache/pekko/actor/ActorCell.scala
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ private[pekko] class ActorCell(
with dungeon.DeathWatch
with dungeon.FaultHandling {

private[this] var _props = _initialProps
private var _props = _initialProps
def props: Props = _props

import ActorCell._
Expand All @@ -445,11 +445,11 @@ private[pekko] class ActorCell(
override final def classicActorContext: ActorContext = this

protected def uid: Int = self.path.uid
private[this] var _actor: Actor = _
private var _actor: Actor = _
def actor: Actor = _actor
var currentMessage: Envelope = _
private var behaviorStack: List[Actor.Receive] = emptyBehaviorStack
private[this] var sysmsgStash: LatestFirstSystemMessageList = SystemMessageList.LNil
private var sysmsgStash: LatestFirstSystemMessageList = SystemMessageList.LNil

// Java API
final def getParent() = parent
Expand Down
4 changes: 2 additions & 2 deletions actor/src/main/scala/org/apache/pekko/actor/ActorRef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,8 @@ private[pekko] class VirtualPathContainer(
// AddressTerminatedTopic must be updated together with the variables here.
// Important: don't include calls to sendSystemMessage inside the synchronized since that can
// result in deadlock, see issue #26326
private[this] var watching = ActorCell.emptyActorRefSet
private[this] var _watchedBy: OptionVal[Set[ActorRef]] = OptionVal.Some(ActorCell.emptyActorRefSet)
private var watching = ActorCell.emptyActorRefSet
private var _watchedBy: OptionVal[Set[ActorRef]] = OptionVal.Some(ActorCell.emptyActorRefSet)

/**
* INTERNAL API
Expand Down
Loading
Loading