Why does Intellij give this warning, what does it mean, how can I make it better ?
import akka.actor.Props
object Router {
def props(config: Config, addresses: Set[Address]): Props =
Props(classOf[Router], config, addresses)
// "dynamic invocation could be replaced with a constructor invocation"
If I the Props inplace I get a different warning.
system.actorOf(Props(classOf[Router], config, addresses))
// could be replaced with factory method call
Thanks
Are you missing a class Router definition with a constructor that takes a Config instance and a collection of Address instances? Something like...
class Router(config: Config, addresses: Set[Address]) extends Actor
If so, then try the following slight modification to your companion object.
object Router {
def props(config: Config, addresses: Set[Address]): Props = {
Props(new Router(config, addresses))
}
}
This follows best practices for creating actors and will probably get rid of the warning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With