javalin / javalin

A simple and modern Java and Kotlin web framework

Home Page:https://javalin.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Javalin 5.6.4 crashes on java 17, while 5.6.3 works fine

grzegorzbor opened this issue · comments

Actual behavior (the bug)
We are running the javalin-based application on JDK 17.
It worked fine on Javalin 5.6.3. But after upgrade to 5.6.4, the code which calls Context.cookie() method to create a cookie, breaks with the following exception:

io.javalin.Javalin : Fatal error occurred while servicing http-request
java.lang.NoSuchMethodError: 'java.lang.Object java.util.List.removeFirst()'
at io.javalin.http.CookieKt.setJavalinCookie(Cookie.kt:47)
at io.javalin.http.Context.cookie(Context.kt:409)

The same code works fine on JDK 17 with javalin 5.6.3.
Because there is almost ne change between 5.6.3 and 5,6.4, there should be no difference. The only difference that we found is that Javalin 5.6.3 release was built on JDK 17 and 5.6.4 was built on JDK 21.

I think that by using JDK 21 to built the javalin, it has been compiled with the Cookie class dependent on the (Sequenced)List.getFirst() method which has been added in java 21.

Expected behavior

Java 17 is LTE and still in active use, so i don't think Javalin should require java 21 at this stage. Definitely it should not be required at the minor upgrade between 5.6.3 and 5.6.4. So javalin should be built on JDK 17, not 21.

Update: Given the fact that Javalin 5.x/6.x uses jetty 11, which is based on java 11, I think Javalin should even be built on JDK 11. But maybe there is no difference between buling on JDK 11 vs 17, while it seems there is a difference between building on 17 vs 21.

Thanks @grzegorzbor, this is frustrating... We had a similar issue earlier, and we supposedly fixed it: #2117

I guess we have to replace the import here too.

We tried upgrading dependency to Kotlin 1.9.23 but it didn't help.
I think maybe this would help at the build time (i mean Javalin build). But now when javalin 5.6.4 is built and linked to the JDK21 method, there is no way to fix it - the 5.6.4 version is just unusable on JDK < 21

I think maybe this would help at the build time (i mean Javalin build). But now when javalin 5.6.4 is built and linked to the JDK21 method, there is no way to fix it - the 5.6.4 version is just unusable on JDK < 21

Yes, I meant that I will try to release using Kotlin 1.9.23 :)

Yes, I meant that I will try to release using Kotlin 1.9.23 :)

We're already on 1.9.23. (Nevermind, I was looking at 6x)

I will build using JDK 11.

After spending way too much time guarding against this on the wrong branch (🤦), I have released 5.6.5, built with JDK 11.

Yep works! thx