I have an Akka actor:
object AnActor:
private def handle(): Behavior[Command] =
Behaviors.receive { (context, msg) =>
msg match
case ACommand() =>
implicit val logger: Logger = context.log // works
given logger: Logger = context.log // fails at runtime: java.lang.UnsupportedOperationException: Unsupported access to ActorContext operation from the outside of Actor
val aRoutine: Future = // ...
aRoutine.onComplete(x => logger.info(x))
}
For some reason logger
defined by given
escapes a thread. Why?
And how to define a given
properly?
BTW what is a tool to check Java-ish code generated by Scala compiler?