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

Customizers for WebServerFactory should only apply to auto-configured WebServerFactory bean #19111

Closed
brucelwl opened this issue Nov 25, 2019 · 2 comments
Labels
status: superseded An issue that has been superseded by another

Comments

@brucelwl
Copy link

brucelwl commented Nov 25, 2019

servlet context parameters will be replaced by ServletWebServerFactoryCustomizer when providing a custom TomcatServletWebServerFactory

I used @Bean to customize TomcatServletWebServerFactory,and set the servlet context parameters, but the parameters replaced by ServletWebServerFactoryCustomizer get from org.springframework.boot.autoconfigure.web.ServerProperties, Is this a bug ?

Here is my @Bean code

 @Bean
    public TomcatServletWebServerFactory tomcatServletWebServerFactory() {
        TomcatServletWebServerFactory tomcatServletWebServerFactory =
                                   new TomcatServletWebServerFactory();

        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("param1", "value1");
        hashMap.put("param2", "value2");

        tomcatServletWebServerFactory.setInitParameters(hashMap);

        return tomcatServletWebServerFactory;
    }

But the following code will replace my parameter settings

image

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 25, 2019
@mbhave mbhave added the for: team-attention An issue we'd like other members of the team to review label Nov 26, 2019
@mbhave
Copy link
Contributor

mbhave commented Dec 2, 2019

This is happening because the WebServerFactoryCustomizers are applied not just to the auto-configured TomcatServletWebServerFactory bean but also to a user-provided TomcatServletWebServerFactory bean. Ideally, we'd like the customizers to apply only to the auto-configured bean as that aligns with the other customizers. This would, however, be a breaking change and we've decided to hold off on this till 3.0.

@brucelwl For your case, you would need to configure a bean of type WebServerFactoryCustomizer which would be ordered so that it is applied after ServletWebServerFactoryCustomizer. You could either move all of your customization logic there instead of adding a bean for TomcatServletWebServerFactory, or just move the bits that overridden by ServletWebServerFactoryCustomizer.

@mbhave mbhave added type: enhancement A general enhancement and removed for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged labels Dec 2, 2019
@mbhave mbhave changed the title servlet context parameters will be replaced by ServletWebServerFactoryCustomizer when providing a custom TomcatServletWebServerFactory Customizers for WebServerFactory should only apply to auto-configured WebServerFactory bean Dec 2, 2019
@mbhave mbhave added this to the General Backlog milestone Dec 2, 2019
@mbhave
Copy link
Contributor

mbhave commented Mar 4, 2021

I think #24706 supersedes this one.

@mbhave mbhave closed this as completed Mar 4, 2021
@mbhave mbhave added status: superseded An issue that has been superseded by another and removed type: enhancement A general enhancement labels Mar 4, 2021
@mbhave mbhave removed this from the General Backlog milestone Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another
Projects
None yet
Development

No branches or pull requests

3 participants