wthamira
wthamira

Reputation: 2250

HttpServer tcpConfiguration Deprecated

I moved to Spring 2.3.1.RELEASE to 2.4.5.

HttpServer tcpConfiguration Deprecated with new version. How can i configure NioEventLoopGroup with Spring boot 2.4.5.

    public NettyReactiveWebServerFactory factory(NioEventLoopGroup eventLoopGroup) {
        NettyReactiveWebServerFactory factory = new NettyReactiveWebServerFactory();
        factory.setServerCustomizers(Collections.singletonList(new NettyServerCustomizer() {
            @Override
            public HttpServer apply(HttpServer httpServer) {
                return httpServer.tcpConfiguration(tcpServer ->
                        tcpServer.bootstrap(serverBootstrap -> serverBootstrap.group(eventLoopGroup)
                                .channel(NioServerSocketChannel.class)));
            }
        }));
        return factory;
    }

Upvotes: 0

Views: 4755

Answers (1)

Violeta Georgieva
Violeta Georgieva

Reputation: 2282

You should use directly the HttpServer#runOn API. The snippet above should be looking like this:

public NettyReactiveWebServerFactory factory(NioEventLoopGroup eventLoopGroup) {
    NettyReactiveWebServerFactory factory = new NettyReactiveWebServerFactory();
    factory.setServerCustomizers(Collections.singletonList(new NettyServerCustomizer() {
        @Override
        public HttpServer apply(HttpServer httpServer) {
            return httpServer.runOn(eventLoopGroup);
        }
    }));
    return factory;
}

Upvotes: 2

Related Questions