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 · 4 comments

Comments

Projects
None yet
5 participants
@jhaeyaert
Copy link

jhaeyaert commented Jun 21, 2017

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.

@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

This comment has been minimized.

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.

@philwebb

This comment has been minimized.

Copy link
Member

philwebb commented Jun 26, 2017

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

@philwebb philwebb added this to the 2.0.0.M3 milestone Jun 26, 2017

@mbhave mbhave self-assigned this Jul 13, 2017

@mbhave

This comment has been minimized.

Copy link
Contributor

mbhave commented Jul 13, 2017

probably also need BuilderCustomizer for Undertow?

@wilkinsona

This comment has been minimized.

Copy link
Member

wilkinsona commented Jul 13, 2017

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

@mbhave mbhave closed this in eb4fc16 Jul 17, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment