Use ByteBuffer support in ServletHttpHandlerAdapter

As of Servlet 6.1, the `ServletInputStream` and `ServletOutputStream`
offer read and write variants based on `ByteBuffer` instead of byte
arrays. This can improve performance and avoid memory copy for I/O
calls.

This was already partially supported for some servers like Tomcat
through specific adapters. This commit moves this support to the
standard `ServletHttpHandlerAdapter` and makes it available for all
Servlet 6.1+ containers.

Closes gh-33748
This commit is contained in:
Brian Clozel
2024-11-22 15:08:02 +01:00
parent f5ff84ab7b
commit 3b65506c13
5 changed files with 40 additions and 175 deletions

View File

@@ -22,7 +22,6 @@ import org.eclipse.jetty.ee10.websocket.server.config.JettyWebSocketServletConta
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.springframework.http.server.reactive.JettyHttpHandlerAdapter;
import org.springframework.http.server.reactive.ServletHttpHandlerAdapter;
/**
@@ -41,7 +40,7 @@ public class JettyHttpServer extends AbstractHttpServer {
this.jettyServer = new Server();
ServletHttpHandlerAdapter servlet = createServletAdapter();
ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter(resolveHttpHandler());
ServletHolder servletHolder = new ServletHolder(servlet);
servletHolder.setAsyncSupported(true);
@@ -56,10 +55,6 @@ public class JettyHttpServer extends AbstractHttpServer {
this.jettyServer.setHandler(this.contextHandler);
}
private ServletHttpHandlerAdapter createServletAdapter() {
return new JettyHttpHandlerAdapter(resolveHttpHandler());
}
@Override
protected void startInternal() throws Exception {
this.jettyServer.start();