Correctly throw when akka.discovery.SimpleServiceDiscovery is found

ReflectiveDynamicAccess.getClassFor checks whether the found class
is of the 'desired type' and if not throws a ClassCastException. In
this case we ignore the result, so the expected type is Nothing,
and akka.discovery.SimpleServiceDiscovery is not assignable to
Nothing.
This commit is contained in:
Arnout Engelen 2019-03-14 18:57:58 +01:00
parent 0646d2d36a
commit 2ccf2ac354
No known key found for this signature in database
GPG key ID: BB8C0F854A1E2105

View file

@ -115,7 +115,11 @@ object Discovery extends ExtensionId[Discovery] with ExtensionIdProvider {
throw new RuntimeException(
"Old version of Akka Discovery from Akka Management found on the classpath. Remove `com.lightbend.akka.discovery:akka-discovery` from the classpath..")
} catch {
case _: ClassNotFoundException => // all good
case _: ClassCastException
throw new RuntimeException(
"Old version of Akka Discovery from Akka Management found on the classpath. Remove `com.lightbend.akka.discovery:akka-discovery` from the classpath..")
case _: ClassNotFoundException =>
// all good
}
}