Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JettyWebServer breaks Jetty ConnectionLimit feature #30565

Closed
baranchikovaleks opened this issue Apr 6, 2022 · 1 comment
Closed

JettyWebServer breaks Jetty ConnectionLimit feature #30565

baranchikovaleks opened this issue Apr 6, 2022 · 1 comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply

Comments

@baranchikovaleks
Copy link

Hello everyone!

In Spring Boot version >2.5.0 JettyWebServer started caching and removing http connectors directly, not via adding lifecycle bean (I suspect this is when it happened - df5f591#diff-7f526bfbdf69fd8f17c40e6583deb2ca69c12528c7730a37c815ec7605eb5e98R122)

So when I configure JettyServerCustomizer to limit connections like this

    @Bean
    public JettyServerCustomizer serverConnectionLimit() {
        return server -> server.addBean(new ConnectionLimit(1, server));
    }

it just does not work, because all the connectors were removed from the server
https://github.com/eclipse/jetty.project/blob/jetty-9.4.46.v20220331/jetty-server/src/main/java/org/eclipse/jetty/server/ConnectionLimit.java#L141

As a workaround, I can use another constructor

    @Bean
    public JettyServerCustomizer connectorsConnectionLimit() {
        return server -> server.addBean(new ConnectionLimit(1, server.getConnectors()));
    }

which works just fine, but I don't think this is an obvious behavior.

I created a small project to reproduce
https://github.com/baranchikovaleks/connection-limit-test

It contains a single test which fails on Spring Boot >2.5.0 and works for older versions.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 6, 2022
@wilkinsona
Copy link
Member

Thanks for the sample and for pinpointing the cause of the change in behavior.

Unfortunately, for things to work as we want with Jetty 10, we have to remove the connectors before calling start() rather than via a bean that's called as part of start() processing. This is due to this change and the eager opening of connections. If we only remove the connectors via a bean, they are available to be opened early which breaks our port clash detection as, in a server with multiple connectors, it's then impossible to determine which connector failed to open.

It would be possible to use different logic in JettyWebServer for removing the connectors, depending on whether its Jetty 9 or Jetty 10 that's being used. However, others may be relying on the current behavior and, given that this works when you retrieve the connectors from the server and pass them into ConnectionLimit, I think we should leave things as they are to avoid the risk of regression in a maintenance release.

@wilkinsona wilkinsona added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

3 participants