From 31ae6da4ec78c2aa3eae952f203a9f29be5e779f Mon Sep 17 00:00:00 2001 From: Mark Thomas Date: Thu, 19 Dec 2024 15:44:18 +0000 Subject: [PATCH] Fix a rare NPE --- java/org/apache/coyote/http11/Http11InputBuffer.java | 5 ++++- webapps/docs/changelog.xml | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/java/org/apache/coyote/http11/Http11InputBuffer.java b/java/org/apache/coyote/http11/Http11InputBuffer.java index 2e6d0e885a73..13a174c48063 100644 --- a/java/org/apache/coyote/http11/Http11InputBuffer.java +++ b/java/org/apache/coyote/http11/Http11InputBuffer.java @@ -250,7 +250,10 @@ void recycle() { activeFilters[i].recycle(); } - byteBuffer.limit(0).position(0); + // Avoid rare NPE reported on users@ list + if (byteBuffer != null) { + byteBuffer.limit(0).position(0); + } lastActiveFilter = -1; swallowInput = true; diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 1be5e1afa25e..3813dfa7f5e5 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -124,6 +124,10 @@ Don't log warnings for registered HTTP/2 settings that Tomcat does not support. These settings are now silently ignored. (markt) + + Avoid a rare NullPointerException when recycling the + Http11InputBuffer. (markt) +