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

Provide the same customisation options for Reactive Web Servers as Servlet Web Servers #9572

Closed
jhaeyaert opened this issue Jun 21, 2017 · 5 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@jhaeyaert
Copy link

Hi,

I currently testing Spring Boot 2.0.0.M2 and I was wondering how to customize Jetty Server with JettyReactiveWebServerFactory ?

With previous version I used JettyServletWebServerFactory which allowed to add Jetty Customizers. I was able to customize port, thread pool size and Jetty behaviour like remove ServerVersion Http header, enable Jetty request logging and so on. Ex :

    @Bean
    public ConfigurableServletWebServerFactory webServerFactory(BeanFactory beanFactory) {
        JettyServletWebServerFactory factory = new JettyServletWebServerFactory();
        factory.setPort(8080);

        final QueuedThreadPool threadPool = new QueuedThreadPool(applicationConfig.getServerMaxThreads(), applicationConfig.getServerMinThreads(),
                applicationConfig.getServerIdleTimeout(), new BlockingArrayQueue<>(100, 100));

        threadPool.setName("http");
        factory.setThreadPool(threadPool);

        // Add customized Jetty configuration
        factory.addServerCustomizers(new JettyServerCustomizer[]{(JettyServerCustomizer) server -> {
            ServerConnector httpConnector = (ServerConnector) server.getConnectors()[0];

            // Remove non necessary headers (Server, X-Powered-By and Date).
            HttpConfiguration httpConfiguration = httpConnector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration();
            httpConfiguration.setSendServerVersion(false);
            httpConfiguration.setSendXPoweredBy(false);
            httpConfiguration.setSendDateHeader(false);
            server.addConnector(httpConnector);
...
}

With the reactive version, I still can configure port and pool but I can't found how to customize other specific setting of Jetty server such as enabling logging of requests or disable some headers

	@Bean
	public JettyReactiveWebServerFactory webServerFactory(BeanFactory beanFactory) {
		JettyReactiveWebServerFactory factory = new JettyReactiveWebServerFactory();
		factory.setPort(8080);

        	final QueuedThreadPool threadPool = new QueuedThreadPool(applicationConfig.getServerMaxThreads(), applicationConfig.getServerMinThreads(),
                applicationConfig.getServerIdleTimeout(), new BlockingArrayQueue<>(100, 100));

        	threadPool.setName("http");
        	factory.setThreadPool(threadPool);

        	// :-( Not available on reactive version : factory.addServerCustomizers(...)

		return factory;
	}

Is it intentional ? Is there any kind of limitation concerning customization of Jetty when using the reactive version ?

Thank in advance for your help.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 21, 2017
@wilkinsona wilkinsona changed the title How to customize Jetty Server when using JettyReactiveWebServerFactory with Spring Boot 2 Provide the same customisation options for Reactive Web Servers as Servlet Web Servers Jun 21, 2017
@wilkinsona
Copy link
Member

wilkinsona commented Jun 21, 2017

The reactive factories for Tomcat and Undertow are also missing some customiser support: Connector customisers for the former and DeploymentInfo customisers for the latter.

Perhaps that was intentional, but I can't think of a reason why such customisation shouldn't be supported in the reactive case.

@wilkinsona wilkinsona added for: team-attention An issue we'd like other members of the team to review priority: normal type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 21, 2017
@philwebb
Copy link
Member

I don't think it was intentional, probably just an oversight.

@philwebb philwebb removed the for: team-attention An issue we'd like other members of the team to review label Jun 26, 2017
@philwebb philwebb added this to the 2.0.0.M3 milestone Jun 26, 2017
@mbhave mbhave self-assigned this Jul 13, 2017
@mbhave
Copy link
Contributor

mbhave commented Jul 13, 2017

probably also need BuilderCustomizer for Undertow?

@wilkinsona
Copy link
Member

Oops, I missed that. Yeah, I think we do. Thanks @mbhave!

@mbhave mbhave closed this as completed in eb4fc16 Jul 17, 2017
@oneutf

This comment has been minimized.

@spring-projects spring-projects deleted a comment from oneutf Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

6 participants