From 18d2f78aa2e133fd44c2320e8e26f4605668dd9d Mon Sep 17 00:00:00 2001 From: Violeta Georgieva Date: Mon, 25 Mar 2024 13:56:37 +0200 Subject: [PATCH] Always check readTimeout configuration before pipeline checks --- .../java/reactor/netty/http/server/HttpServerConfig.java | 8 +++++--- .../reactor/netty/http/server/HttpServerOperations.java | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/reactor-netty-http/src/main/java/reactor/netty/http/server/HttpServerConfig.java b/reactor-netty-http/src/main/java/reactor/netty/http/server/HttpServerConfig.java index 0a11760d7a..a746dc7ba5 100644 --- a/reactor-netty-http/src/main/java/reactor/netty/http/server/HttpServerConfig.java +++ b/reactor-netty-http/src/main/java/reactor/netty/http/server/HttpServerConfig.java @@ -1481,9 +1481,11 @@ protected void decode(ChannelHandlerContext ctx, HttpObject msg, List ou } void stopTimeouts(ChannelHandlerContext ctx) { - ChannelHandler handler = ctx.channel().pipeline().get(NettyPipeline.ReadTimeoutHandler); - if (handler != null) { - ctx.channel().pipeline().remove(handler); + if (readTimeout != null) { + ChannelHandler handler = ctx.channel().pipeline().get(NettyPipeline.ReadTimeoutHandler); + if (handler != null) { + ctx.channel().pipeline().remove(handler); + } } if (requestTimeoutFuture != null) { requestTimeoutFuture.cancel(false); diff --git a/reactor-netty-http/src/main/java/reactor/netty/http/server/HttpServerOperations.java b/reactor-netty-http/src/main/java/reactor/netty/http/server/HttpServerOperations.java index a8cd5d96b2..c2f9741180 100644 --- a/reactor-netty-http/src/main/java/reactor/netty/http/server/HttpServerOperations.java +++ b/reactor-netty-http/src/main/java/reactor/netty/http/server/HttpServerOperations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2023 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2011-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -677,7 +677,9 @@ protected void onInboundNext(ChannelHandlerContext ctx, Object msg) { super.onInboundNext(ctx, msg); } if (msg instanceof LastHttpContent) { - removeHandler(NettyPipeline.ReadTimeoutHandler); + if (readTimeout != null) { + removeHandler(NettyPipeline.ReadTimeoutHandler); + } if (requestTimeoutFuture != null) { requestTimeoutFuture.cancel(false); requestTimeoutFuture = null;