What is new in Jersey 2.32

Recently, Jersey 2.32 has been released. Jersey 2.x is a continuous evolution of Jersey implementing JAX-RS 2.1 Specification. While the successor Jakarta Restful Web Services 3.0 Specification, which is part of the Jakarta EE 9 initiative, will bring a lot of new features that will be implemented in Jersey 3.x (currently in 3.0.0-M6 release – which passes the Jakarta EE 9 Restful Web Services TCK already), and Jersey 3.x will become the main evolution branch, we see many requirements to keep developing Jersey 2.x for several additional years.

Jersey 2.32 (or newer) is the JAX-RS implementation that is going to be used in Helidon 2.0.3, and it also is planned to be part of the Weblogic Application Server 14.1.2.

Jersey 2.32 supports JDK 8, and JDK 11-JDK 15 (since Jersey 2.31). Along with interfaces PreInvocationInterceptorPostInvocationInterceptor, and InvocationBuilderListener, introduced in Jersey 2.30, an additional ClientBuilderListener interface has been added. Unlike the first two, it is not registered on the client, rather it is used as a service (defined in META-INF/services) so that it can be invoked before the Client is created.

Helidon 2 comes with a new reactive HTTP client called WebClient based on Netty HTTP client. Jersey 2.31 came with an alternative connector that uses the Helidon WebClient for HTTP requests using the WebClient by JAX-RS/Jersey client syntax. It has been built using Helidon 2.0.0-RC2 and as with the other connectors. The Helidon API changed, however, between Helidon 2.0.0-RC2 and Helidon 2.0.0 and the connector implementation was contributed to Helidon. Hence Jersey 2.32 comes with HelidonConnectorProvider that simply reuses the connector from Helidon. This way, the connector reflects the most recent changes in the implementation in Helidon (we recommend to use with Helidon 2.0.3, or later, when available, the maven dependency on Helidon connector is therefore provided in Jersey Helidon Connector module).

We made improvements to Netty and Apache connector, too. The Netty connector is configurable using NettyClientProperties, Apache connector accepts HttpEntity type in JAX-RS Entity. The default HttpUrlConnector now supports Expect:100-continue HTTP header using Expect100ContinueFeature.

Registering features now supports priorities on features. Both using @Priority or register(feature, priority) are legitimate options. This allows for the ordering of the execution of the features.

MicroProfile Rest Client implementation is now compatible with MicroProfile Rest Client 1.4.1 Specification. It also allows for using regular expressions in @Path annotation now.

We modified SSE, so now it is possible to do all of the following (in case of JDK8 the last 2 lines are not applicable):

    public void register(@Context SseEventSink eventSink)
    public void register(@Context org.glassfish.jersey.internal.jsr166.Flow.Subscriber<String> eventSink)
    public void register(@Context org.glassfish.jersey.internal.jsr166.Flow.Subscriber<OutboundEvent> eventSink)
    public void register(@Context java.util.concurrent.Flow.Subscriber<String> eventSink)
    public void register(@Context java.util.concurrent.Flow.Subscriber<OutboundEvent> eventSink)

For additional changes and details, it is possible to check release 2.32, and 2.31, respectively.

This entry was posted in Jersey. Bookmark the permalink.