Javalin 2.8.0 arrives with Micrometer support and important Misc fixes
Javalin, with its super fast release cycle, is back with a new update that brings some important fixes as well as some handy new features. Let’s take a look.
If you are not yet familiar with Javalin, a short introduction is in order.
Javalin is a potent yet lightweight mixture of Java and Kotlin. With a focus on simplicity and interoperability, Javalin is perfect for developers who need a flexible and lightweight framework for developing.
This time around, we take a look at Javalin 2.8.0 which brings some important fixes, as well as Validation improvements, and Micrometer support.
Let’s have a look.
Validation improvements – The validation added in 2.2.0 is one of Javalin’s most popular features. However, the syntax was a bit rickety. More specifically, the naming of the validation methods make the code overly verbose, and everything looks very inconsistent. In 2.8.0,
ctx.validated... gets deprecated and overloads are introduced instead. This should make controllers a lot easier to read. The methods will be removed completely in 3.0.0.
Micrometer support – This vendor-neutral application metrics facade is now supported in Javalin and you can easily enable it by doing
Simplified startup logging – This might seem like a minor thing, but there have been some complaints from the users about verbose and cryptic log messages from Jetty. The Javalin team agrees that those messages weren’t that helpful so they removed them.
Misc fixes – There are several important fixes including:
- CORS now supports cookies (allow-credentials: true)
- You can now use any connector (such as
UnixSocketConnector) with the embedded Jetty server
- Jetty no longer retries a request if a
java.lang.Erroris thrown in a handler
- Javalin used to
log.error(...)if it failed to start, now it throws instead
sessionHandler()no longer throws exceptions if
Head over to the official release notes to find out more information on these updates.
Want to try out Javalin 2.6 for yourself? This open source web framework is available on GitHub or here for download. Javalin is a true micro Java REST API library and has no external dependencies other than the embedded web-server, but it has plugins for JSON mapping and template rendering available if you need them.