authentikat-jwt
authentikat-jwt copied to clipboard
JwtHeader.fromJsonString fails on scala 2.12.12
Trying to parse the JWT with scala 2.12.12 fails
The following snippet will return false
on validation:
val jwt = JsonWebToken(JwtHeader("HS256"), JwtClaimsSet(Map.empty[String, String]), "test")
JsonWebToken.validate(jwt, "test")
There appears to be a problem to parse the header properly and the following header parsing throws an exception by itself:
JwtHeader.fromJsonString(JwtHeader("HS256").asJsonString)
Exception in thread "main" java.lang.NoSuchMethodError: scala.collection.immutable.List.$anonfun$flatMap$1$adapted(Lscala/runtime/BooleanRef;Lscala/runtime/ObjectRef;Lscala/runtime/ObjectRef;Ljava/lang/Object;)Ljava/lang/Object;
at java.base/java.lang.invoke.MethodHandleNatives.resolve(Native Method)
at java.base/java.lang.invoke.MemberName$Factory.resolve(MemberName.java:1041)
at java.base/java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:1066)
at java.base/java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:2040)
at java.base/java.lang.invoke.MethodHandles$Lookup.linkMethodHandleConstant(MethodHandles.java:2453)
at java.base/java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:501)
at org.json4s.MonadicJValue.findDirectByName(MonadicJValue.scala:25)
at org.json4s.MonadicJValue.$bslash(MonadicJValue.scala:18)
at authentikat.jwt.JwtHeader$.fromJsonString(JwtHeader.scala:42)
at com.playground$.main(App.scala:17)
at com.playground.App.main(App.scala)
The issue possibly comes from json4s and scala 2.12.12 problem with older json4s versions (e.g. https://github.com/scala/bug/issues/12100), and if so possibly the json4s should be updated here