From 77a3af0c8f2c1680a8e97581636d41dd1b05ff9a Mon Sep 17 00:00:00 2001 From: Violeta Georgieva Date: Mon, 25 Mar 2024 14:08:41 +0200 Subject: [PATCH] Always check idleTimeout configuration before pipeline checks (#3117) --- .../java/reactor/netty/http/server/HttpTrafficHandler.java | 6 ++++-- .../java/reactor/netty/http/server/IdleTimeoutHandler.java | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/reactor-netty-http/src/main/java/reactor/netty/http/server/HttpTrafficHandler.java b/reactor-netty-http/src/main/java/reactor/netty/http/server/HttpTrafficHandler.java index 09412fabe3..c773b1f898 100644 --- a/reactor-netty-http/src/main/java/reactor/netty/http/server/HttpTrafficHandler.java +++ b/reactor-netty-http/src/main/java/reactor/netty/http/server/HttpTrafficHandler.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. @@ -148,7 +148,9 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) { } // read message and track if it was keepAlive if (msg instanceof HttpRequest) { - IdleTimeoutHandler.removeIdleTimeoutHandler(ctx.pipeline()); + if (idleTimeout != null) { + IdleTimeoutHandler.removeIdleTimeoutHandler(ctx.pipeline()); + } final HttpRequest request = (HttpRequest) msg; diff --git a/reactor-netty-http/src/main/java/reactor/netty/http/server/IdleTimeoutHandler.java b/reactor-netty-http/src/main/java/reactor/netty/http/server/IdleTimeoutHandler.java index b8d333fcb2..d31f6310b8 100644 --- a/reactor-netty-http/src/main/java/reactor/netty/http/server/IdleTimeoutHandler.java +++ b/reactor-netty-http/src/main/java/reactor/netty/http/server/IdleTimeoutHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2022-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. @@ -53,7 +53,7 @@ protected void channelIdle(ChannelHandlerContext ctx, IdleStateEvent evt) { } static void addIdleTimeoutHandler(ChannelPipeline pipeline, @Nullable Duration idleTimeout) { - if (pipeline.get(NettyPipeline.IdleTimeoutHandler) == null && idleTimeout != null) { + if (idleTimeout != null && pipeline.get(NettyPipeline.IdleTimeoutHandler) == null) { String baseName = null; if (pipeline.get(NettyPipeline.HttpCodec) != null) { baseName = NettyPipeline.HttpCodec;