Use a dedicated mismatching indicator instead of null for WidenInterceptor. (#27292)

This commit is contained in:
kerr 2019-07-23 21:58:04 +08:00 committed by Arnout Engelen
parent 5e68cd0297
commit d4dcbee4c9

View file

@ -179,8 +179,9 @@ private[akka] final class LogMessagesInterceptor(val opts: LogOptions) extends B
@InternalApi
private[akka] object TransformMessagesInterceptor {
private final val _any2null = (_: Any) => null
private final def any2null[T] = _any2null.asInstanceOf[Any => T]
private final val _notMatchIndicator: Any = new AnyRef
private final val _any2NotMatchIndicator = (_: Any) => _notMatchIndicator
private final def any2NotMatchIndicator[T] = _any2NotMatchIndicator.asInstanceOf[Any => T]
}
/**
@ -205,8 +206,8 @@ private[akka] final case class TransformMessagesInterceptor[O: ClassTag, I](matc
}
def aroundReceive(ctx: TypedActorContext[O], msg: O, target: ReceiveTarget[I]): Behavior[I] = {
matcher.applyOrElse(msg, any2null) match {
case null => Behaviors.unhandled
matcher.applyOrElse(msg, any2NotMatchIndicator) match {
case result if _notMatchIndicator == result => Behaviors.unhandled
case transformed => target(ctx, transformed)
}
}