From 2ccf2ac354290b47c3fbbced3a415acafb938f0d Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Thu, 14 Mar 2019 18:57:58 +0100 Subject: [PATCH] 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. --- .../src/main/scala/akka/discovery/Discovery.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/akka-discovery/src/main/scala/akka/discovery/Discovery.scala b/akka-discovery/src/main/scala/akka/discovery/Discovery.scala index ab1ef0e2c5..952f9c68d8 100644 --- a/akka-discovery/src/main/scala/akka/discovery/Discovery.scala +++ b/akka-discovery/src/main/scala/akka/discovery/Discovery.scala @@ -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 } }