This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 0362def0d5 Create a HttpParser if none is found 0362def0d5 is described below commit 0362def0d5eacf1bcabede9ababa14842653c55f Author: remm <r...@apache.org> AuthorDate: Thu Oct 24 17:05:06 2024 +0200 Create a HttpParser if none is found Lifecycle is not enforced in these components, and init actually does little (JMX, protocol handlers, upgrade protocols; all likely not used and maybe not desired). Normally HTTP/2 is always fine since it has to use init to work. Reported NPE in Http11InputBuffer from a user with a "working" embedded Tomcat before 9.0.93. --- java/org/apache/coyote/http11/Http11Processor.java | 16 ++++++++++++++-- webapps/docs/changelog.xml | 7 +++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java index 3166903227..aee4a92c04 100644 --- a/java/org/apache/coyote/http11/Http11Processor.java +++ b/java/org/apache/coyote/http11/Http11Processor.java @@ -145,13 +145,25 @@ public class Http11Processor extends AbstractProcessor { private SendfileDataBase sendfileData = null; + /** + * Http parser. + */ + private final HttpParser httpParser; + + @SuppressWarnings("deprecation") public Http11Processor(AbstractHttp11Protocol<?> protocol, Adapter adapter) { super(adapter); this.protocol = protocol; + HttpParser httpParser = protocol.getHttpParser(); + if (httpParser == null) { + httpParser = new HttpParser(protocol.getRelaxedPathChars(), protocol.getRelaxedQueryChars()); + } + this.httpParser = httpParser; + inputBuffer = new Http11InputBuffer(request, protocol.getMaxHttpRequestHeaderSize(), - protocol.getRejectIllegalHeader(), protocol.getHttpParser()); + protocol.getRejectIllegalHeader(), httpParser); request.setInputBuffer(inputBuffer); outputBuffer = new Http11OutputBuffer(response, protocol.getMaxHttpResponseHeaderSize()); @@ -763,7 +775,7 @@ public class Http11Processor extends AbstractProcessor { // Validate the characters in the URI. %nn decoding will be checked at // the point of decoding. for (int i = uriBC.getStart(); i < uriBC.getEnd(); i++) { - if (!protocol.getHttpParser().isAbsolutePathRelaxed(uriB[i])) { + if (!httpParser.isAbsolutePathRelaxed(uriB[i])) { badRequest("http11processor.request.invalidUri"); break; } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 2126ed8b0b..94ac99b9c4 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -199,6 +199,13 @@ <fix> Skip OpenSSLConf with BoringSSL since it is unsupported. (remm) </fix> + <fix> + Create the <code>HttpParser</code> in <code>Http11Processor</code> + if it is not present on the <code>AbstractHttp11Protocol</code> + to provide better lifecycle robustness for regular HTTP/1.1. The new + behavior was introduced on a previous refactoring to improve HTTP/2 + performance. (remm) + </fix> </changelog> </subsection> <subsection name="Japser"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org