Upgrading Jetty 8 to Jetty 9

2019-08-10 07:33发布

I am upgrading from jetty 8 to jetty 9 and have come across some issues around compilation failures within some APIs.

The SslSelectChannelConnector has been removed and from what I can see httpConfiguration with secureRequestCustomizer replaces this.

But there are many methods that I cant find on both. For example

setRequestBufferSize

setResponseBufferSize

setAcceptors

setMaxIdleTime

SessionHandler no longer has a getSessionManager() method.

Also the queueThreadPool no longer has a setMaxQueued(int ), and JettyServer no longer has these two methods: setThreadPool(QueueThreadPool) setGracefulShutdown(int)

Edit: SslSelectChannelConnector Deprecated. use SelectChannelConnector with SslContextFactory.

jettyServer.setThreadPool(threadPool);  // --> threadPool is set in the constructor new Server(QueueThreadPool)
jettyServer.setGracefulShutdown(5000);  // --> jettyServer.setStopTimeout(5000);
jettyServer.setConnectors(new Connector[] { connector });  // -->  ServerConnector which takes https_config
jettyServer.setSendServerVersion(false); // -->  https_config.setSendServerVersion(false);

Where or which API is used in place of the above?

Also is there any custom stuff that stopped working at runtime, that isn't obvious to find/see.

1条回答
趁早两清
2楼-- · 2019-08-10 07:53

Reminder: Jetty versioning (since 1995) is <servlet_support>.<major_version>.<minor_version>

You are doing a major version upgrade from 8.1 to 9.4 (which is 6 major versions!). You are seeing a massive amount of change as a result of this.

The SslSelectChannelConnector has been removed and from what I can see httpConfiguration with secureRequestCustomizer replaces this.

Welcome to the new world of protocols.

There is no longer any concept of protocol specific connectors.

ServerConnector is the connector, it has no protocol knowledge, nor needs it. It simply is a connection point (not even TCP/IP specific, it could be Unix Sockets for example) to the server.

The configuration of it, determines the connection type, where it binds, and how the protocol is negotiated once the client connects to that port.

The ConnectionFactory determines that.

The HttpConfiguration determines how the HTTP level behavior functions.

See: https://stackoverflow.com/a/30191878/775715 for description.

See: embedded-jetty examples of this is use. Start with LikeJettyXml.java.

See: embedded-jetty-cookbook for more examples.

But there are many methods that I cant find on both. For example

setRequestBufferSize

This doesn't exist anymore, it was incompatible with SPDY and HTTP/2

See HttpConfiguration.setRequestHeaderSize(int) for controlling the maximum request header size.

Note: If you are using HTTP/2, we would recommend that you do not adjust the request header size to be bigger then default (for protocol compatibility reasons).

setResponseBufferSize

This doesn't exist anymore, it was incompatible with SPDY and HTTP/2.

See HttpConfiguration.setResponseHeaderSize(int) for controlling the maximum response header size.

Note: If you are using HTTP/2, we would recommend that you do not adjust the response header size to be bigger then default (for protocol compatibility reasons).

See HttpConfiguration.setOutputBufferSize(int) for output buffer aggregation controls. (has little meaning in HTTP/2, is really only relevant for HTTP/1.x)

setAcceptors

See the various constructors for ServerConnector, there are no setters for these.

setMaxIdleTime

There are many idle timeout settings available to you (eg: connector, connection, endpoint, thread, threadpool, AsyncContext, read, write, websocket session, etc ...)

Here's a few examples that seem relevant based on your questions.

See ServerConnector.setIdleTimeout(long)

See HttpConfiguration.setIdleTimeout(long)

See QueuedThreadPool.setIdleTimeout(int)

SessionHandler no longer has a getSessionManager() method.

The Session Handling has undergone even greater change over the past 6 major version updates then the connectors.

See: OneServletContextWithSession.java

Also the queueThreadPool no longer has a setMaxQueued(int ), and JettyServer no longer has these two methods: setThreadPool(QueueThreadPool) setGracefulShutdown(int)

The configuration for min/max in QueuedThreadPool are part of the Constructors. There are no setters for min/max.

To configure the Server thread pool, use the constructors that allow you to pass in a Thread Pool.

Note: If you are using HTTP/2, with html/css/javascript we would recommend that you plan for increased thread pool demand (due to the nature of the protocol)

查看更多
登录 后发表回答