(tomcat) branch 10.1.x updated: Add support for Java 23

2024-04-29 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
 new f8ea6383c2 Add support for Java 23
f8ea6383c2 is described below

commit f8ea6383c2e9c93f2e2bd748331a55524ac98374
Author: Mark Thomas 
AuthorDate: Mon Apr 29 09:03:32 2024 +0100

Add support for Java 23
---
 java/org/apache/jasper/compiler/JDTCompiler.java | 11 +++
 webapps/docs/changelog.xml   | 11 +++
 2 files changed, 22 insertions(+)

diff --git a/java/org/apache/jasper/compiler/JDTCompiler.java 
b/java/org/apache/jasper/compiler/JDTCompiler.java
index 2179f3a7e7..e34a911166 100644
--- a/java/org/apache/jasper/compiler/JDTCompiler.java
+++ b/java/org/apache/jasper/compiler/JDTCompiler.java
@@ -332,6 +332,11 @@ public class JDTCompiler extends 
org.apache.jasper.compiler.Compiler {
 // Java 11.
 // This is checked against the actual version below.
 settings.put(CompilerOptions.OPTION_Source, "22");
+} else if (opt.equals("23")) {
+// Constant not available in latest ECJ version that runs on
+// Java 11.
+// This is checked against the actual version below.
+settings.put(CompilerOptions.OPTION_Source, "23");
 } else {
 log.warn(Localizer.getMessage("jsp.warning.unknown.sourceVM", 
opt));
 settings.put(CompilerOptions.OPTION_Source, 
CompilerOptions.VERSION_11);
@@ -417,6 +422,12 @@ public class JDTCompiler extends 
org.apache.jasper.compiler.Compiler {
 // This is checked against the actual version below.
 settings.put(CompilerOptions.OPTION_TargetPlatform, "22");
 settings.put(CompilerOptions.OPTION_Compliance, "22");
+} else if (opt.equals("23")) {
+// Constant not available in latest ECJ version shipped with
+// Tomcat. May be supported in a snapshot build.
+// This is checked against the actual version below.
+settings.put(CompilerOptions.OPTION_TargetPlatform, "23");
+settings.put(CompilerOptions.OPTION_Compliance, "23");
 } else {
 log.warn(Localizer.getMessage("jsp.warning.unknown.targetVM", 
opt));
 settings.put(CompilerOptions.OPTION_TargetPlatform, 
CompilerOptions.VERSION_11);
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index b022f03249..f736ed04db 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -174,6 +174,17 @@
   
 
   
+  
+
+  
+Add support for specifying Java 23 (with the value 23) as
+the compiler source and/or compiler target for JSP compilation. If used
+with an Eclipse JDT compiler version that does not support these 
values,
+a warning will be logged and the default will used.
+(markt)
+  
+
+  
   
 
   


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 02/02: Add support for Java 23

2024-04-29 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 096e13459dc74760510d3abe2102810cb7566c1c
Author: Mark Thomas 
AuthorDate: Mon Apr 29 09:03:32 2024 +0100

Add support for Java 23
---
 java/org/apache/jasper/compiler/JDTCompiler.java | 11 ---
 webapps/docs/changelog.xml   | 11 +++
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/jasper/compiler/JDTCompiler.java 
b/java/org/apache/jasper/compiler/JDTCompiler.java
index 16bf7060f7..e5b5d1a278 100644
--- a/java/org/apache/jasper/compiler/JDTCompiler.java
+++ b/java/org/apache/jasper/compiler/JDTCompiler.java
@@ -322,10 +322,12 @@ public class JDTCompiler extends 
org.apache.jasper.compiler.Compiler {
 } else if (opt.equals("21")) {
 settings.put(CompilerOptions.OPTION_Source, 
CompilerOptions.VERSION_21);
 } else if (opt.equals("22")) {
+settings.put(CompilerOptions.OPTION_Source, 
CompilerOptions.VERSION_22);
+} else if (opt.equals("23")) {
 // Constant not available in latest ECJ version shipped with
 // Tomcat. May be supported in a snapshot build.
 // This is checked against the actual version below.
-settings.put(CompilerOptions.OPTION_Source, "22");
+settings.put(CompilerOptions.OPTION_Source, "23");
 } else {
 log.warn(Localizer.getMessage("jsp.warning.unknown.sourceVM", 
opt));
 settings.put(CompilerOptions.OPTION_Source, 
CompilerOptions.VERSION_17);
@@ -400,11 +402,14 @@ public class JDTCompiler extends 
org.apache.jasper.compiler.Compiler {
 settings.put(CompilerOptions.OPTION_TargetPlatform, 
CompilerOptions.VERSION_21);
 settings.put(CompilerOptions.OPTION_Compliance, 
CompilerOptions.VERSION_21);
 } else if (opt.equals("22")) {
+settings.put(CompilerOptions.OPTION_TargetPlatform, 
CompilerOptions.VERSION_22);
+settings.put(CompilerOptions.OPTION_Compliance, 
CompilerOptions.VERSION_22);
+} else if (opt.equals("23")) {
 // Constant not available in latest ECJ version shipped with
 // Tomcat. May be supported in a snapshot build.
 // This is checked against the actual version below.
-settings.put(CompilerOptions.OPTION_TargetPlatform, "22");
-settings.put(CompilerOptions.OPTION_Compliance, "22");
+settings.put(CompilerOptions.OPTION_TargetPlatform, "23");
+settings.put(CompilerOptions.OPTION_Compliance, "23");
 } else {
 log.warn(Localizer.getMessage("jsp.warning.unknown.targetVM", 
opt));
 settings.put(CompilerOptions.OPTION_TargetPlatform, 
CompilerOptions.VERSION_17);
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 6e0838465d..53f60a70d2 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -196,6 +196,17 @@
   
 
   
+  
+
+  
+Add support for specifying Java 23 (with the value 23) as
+the compiler source and/or compiler target for JSP compilation. If used
+with an Eclipse JDT compiler version that does not support these 
values,
+a warning will be logged and the default will used.
+(markt)
+  
+
+  
   
 
   


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch main updated (e9046d96a6 -> 096e13459d)

2024-04-29 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from e9046d96a6 Add support for timescales with time-taken access log 
token. (#721)
 new 85cc21837a Update JDT to 4.31 (March 2024)
 new 096e13459d Add support for Java 23

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 build.properties.default | 12 ++--
 java/org/apache/jasper/compiler/JDTCompiler.java | 11 ---
 res/maven/tomcat-jasper.pom  |  2 +-
 webapps/docs/changelog.xml   | 14 ++
 4 files changed, 29 insertions(+), 10 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 01/02: Update JDT to 4.31 (March 2024)

2024-04-29 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 85cc21837a80e55cc508724f27b18fa85b4a1922
Author: Mark Thomas 
AuthorDate: Mon Apr 29 09:03:17 2024 +0100

Update JDT to 4.31 (March 2024)
---
 build.properties.default| 12 ++--
 res/maven/tomcat-jasper.pom |  2 +-
 webapps/docs/changelog.xml  |  3 +++
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/build.properties.default b/build.properties.default
index 0d6d7cabdc..a1fc6e5f17 100644
--- a/build.properties.default
+++ b/build.properties.default
@@ -123,15 +123,15 @@ base-maven.loc=https://repo.maven.apache.org/maven2
 # - Eclipse JDT, version 4.7 or later -#
 # See 
https://cwiki.apache.org/confluence/display/TOMCAT/Managing+Tomcat%27s+Dependency+on+the+Eclipse+JDT+Core+Batch+Compiler
 #
-# Checksum is from "SHA512 Checksums for 4.30" link at
-# https://download.eclipse.org/eclipse/downloads/drops4/R-4.30-202312010110/
-# 
https://download.eclipse.org/eclipse/downloads/drops4/R-4.30-202312010110/checksum/eclipse-4.30-SUMSSHA512
+# Checksum is from "SHA512 Checksums for 4.31" link at
+# https://download.eclipse.org/eclipse/downloads/drops4/R-4.31-202402290520/
+# 
https://download.eclipse.org/eclipse/downloads/drops4/R-4.31-202402290520/checksum/eclipse-4.31-SUMSSHA512
 #
-jdt.version=4.30
-jdt.release=R-4.30-202312010110
+jdt.version=4.31
+jdt.release=R-4.31-202402290520
 jdt.checksum.enabled=true
 jdt.checksum.algorithm=SHA-512
-jdt.checksum.value=f889b0f305cdf6b548e13ef73cd8ec488be3bf43a3d48659a1fcfce01068fb47adb398bb6006a067d61cfefbee7ecc279e4fcea385f27be211817709cdebc54e
+jdt.checksum.value=1f31bea2297013601ba7a3e0a8c65d7b621601c106fe10bf2a11af625d63aa0772941fa029fb392cd9fe2314203e6ef7e04a94dc938e15961108494139fae3e8
 jdt.home=${base.path}/ecj-${jdt.version}
 jdt.jar=${jdt.home}/ecj-${jdt.version}.jar
 # The download will be moved to the archive area eventually. We are taking 
care of that in advance.
diff --git a/res/maven/tomcat-jasper.pom b/res/maven/tomcat-jasper.pom
index fd97e2a35f..6976884efa 100644
--- a/res/maven/tomcat-jasper.pom
+++ b/res/maven/tomcat-jasper.pom
@@ -60,7 +60,7 @@
 
   org.eclipse.jdt
   ecj
-  3.36.0
+  3.37.0
 
 
   org.apache.tomcat
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index cc82d7932b..6e0838465d 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -203,6 +203,9 @@
 rather than the version provided by Commons Codec. This removes the
 internal fork of Commons Codec. (markt)
   
+  
+Update to the Eclipse JDT compiler 4.31. (markt)
+  
 
   
 


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 05/05: Fix disastrous cookie-logging patch.

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit fa0cb106e2d13edca9f2c8d038b913d2ae539a0c
Author: Christopher Schultz 
AuthorDate: Fri Apr 19 10:16:36 2024 -0400

Fix disastrous cookie-logging patch.
---
 java/org/apache/catalina/valves/AbstractAccessLogValve.java | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/valves/AbstractAccessLogValve.java 
b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
index 7a9c83d849..ca3a90e2e8 100644
--- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
+++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
@@ -1489,17 +1489,19 @@ public abstract class AbstractAccessLogValve extends 
ValveBase implements Access
 if (cookies != null) {
 for (Cookie cookie : cookies) {
 if (cookieNameToLog.equals(cookie.getName())) {
+if (value == null) {
+value = new StringBuilder();
+}
 if (first) {
 first = false;
 } else {
 value.append(',');
 }
-value = new StringBuilder();
 value.append(cookie.getValue());
 }
 }
 }
-if (value.length() == 0) {
+if (value == null) {
 buf.append('-');
 } else {
 escapeAndAppend(value.toString(), buf);


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 01/05: Add a method to filter the parsed headers.

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit b31efad19216282c43635099f3c6d02fad4d8df6
Author: Mark Thomas 
AuthorDate: Fri Apr 26 15:46:32 2024 +0100

Add a method to filter the parsed headers.

This will (eventually) be used by the refactored trailer header parsing
---
 java/org/apache/tomcat/util/http/MimeHeaders.java | 16 
 1 file changed, 16 insertions(+)

diff --git a/java/org/apache/tomcat/util/http/MimeHeaders.java 
b/java/org/apache/tomcat/util/http/MimeHeaders.java
index 48ec279a09..5a67d76f7a 100644
--- a/java/org/apache/tomcat/util/http/MimeHeaders.java
+++ b/java/org/apache/tomcat/util/http/MimeHeaders.java
@@ -23,6 +23,7 @@ import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.tomcat.util.buf.MessageBytes;
 import org.apache.tomcat.util.buf.StringUtils;
@@ -167,6 +168,21 @@ public class MimeHeaders {
 }
 
 
+public void filter(Set allowedHeaders) {
+int j = -1;
+for (int i = 0; i < count; i++) {
+String name = headers[i].getName().toStringType();
+if (allowedHeaders.contains(name)) {
+++j;
+if (j != i) {
+headers[j] = headers[i];
+}
+}
+}
+count = ++j;
+}
+
+
 public void duplicate(MimeHeaders source) throws IOException {
 for (int i = 0; i < source.size(); i++) {
 MimeHeaderField mhf = createHeader();


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 9.0.x updated (4d23ff3142 -> fa0cb106e2)

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from 4d23ff3142 Remove redundant override javadoc
 new b31efad192 Add a method to filter the parsed headers.
 new e87a432f88 Add a common header parser for headers and trailers
 new f75509c443 Refactor chunked input filter to use common HTTP 
header/trailer parser
 new 7e8fd4350e Additional tests for non-blocking chunked reads
 new fa0cb106e2 Fix disastrous cookie-logging patch.

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../catalina/valves/AbstractAccessLogValve.java|   6 +-
 java/org/apache/coyote/http11/Http11Processor.java |   2 +-
 .../coyote/http11/filters/ChunkedInputFilter.java  | 576 -
 java/org/apache/tomcat/util/http/MimeHeaders.java  |  16 +
 .../tomcat/util/http/parser/HttpHeaderParser.java  | 409 +++
 .../util/http/parser/LocalStrings.properties   |   3 +
 .../util/http/parser/LocalStrings_fr.properties|   2 +
 .../util/http/parser/LocalStrings_ja.properties|   2 +
 .../catalina/nonblocking/TestNonBlockingAPI.java   | 442 +++-
 .../http11/filters/TestChunkedInputFilter.java | 176 ++-
 webapps/docs/changelog.xml |   3 +
 11 files changed, 1256 insertions(+), 381 deletions(-)
 create mode 100644 
java/org/apache/tomcat/util/http/parser/HttpHeaderParser.java


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 04/05: Additional tests for non-blocking chunked reads

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 7e8fd4350e2922c282d92787b08392d1e2949992
Author: Mark Thomas 
AuthorDate: Fri Apr 26 16:02:09 2024 +0100

Additional tests for non-blocking chunked reads
---
 .../catalina/nonblocking/TestNonBlockingAPI.java   | 442 -
 .../http11/filters/TestChunkedInputFilter.java | 176 +++-
 2 files changed, 587 insertions(+), 31 deletions(-)

diff --git a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java 
b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
index 1df7859c2d..e451835a72 100644
--- a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
+++ b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
@@ -72,6 +72,9 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
 
 private static final Log log = LogFactory.getLog(TestNonBlockingAPI.class);
 
+private static String TRAILER_HEADER_NAME = "x-test";
+private static String TRAILER_HEADER_VALUE = "abcde";
+
 private static final int CHUNK_SIZE = 1024 * 1024;
 private static final int WRITE_SIZE  = CHUNK_SIZE * 10;
 private static final byte[] DATA = new byte[WRITE_SIZE];
@@ -130,7 +133,7 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
 // No file system docBase required
 Context ctx = getProgrammaticRootContext();
 
-NBReadServlet servlet = new NBReadServlet(ignoreIsReady, async);
+NBReadServlet servlet = new NBReadServlet(ignoreIsReady, async, null);
 String servletName = NBReadServlet.class.getName();
 Tomcat.addServlet(ctx, servletName, servlet);
 ctx.addServletMappingDecoded("/", servletName);
@@ -154,31 +157,416 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
 
 
 @Test
-public void testNonBlockingReadChunked() throws Exception {
+public void testNonBlockingReadChunkedNoSplits() throws Exception {
+String[] requestBody = new String[] {
+"14" + SimpleHttpClient.CRLF +
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitBeforeChunkHeader() throws 
Exception {
+String[] requestBody = new String[] {
+"",
+"14" + SimpleHttpClient.CRLF +
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitInChunkHeader() throws 
Exception {
+String[] requestBody = new String[] {
+"1",
+"4" + SimpleHttpClient.CRLF +
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitAfterChunkHeader() throws 
Exception {
+String[] requestBody = new String[] {
+"14",
+SimpleHttpClient.CRLF +
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitInHeaderCrlf() throws Exception 
{
+String[] requestBody = new String[] {
+"14\r",
+"\n" +
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitAfterHeaderCrlf() throws 
Exception {
+String[] requestBody = new String[] {
+"14" + SimpleHttpClient.CRLF,
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitBeforeExtensionDelimter() 
throws Exception {
+String[] requestBody = new String[] {
+"14",
+";a=b" + SimpleHttpClient.CRLF +
+"012345678901FINIS

(tomcat) 03/05: Refactor chunked input filter to use common HTTP header/trailer parser

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit f75509c4439dacf21b065c8d2965169dab5d50bf
Author: Mark Thomas 
AuthorDate: Fri Apr 26 15:58:37 2024 +0100

Refactor chunked input filter to use common HTTP header/trailer parser

This adds non-blocking read support for chunked request bodies
---
 java/org/apache/coyote/http11/Http11Processor.java |   2 +-
 .../coyote/http11/filters/ChunkedInputFilter.java  | 576 -
 webapps/docs/changelog.xml |   3 +
 3 files changed, 233 insertions(+), 348 deletions(-)

diff --git a/java/org/apache/coyote/http11/Http11Processor.java 
b/java/org/apache/coyote/http11/Http11Processor.java
index 7c5ca6176e..37afea55fe 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -168,7 +168,7 @@ public class Http11Processor extends AbstractProcessor {
 
 // Create and add the chunked filters.
 inputBuffer.addFilter(
-new ChunkedInputFilter(protocol.getMaxTrailerSize(), 
protocol.getAllowedTrailerHeadersInternal(),
+new ChunkedInputFilter(request, protocol.getMaxTrailerSize(), 
protocol.getAllowedTrailerHeadersInternal(),
 protocol.getMaxExtensionSize(), 
protocol.getMaxSwallowSize()));
 outputBuffer.addFilter(new ChunkedOutputFilter());
 
diff --git a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 
b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
index 741cd1078b..f350487771 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
@@ -16,11 +16,9 @@
  */
 package org.apache.coyote.http11.filters;
 
-import java.io.EOFException;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
-import java.util.Locale;
 import java.util.Set;
 
 import org.apache.coyote.ActionCode;
@@ -31,8 +29,9 @@ import org.apache.coyote.http11.Constants;
 import org.apache.coyote.http11.InputFilter;
 import org.apache.tomcat.util.buf.ByteChunk;
 import org.apache.tomcat.util.buf.HexUtils;
-import org.apache.tomcat.util.http.MimeHeaders;
-import org.apache.tomcat.util.http.parser.HttpParser;
+import org.apache.tomcat.util.http.parser.HttpHeaderParser;
+import org.apache.tomcat.util.http.parser.HttpHeaderParser.HeaderDataSource;
+import org.apache.tomcat.util.http.parser.HttpHeaderParser.HeaderParseStatus;
 import org.apache.tomcat.util.net.ApplicationBufferHandler;
 import org.apache.tomcat.util.res.StringManager;
 
@@ -42,7 +41,7 @@ import org.apache.tomcat.util.res.StringManager;
  *
  * @author Remy Maucherat
  */
-public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler {
+public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler, HeaderDataSource {
 
 private static final StringManager sm = 
StringManager.getManager(ChunkedInputFilter.class);
 
@@ -82,28 +81,15 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
 
 
 /**
- * Flag set to true when the end chunk has been read.
+ * Buffer used to store trailing headers. Is normally in read mode.
  */
-protected boolean endChunk = false;
-
-
-/**
- * Byte chunk used to store trailing headers.
- */
-protected final ByteChunk trailingHeaders = new ByteChunk();
-
-
-/**
- * Flag set to true if the next call to doRead() must parse a CRLF pair
- * before doing anything else.
- */
-protected boolean needCRLFParse = false;
+protected final ByteBuffer trailingHeaders;
 
 
 /**
  * Request being parsed.
  */
-private Request request;
+private final Request request;
 
 
 /**
@@ -112,38 +98,31 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
 private final long maxExtensionSize;
 
 
-/**
- * Limit for trailer size.
- */
-private final int maxTrailerSize;
-
-
-/**
- * Size of extensions processed for this request.
- */
-private long extensionSize;
-
-
 private final int maxSwallowSize;
 
+private final Set allowedTrailerHeaders;
 
-/**
- * Flag that indicates if an error has occurred.
+/*
+ * Parsing state.
  */
-private boolean error;
-
-
-private final Set allowedTrailerHeaders;
+private volatile ParseState parseState = ParseState.CHUNK_HEADER;
+private volatile boolean crFound = false;
+private volatile int chunkSizeDigitsRead = 0;
+private volatile boolean parsingExtension = false;
+private volatile long extensionSize;
+private final HttpHeaderParser httpHeaderParser;
 
 // --- Constructors
 
-public ChunkedInputFilter(int

(tomcat) 02/05: Add a common header parser for headers and trailers

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit e87a432f88663064f066509b53977da2fa2a9bd9
Author: Mark Thomas 
AuthorDate: Fri Apr 26 15:47:23 2024 +0100

Add a common header parser for headers and trailers
---
 .../tomcat/util/http/parser/HttpHeaderParser.java  | 409 +
 .../util/http/parser/LocalStrings.properties   |   3 +
 .../util/http/parser/LocalStrings_fr.properties|   2 +
 .../util/http/parser/LocalStrings_ja.properties|   2 +
 4 files changed, 416 insertions(+)

diff --git a/java/org/apache/tomcat/util/http/parser/HttpHeaderParser.java 
b/java/org/apache/tomcat/util/http/parser/HttpHeaderParser.java
new file mode 100644
index 00..7ef3b8b5ee
--- /dev/null
+++ b/java/org/apache/tomcat/util/http/parser/HttpHeaderParser.java
@@ -0,0 +1,409 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.tomcat.util.http.parser;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import org.apache.tomcat.util.buf.MessageBytes;
+import org.apache.tomcat.util.http.HeaderUtil;
+import org.apache.tomcat.util.http.MimeHeaders;
+import org.apache.tomcat.util.res.StringManager;
+
+public class HttpHeaderParser {
+
+private static final StringManager sm = 
StringManager.getManager(HttpHeaderParser.class);
+
+private static final byte CR = (byte) '\r';
+private static final byte LF = (byte) '\n';
+private static final byte SP = (byte) ' ';
+private static final byte HT = (byte) '\t';
+private static final byte COLON = (byte) ':';
+private static final byte A = (byte) 'A';
+private static final byte a = (byte) 'a';
+private static final byte Z = (byte) 'Z';
+private static final byte LC_OFFSET = A - a;
+
+private final HeaderDataSource source;
+private final MimeHeaders headers;
+private final boolean tolerantEol;
+private final HeaderParseData headerData = new HeaderParseData();
+
+private HeaderParsePosition headerParsePos = 
HeaderParsePosition.HEADER_START;
+private byte prevChr = 0;
+private byte chr = 0;
+
+
+public HttpHeaderParser(HeaderDataSource source, MimeHeaders headers, 
boolean tolerantEol) {
+this.source = source;
+this.headers = headers;
+this.tolerantEol = tolerantEol;
+}
+
+
+public void recycle() {
+chr = 0;
+prevChr = 0;
+headerParsePos = HeaderParsePosition.HEADER_START;
+headerData.recycle();
+}
+
+
+/**
+ * Parse an HTTP header.
+ *
+ * @return One of {@link HeaderParseStatus#NEED_MORE_DATA}, {@link 
HeaderParseStatus#HAVE_MORE_HEADERS} or
+ * {@link HeaderParseStatus#DONE}.
+ *
+ * @throws IOException If an error occurs during the parsing of the headers
+ */
+public HeaderParseStatus parseHeader() throws IOException {
+
+while (headerParsePos == HeaderParsePosition.HEADER_START) {
+
+// Read new bytes if needed
+if (source.getHeaderByteBuffer().position() >= 
source.getHeaderByteBuffer().limit()) {
+if (!source.fillHeaderBuffer()) {
+return HeaderParseStatus.NEED_MORE_DATA;
+}
+}
+
+prevChr = chr;
+chr = source.getHeaderByteBuffer().get();
+
+if (chr == CR && prevChr != CR) {
+// Possible start of CRLF - process the next byte.
+} else if (chr == LF) {
+if (!tolerantEol && prevChr != CR) {
+throw new 
IllegalArgumentException(sm.getString("httpHeaderParser.invalidCrlfNoCR"));
+}
+return HeaderParseStatus.DONE;
+} else {
+if (prevChr == CR) {
+// Must have read two bytes (first was CR, second was not 
LF)
+
source.getHeaderByteBuffer().position(source.getHeaderByteBuffer().position() - 
2);
+} else {
+// Must have only read one byte
+
source.getHeade

(tomcat) branch 10.1.x updated: Fix disastrous cookie-logging patch.

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 783815fd94 Fix disastrous cookie-logging patch.
783815fd94 is described below

commit 783815fd940a4ac2f6d7df7bd056e071f54d7de6
Author: Christopher Schultz 
AuthorDate: Fri Apr 19 10:16:36 2024 -0400

Fix disastrous cookie-logging patch.
---
 java/org/apache/catalina/valves/AbstractAccessLogValve.java | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/valves/AbstractAccessLogValve.java 
b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
index 03acb492fa..5c4e67dde6 100644
--- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
+++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
@@ -1515,17 +1515,19 @@ public abstract class AbstractAccessLogValve extends 
ValveBase implements Access
 if (cookies != null) {
 for (Cookie cookie : cookies) {
 if (cookieNameToLog.equals(cookie.getName())) {
+if (value == null) {
+value = new StringBuilder();
+}
 if (first) {
 first = false;
 } else {
 value.append(',');
 }
-value = new StringBuilder();
 value.append(cookie.getValue());
 }
 }
 }
-if (value.length() == 0) {
+if (value == null) {
 buf.append('-');
 } else {
 escapeAndAppend(value.toString(), buf);


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 03/04: Refactor chunked input filter to use common HTTP header/trailer parser

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 92e3c7a7adc574a859ab70333bf930561dcf1e9d
Author: Mark Thomas 
AuthorDate: Fri Apr 26 15:58:37 2024 +0100

Refactor chunked input filter to use common HTTP header/trailer parser

This adds non-blocking read support for chunked request bodies
---
 java/org/apache/coyote/http11/Http11Processor.java |   2 +-
 .../coyote/http11/filters/ChunkedInputFilter.java  | 576 -
 webapps/docs/changelog.xml |   3 +
 3 files changed, 233 insertions(+), 348 deletions(-)

diff --git a/java/org/apache/coyote/http11/Http11Processor.java 
b/java/org/apache/coyote/http11/Http11Processor.java
index 0692b8da4e..c75243e369 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -169,7 +169,7 @@ public class Http11Processor extends AbstractProcessor {
 
 // Create and add the chunked filters.
 inputBuffer.addFilter(
-new ChunkedInputFilter(protocol.getMaxTrailerSize(), 
protocol.getAllowedTrailerHeadersInternal(),
+new ChunkedInputFilter(request, protocol.getMaxTrailerSize(), 
protocol.getAllowedTrailerHeadersInternal(),
 protocol.getMaxExtensionSize(), 
protocol.getMaxSwallowSize()));
 outputBuffer.addFilter(new ChunkedOutputFilter());
 
diff --git a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 
b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
index 741cd1078b..f350487771 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
@@ -16,11 +16,9 @@
  */
 package org.apache.coyote.http11.filters;
 
-import java.io.EOFException;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
-import java.util.Locale;
 import java.util.Set;
 
 import org.apache.coyote.ActionCode;
@@ -31,8 +29,9 @@ import org.apache.coyote.http11.Constants;
 import org.apache.coyote.http11.InputFilter;
 import org.apache.tomcat.util.buf.ByteChunk;
 import org.apache.tomcat.util.buf.HexUtils;
-import org.apache.tomcat.util.http.MimeHeaders;
-import org.apache.tomcat.util.http.parser.HttpParser;
+import org.apache.tomcat.util.http.parser.HttpHeaderParser;
+import org.apache.tomcat.util.http.parser.HttpHeaderParser.HeaderDataSource;
+import org.apache.tomcat.util.http.parser.HttpHeaderParser.HeaderParseStatus;
 import org.apache.tomcat.util.net.ApplicationBufferHandler;
 import org.apache.tomcat.util.res.StringManager;
 
@@ -42,7 +41,7 @@ import org.apache.tomcat.util.res.StringManager;
  *
  * @author Remy Maucherat
  */
-public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler {
+public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler, HeaderDataSource {
 
 private static final StringManager sm = 
StringManager.getManager(ChunkedInputFilter.class);
 
@@ -82,28 +81,15 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
 
 
 /**
- * Flag set to true when the end chunk has been read.
+ * Buffer used to store trailing headers. Is normally in read mode.
  */
-protected boolean endChunk = false;
-
-
-/**
- * Byte chunk used to store trailing headers.
- */
-protected final ByteChunk trailingHeaders = new ByteChunk();
-
-
-/**
- * Flag set to true if the next call to doRead() must parse a CRLF pair
- * before doing anything else.
- */
-protected boolean needCRLFParse = false;
+protected final ByteBuffer trailingHeaders;
 
 
 /**
  * Request being parsed.
  */
-private Request request;
+private final Request request;
 
 
 /**
@@ -112,38 +98,31 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
 private final long maxExtensionSize;
 
 
-/**
- * Limit for trailer size.
- */
-private final int maxTrailerSize;
-
-
-/**
- * Size of extensions processed for this request.
- */
-private long extensionSize;
-
-
 private final int maxSwallowSize;
 
+private final Set allowedTrailerHeaders;
 
-/**
- * Flag that indicates if an error has occurred.
+/*
+ * Parsing state.
  */
-private boolean error;
-
-
-private final Set allowedTrailerHeaders;
+private volatile ParseState parseState = ParseState.CHUNK_HEADER;
+private volatile boolean crFound = false;
+private volatile int chunkSizeDigitsRead = 0;
+private volatile boolean parsingExtension = false;
+private volatile long extensionSize;
+private final HttpHeaderParser httpHeaderParser;
 
 // --- Constructors
 
-public ChunkedInputFilter(int

(tomcat) 04/04: Additional tests for non-blocking chunked reads

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 24a1932b51f77d8935e690dead32a643b45273f9
Author: Mark Thomas 
AuthorDate: Fri Apr 26 16:02:09 2024 +0100

Additional tests for non-blocking chunked reads
---
 .../catalina/nonblocking/TestNonBlockingAPI.java   | 442 -
 .../http11/filters/TestChunkedInputFilter.java | 176 +++-
 2 files changed, 587 insertions(+), 31 deletions(-)

diff --git a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java 
b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
index eca6090712..7840c56c98 100644
--- a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
+++ b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
@@ -73,6 +73,9 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
 
 private static final Log log = LogFactory.getLog(TestNonBlockingAPI.class);
 
+private static String TRAILER_HEADER_NAME = "x-test";
+private static String TRAILER_HEADER_VALUE = "abcde";
+
 private static final int CHUNK_SIZE = 1024 * 1024;
 private static final int WRITE_SIZE  = CHUNK_SIZE * 10;
 private static final byte[] DATA = new byte[WRITE_SIZE];
@@ -131,7 +134,7 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
 // No file system docBase required
 Context ctx = getProgrammaticRootContext();
 
-NBReadServlet servlet = new NBReadServlet(ignoreIsReady, async);
+NBReadServlet servlet = new NBReadServlet(ignoreIsReady, async, null);
 String servletName = NBReadServlet.class.getName();
 Tomcat.addServlet(ctx, servletName, servlet);
 ctx.addServletMappingDecoded("/", servletName);
@@ -155,31 +158,416 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
 
 
 @Test
-public void testNonBlockingReadChunked() throws Exception {
+public void testNonBlockingReadChunkedNoSplits() throws Exception {
+String[] requestBody = new String[] {
+"14" + SimpleHttpClient.CRLF +
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitBeforeChunkHeader() throws 
Exception {
+String[] requestBody = new String[] {
+"",
+"14" + SimpleHttpClient.CRLF +
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitInChunkHeader() throws 
Exception {
+String[] requestBody = new String[] {
+"1",
+"4" + SimpleHttpClient.CRLF +
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitAfterChunkHeader() throws 
Exception {
+String[] requestBody = new String[] {
+"14",
+SimpleHttpClient.CRLF +
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitInHeaderCrlf() throws Exception 
{
+String[] requestBody = new String[] {
+"14\r",
+"\n" +
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitAfterHeaderCrlf() throws 
Exception {
+String[] requestBody = new String[] {
+"14" + SimpleHttpClient.CRLF,
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitBeforeExtensionDelimter() 
throws Exception {
+String[] requestBody = new String[] {
+"14",
+";a=b" + SimpleHttpClient.CRLF +
+"012345678901FINIS

(tomcat) branch 10.1.x updated (4e92dc6044 -> 24a1932b51)

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from 4e92dc6044 Remove redundant override javadoc
 new a13938a854 Add a method to filter the parsed headers.
 new a5a7c11250 Add a common header parser for headers and trailers
 new 92e3c7a7ad Refactor chunked input filter to use common HTTP 
header/trailer parser
 new 24a1932b51 Additional tests for non-blocking chunked reads

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/org/apache/coyote/http11/Http11Processor.java |   2 +-
 .../coyote/http11/filters/ChunkedInputFilter.java  | 576 -
 java/org/apache/tomcat/util/http/MimeHeaders.java  |  16 +
 .../tomcat/util/http/parser/HttpHeaderParser.java  | 409 +++
 .../util/http/parser/LocalStrings.properties   |   3 +
 .../util/http/parser/LocalStrings_fr.properties|   2 +
 .../util/http/parser/LocalStrings_ja.properties|   2 +
 .../catalina/nonblocking/TestNonBlockingAPI.java   | 442 +++-
 .../http11/filters/TestChunkedInputFilter.java | 176 ++-
 webapps/docs/changelog.xml |   3 +
 10 files changed, 1252 insertions(+), 379 deletions(-)
 create mode 100644 
java/org/apache/tomcat/util/http/parser/HttpHeaderParser.java


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 01/04: Add a method to filter the parsed headers.

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit a13938a854c8f8c86c07acc314b5bfed39a62290
Author: Mark Thomas 
AuthorDate: Fri Apr 26 15:46:32 2024 +0100

Add a method to filter the parsed headers.

This will (eventually) be used by the refactored trailer header parsing
---
 java/org/apache/tomcat/util/http/MimeHeaders.java | 16 
 1 file changed, 16 insertions(+)

diff --git a/java/org/apache/tomcat/util/http/MimeHeaders.java 
b/java/org/apache/tomcat/util/http/MimeHeaders.java
index 48ec279a09..5a67d76f7a 100644
--- a/java/org/apache/tomcat/util/http/MimeHeaders.java
+++ b/java/org/apache/tomcat/util/http/MimeHeaders.java
@@ -23,6 +23,7 @@ import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.tomcat.util.buf.MessageBytes;
 import org.apache.tomcat.util.buf.StringUtils;
@@ -167,6 +168,21 @@ public class MimeHeaders {
 }
 
 
+public void filter(Set allowedHeaders) {
+int j = -1;
+for (int i = 0; i < count; i++) {
+String name = headers[i].getName().toStringType();
+if (allowedHeaders.contains(name)) {
+++j;
+if (j != i) {
+headers[j] = headers[i];
+}
+}
+}
+count = ++j;
+}
+
+
 public void duplicate(MimeHeaders source) throws IOException {
 for (int i = 0; i < source.size(); i++) {
 MimeHeaderField mhf = createHeader();


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 02/04: Add a common header parser for headers and trailers

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit a5a7c112505b471e943967fd33c72299cbe6bb9f
Author: Mark Thomas 
AuthorDate: Fri Apr 26 15:47:23 2024 +0100

Add a common header parser for headers and trailers
---
 .../tomcat/util/http/parser/HttpHeaderParser.java  | 409 +
 .../util/http/parser/LocalStrings.properties   |   3 +
 .../util/http/parser/LocalStrings_fr.properties|   2 +
 .../util/http/parser/LocalStrings_ja.properties|   2 +
 4 files changed, 416 insertions(+)

diff --git a/java/org/apache/tomcat/util/http/parser/HttpHeaderParser.java 
b/java/org/apache/tomcat/util/http/parser/HttpHeaderParser.java
new file mode 100644
index 00..7ef3b8b5ee
--- /dev/null
+++ b/java/org/apache/tomcat/util/http/parser/HttpHeaderParser.java
@@ -0,0 +1,409 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.tomcat.util.http.parser;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import org.apache.tomcat.util.buf.MessageBytes;
+import org.apache.tomcat.util.http.HeaderUtil;
+import org.apache.tomcat.util.http.MimeHeaders;
+import org.apache.tomcat.util.res.StringManager;
+
+public class HttpHeaderParser {
+
+private static final StringManager sm = 
StringManager.getManager(HttpHeaderParser.class);
+
+private static final byte CR = (byte) '\r';
+private static final byte LF = (byte) '\n';
+private static final byte SP = (byte) ' ';
+private static final byte HT = (byte) '\t';
+private static final byte COLON = (byte) ':';
+private static final byte A = (byte) 'A';
+private static final byte a = (byte) 'a';
+private static final byte Z = (byte) 'Z';
+private static final byte LC_OFFSET = A - a;
+
+private final HeaderDataSource source;
+private final MimeHeaders headers;
+private final boolean tolerantEol;
+private final HeaderParseData headerData = new HeaderParseData();
+
+private HeaderParsePosition headerParsePos = 
HeaderParsePosition.HEADER_START;
+private byte prevChr = 0;
+private byte chr = 0;
+
+
+public HttpHeaderParser(HeaderDataSource source, MimeHeaders headers, 
boolean tolerantEol) {
+this.source = source;
+this.headers = headers;
+this.tolerantEol = tolerantEol;
+}
+
+
+public void recycle() {
+chr = 0;
+prevChr = 0;
+headerParsePos = HeaderParsePosition.HEADER_START;
+headerData.recycle();
+}
+
+
+/**
+ * Parse an HTTP header.
+ *
+ * @return One of {@link HeaderParseStatus#NEED_MORE_DATA}, {@link 
HeaderParseStatus#HAVE_MORE_HEADERS} or
+ * {@link HeaderParseStatus#DONE}.
+ *
+ * @throws IOException If an error occurs during the parsing of the headers
+ */
+public HeaderParseStatus parseHeader() throws IOException {
+
+while (headerParsePos == HeaderParsePosition.HEADER_START) {
+
+// Read new bytes if needed
+if (source.getHeaderByteBuffer().position() >= 
source.getHeaderByteBuffer().limit()) {
+if (!source.fillHeaderBuffer()) {
+return HeaderParseStatus.NEED_MORE_DATA;
+}
+}
+
+prevChr = chr;
+chr = source.getHeaderByteBuffer().get();
+
+if (chr == CR && prevChr != CR) {
+// Possible start of CRLF - process the next byte.
+} else if (chr == LF) {
+if (!tolerantEol && prevChr != CR) {
+throw new 
IllegalArgumentException(sm.getString("httpHeaderParser.invalidCrlfNoCR"));
+}
+return HeaderParseStatus.DONE;
+} else {
+if (prevChr == CR) {
+// Must have read two bytes (first was CR, second was not 
LF)
+
source.getHeaderByteBuffer().position(source.getHeaderByteBuffer().position() - 
2);
+} else {
+// Must have only read one byte
+
source.getHeade

(tomcat) 02/03: Refactor HTTP header parsing to use common parser

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit e5acf2cf0f745350c85d81532826d92b1882469a
Author: Mark Thomas 
AuthorDate: Fri Apr 26 16:06:52 2024 +0100

Refactor HTTP header parsing to use common parser
---
 java/org/apache/coyote/http11/Constants.java   |  12 +
 .../apache/coyote/http11/Http11InputBuffer.java| 375 ++---
 .../apache/coyote/http11/LocalStrings.properties   |   2 -
 .../coyote/http11/LocalStrings_fr.properties   |   2 -
 .../coyote/http11/LocalStrings_ja.properties   |   2 -
 .../coyote/http11/LocalStrings_ko.properties   |   1 -
 .../coyote/http11/LocalStrings_zh_CN.properties|   1 -
 webapps/docs/changelog.xml |   3 +
 8 files changed, 43 insertions(+), 355 deletions(-)

diff --git a/java/org/apache/coyote/http11/Constants.java 
b/java/org/apache/coyote/http11/Constants.java
index 700834c7ad..b580819b28 100644
--- a/java/org/apache/coyote/http11/Constants.java
+++ b/java/org/apache/coyote/http11/Constants.java
@@ -72,19 +72,28 @@ public final class Constants {
 
 /**
  * 'A'.
+ *
+ * @deprecated Unused. Will be removed in Tomcat 11.
  */
+@Deprecated
 public static final byte A = (byte) 'A';
 
 
 /**
  * 'a'.
+ *
+ * @deprecated Unused. Will be removed in Tomcat 11.
  */
+@Deprecated
 public static final byte a = (byte) 'a';
 
 
 /**
  * 'Z'.
+ *
+ * @deprecated Unused. Will be removed in Tomcat 11.
  */
+@Deprecated
 public static final byte Z = (byte) 'Z';
 
 
@@ -96,7 +105,10 @@ public final class Constants {
 
 /**
  * Lower case offset.
+ *
+ * @deprecated Unused. Will be removed in Tomcat 11.
  */
+@Deprecated
 public static final byte LC_OFFSET = A - a;
 
 
diff --git a/java/org/apache/coyote/http11/Http11InputBuffer.java 
b/java/org/apache/coyote/http11/Http11InputBuffer.java
index fea3b2fe46..c047a26701 100644
--- a/java/org/apache/coyote/http11/Http11InputBuffer.java
+++ b/java/org/apache/coyote/http11/Http11InputBuffer.java
@@ -27,9 +27,10 @@ import org.apache.coyote.InputBuffer;
 import org.apache.coyote.Request;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.util.buf.MessageBytes;
 import org.apache.tomcat.util.http.HeaderUtil;
-import org.apache.tomcat.util.http.MimeHeaders;
+import org.apache.tomcat.util.http.parser.HttpHeaderParser;
+import org.apache.tomcat.util.http.parser.HttpHeaderParser.HeaderDataSource;
+import org.apache.tomcat.util.http.parser.HttpHeaderParser.HeaderParseStatus;
 import org.apache.tomcat.util.http.parser.HttpParser;
 import org.apache.tomcat.util.net.ApplicationBufferHandler;
 import org.apache.tomcat.util.net.SocketWrapperBase;
@@ -38,7 +39,7 @@ import org.apache.tomcat.util.res.StringManager;
 /**
  * InputBuffer for HTTP that provides request header parsing as well as 
transfer encoding.
  */
-public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler {
+public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler, HeaderDataSource {
 
 // -- Constants
 
@@ -59,12 +60,6 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
 private final Request request;
 
 
-/**
- * Headers of the associated request.
- */
-private final MimeHeaders headers;
-
-
 /**
  * State.
  */
@@ -129,9 +124,8 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
 private boolean parsingRequestLineEol = false;
 private int parsingRequestLineStart = 0;
 private int parsingRequestLineQPos = -1;
-private HeaderParsePosition headerParsePos;
-private final HeaderParseData headerData = new HeaderParseData();
 private final HttpParser httpParser;
+private final HttpHeaderParser httpHeaderParser;
 
 /**
  * Maximum allowed size of the HTTP request line plus headers plus any 
leading blank lines.
@@ -149,7 +143,6 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
 public Http11InputBuffer(Request request, int headerBufferSize, HttpParser 
httpParser) {
 
 this.request = request;
-headers = request.getMimeHeaders();
 
 this.headerBufferSize = headerBufferSize;
 this.httpParser = httpParser;
@@ -158,13 +151,15 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
 activeFilters = new InputFilter[0];
 lastActiveFilter = -1;
 
-parsingHeader = true;
 parsingRequestLine = true;
 parsingRequestLinePhase = 0;
 parsingRequestLineEol = false;
 parsingRequestLineStart = 0;
 parsingRequestLineQPos = -1;
-headerParsePos

(tomcat) 01/03: Add changelog entry

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit a5c31c0f14c7598c3574df1159f560b01d3f9fba
Author: Mark Thomas 
AuthorDate: Fri Apr 26 16:49:32 2024 +0100

Add changelog entry
---
 webapps/docs/changelog.xml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 46f409d856..044a6a19fc 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -183,6 +183,9 @@
 Ensure that multiple instances of the same trailer field are handled
 correctly. (markt)
   
+  
+Fix non-blocking reads of chunked request bodies. (markt)
+  
 
   
   


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 03/03: Remove deprecated code

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 8081af2086a89618a75a7091835fe56d2fc19364
Author: Mark Thomas 
AuthorDate: Fri Apr 26 16:07:21 2024 +0100

Remove deprecated code
---
 java/org/apache/coyote/http11/Constants.java | 36 
 1 file changed, 36 deletions(-)

diff --git a/java/org/apache/coyote/http11/Constants.java 
b/java/org/apache/coyote/http11/Constants.java
index b580819b28..7831aa5494 100644
--- a/java/org/apache/coyote/http11/Constants.java
+++ b/java/org/apache/coyote/http11/Constants.java
@@ -70,48 +70,12 @@ public final class Constants {
 public static final byte SEMI_COLON = (byte) ';';
 
 
-/**
- * 'A'.
- *
- * @deprecated Unused. Will be removed in Tomcat 11.
- */
-@Deprecated
-public static final byte A = (byte) 'A';
-
-
-/**
- * 'a'.
- *
- * @deprecated Unused. Will be removed in Tomcat 11.
- */
-@Deprecated
-public static final byte a = (byte) 'a';
-
-
-/**
- * 'Z'.
- *
- * @deprecated Unused. Will be removed in Tomcat 11.
- */
-@Deprecated
-public static final byte Z = (byte) 'Z';
-
-
 /**
  * '?'.
  */
 public static final byte QUESTION = (byte) '?';
 
 
-/**
- * Lower case offset.
- *
- * @deprecated Unused. Will be removed in Tomcat 11.
- */
-@Deprecated
-public static final byte LC_OFFSET = A - a;
-
-
 /* Various constant "strings" */
 public static final String CONNECTION = "Connection";
 public static final String CLOSE = "close";


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch main updated (8d6420831f -> 8081af2086)

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from 8d6420831f Fix test failure on Windows
 new a5c31c0f14 Add changelog entry
 new e5acf2cf0f Refactor HTTP header parsing to use common parser
 new 8081af2086 Remove deprecated code

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/org/apache/coyote/http11/Constants.java   |  24 --
 .../apache/coyote/http11/Http11InputBuffer.java| 375 ++---
 .../apache/coyote/http11/LocalStrings.properties   |   2 -
 .../coyote/http11/LocalStrings_fr.properties   |   2 -
 .../coyote/http11/LocalStrings_ja.properties   |   2 -
 .../coyote/http11/LocalStrings_ko.properties   |   1 -
 .../coyote/http11/LocalStrings_zh_CN.properties|   1 -
 webapps/docs/changelog.xml |   6 +
 8 files changed, 34 insertions(+), 379 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch main updated: Fix test failure on Windows

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
 new 8d6420831f Fix test failure on Windows
8d6420831f is described below

commit 8d6420831f071e5ceefedbd8f692764b3836fbeb
Author: Mark Thomas 
AuthorDate: Fri Apr 26 17:04:07 2024 +0100

Fix test failure on Windows
---
 test/org/apache/coyote/http11/filters/TestChunkedInputFilter.java | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/test/org/apache/coyote/http11/filters/TestChunkedInputFilter.java 
b/test/org/apache/coyote/http11/filters/TestChunkedInputFilter.java
index 9a44b02b08..b264092ed0 100644
--- a/test/org/apache/coyote/http11/filters/TestChunkedInputFilter.java
+++ b/test/org/apache/coyote/http11/filters/TestChunkedInputFilter.java
@@ -697,7 +697,11 @@ public class TestChunkedInputFilter extends TomcatBaseTest 
{
 
 client.setRequest(request);
 client.connect();
-client.processRequest();
+try {
+client.processRequest();
+} catch (IOException ioe) {
+// Ignore - Triggered by connection being dropped after error
+}
 // NIO2 may (will?) return null here
 String responseLine = client.getResponseLine();
 if (responseLine == null) {


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 01/04: Add a method to filter the parsed headers.

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 43622a07488a297dbd8ad4d0c72d2ff4d8c24f90
Author: Mark Thomas 
AuthorDate: Fri Apr 26 15:46:32 2024 +0100

Add a method to filter the parsed headers.

This will (eventually) be used by the refactored trailer header parsing
---
 java/org/apache/tomcat/util/http/MimeHeaders.java | 16 
 1 file changed, 16 insertions(+)

diff --git a/java/org/apache/tomcat/util/http/MimeHeaders.java 
b/java/org/apache/tomcat/util/http/MimeHeaders.java
index cfc419199c..43b089451d 100644
--- a/java/org/apache/tomcat/util/http/MimeHeaders.java
+++ b/java/org/apache/tomcat/util/http/MimeHeaders.java
@@ -23,6 +23,7 @@ import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.tomcat.util.buf.MessageBytes;
 import org.apache.tomcat.util.buf.StringUtils;
@@ -162,6 +163,21 @@ public class MimeHeaders {
 }
 
 
+public void filter(Set allowedHeaders) {
+int j = -1;
+for (int i = 0; i < count; i++) {
+String name = headers[i].getName().toStringType();
+if (allowedHeaders.contains(name)) {
+++j;
+if (j != i) {
+headers[j] = headers[i];
+}
+}
+}
+count = ++j;
+}
+
+
 public void duplicate(MimeHeaders source) throws IOException {
 for (int i = 0; i < source.size(); i++) {
 MimeHeaderField mhf = createHeader();


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch main updated (c1664157ce -> b25db176fb)

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from c1664157ce Remove redundant override javadoc
 new 43622a0748 Add a method to filter the parsed headers.
 new 3443bffb40 Add a common header parser for headers and trailers
 new cbed8e1836 Refactor chunked input filter to use common HTTP 
header/trailer parser
 new b25db176fb Additional tests for non-blocking chunked reads

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/org/apache/coyote/http11/Http11Processor.java |   2 +-
 .../coyote/http11/filters/ChunkedInputFilter.java  | 576 -
 java/org/apache/tomcat/util/http/MimeHeaders.java  |  16 +
 .../tomcat/util/http/parser/HttpHeaderParser.java  | 409 +++
 .../util/http/parser/LocalStrings.properties   |   3 +
 .../util/http/parser/LocalStrings_fr.properties|   2 +
 .../util/http/parser/LocalStrings_ja.properties|   2 +
 .../catalina/nonblocking/TestNonBlockingAPI.java   | 442 +++-
 .../http11/filters/TestChunkedInputFilter.java | 172 +-
 9 files changed, 1245 insertions(+), 379 deletions(-)
 create mode 100644 
java/org/apache/tomcat/util/http/parser/HttpHeaderParser.java


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 02/04: Add a common header parser for headers and trailers

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 3443bffb40c22b2c107e277575e02f9f4e688e3d
Author: Mark Thomas 
AuthorDate: Fri Apr 26 15:47:23 2024 +0100

Add a common header parser for headers and trailers
---
 .../tomcat/util/http/parser/HttpHeaderParser.java  | 409 +
 .../util/http/parser/LocalStrings.properties   |   3 +
 .../util/http/parser/LocalStrings_fr.properties|   2 +
 .../util/http/parser/LocalStrings_ja.properties|   2 +
 4 files changed, 416 insertions(+)

diff --git a/java/org/apache/tomcat/util/http/parser/HttpHeaderParser.java 
b/java/org/apache/tomcat/util/http/parser/HttpHeaderParser.java
new file mode 100644
index 00..7ef3b8b5ee
--- /dev/null
+++ b/java/org/apache/tomcat/util/http/parser/HttpHeaderParser.java
@@ -0,0 +1,409 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.tomcat.util.http.parser;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import org.apache.tomcat.util.buf.MessageBytes;
+import org.apache.tomcat.util.http.HeaderUtil;
+import org.apache.tomcat.util.http.MimeHeaders;
+import org.apache.tomcat.util.res.StringManager;
+
+public class HttpHeaderParser {
+
+private static final StringManager sm = 
StringManager.getManager(HttpHeaderParser.class);
+
+private static final byte CR = (byte) '\r';
+private static final byte LF = (byte) '\n';
+private static final byte SP = (byte) ' ';
+private static final byte HT = (byte) '\t';
+private static final byte COLON = (byte) ':';
+private static final byte A = (byte) 'A';
+private static final byte a = (byte) 'a';
+private static final byte Z = (byte) 'Z';
+private static final byte LC_OFFSET = A - a;
+
+private final HeaderDataSource source;
+private final MimeHeaders headers;
+private final boolean tolerantEol;
+private final HeaderParseData headerData = new HeaderParseData();
+
+private HeaderParsePosition headerParsePos = 
HeaderParsePosition.HEADER_START;
+private byte prevChr = 0;
+private byte chr = 0;
+
+
+public HttpHeaderParser(HeaderDataSource source, MimeHeaders headers, 
boolean tolerantEol) {
+this.source = source;
+this.headers = headers;
+this.tolerantEol = tolerantEol;
+}
+
+
+public void recycle() {
+chr = 0;
+prevChr = 0;
+headerParsePos = HeaderParsePosition.HEADER_START;
+headerData.recycle();
+}
+
+
+/**
+ * Parse an HTTP header.
+ *
+ * @return One of {@link HeaderParseStatus#NEED_MORE_DATA}, {@link 
HeaderParseStatus#HAVE_MORE_HEADERS} or
+ * {@link HeaderParseStatus#DONE}.
+ *
+ * @throws IOException If an error occurs during the parsing of the headers
+ */
+public HeaderParseStatus parseHeader() throws IOException {
+
+while (headerParsePos == HeaderParsePosition.HEADER_START) {
+
+// Read new bytes if needed
+if (source.getHeaderByteBuffer().position() >= 
source.getHeaderByteBuffer().limit()) {
+if (!source.fillHeaderBuffer()) {
+return HeaderParseStatus.NEED_MORE_DATA;
+}
+}
+
+prevChr = chr;
+chr = source.getHeaderByteBuffer().get();
+
+if (chr == CR && prevChr != CR) {
+// Possible start of CRLF - process the next byte.
+} else if (chr == LF) {
+if (!tolerantEol && prevChr != CR) {
+throw new 
IllegalArgumentException(sm.getString("httpHeaderParser.invalidCrlfNoCR"));
+}
+return HeaderParseStatus.DONE;
+} else {
+if (prevChr == CR) {
+// Must have read two bytes (first was CR, second was not 
LF)
+
source.getHeaderByteBuffer().position(source.getHeaderByteBuffer().position() - 
2);
+} else {
+// Must have only read one byte
+
source.getHeaderByteBuffer

(tomcat) 04/04: Additional tests for non-blocking chunked reads

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit b25db176fb138af7086a1ea5a1473b03b58747e8
Author: Mark Thomas 
AuthorDate: Fri Apr 26 16:02:09 2024 +0100

Additional tests for non-blocking chunked reads
---
 .../catalina/nonblocking/TestNonBlockingAPI.java   | 442 -
 .../http11/filters/TestChunkedInputFilter.java | 172 +++-
 2 files changed, 583 insertions(+), 31 deletions(-)

diff --git a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java 
b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
index 66fbf2ac12..7402e69645 100644
--- a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
+++ b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
@@ -74,6 +74,9 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
 
 private static final Log log = LogFactory.getLog(TestNonBlockingAPI.class);
 
+private static String TRAILER_HEADER_NAME = "x-test";
+private static String TRAILER_HEADER_VALUE = "abcde";
+
 private static final int CHUNK_SIZE = 1024 * 1024;
 private static final int WRITE_SIZE  = CHUNK_SIZE * 10;
 private static final byte[] DATA = new byte[WRITE_SIZE];
@@ -132,7 +135,7 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
 // No file system docBase required
 Context ctx = getProgrammaticRootContext();
 
-NBReadServlet servlet = new NBReadServlet(ignoreIsReady, async);
+NBReadServlet servlet = new NBReadServlet(ignoreIsReady, async, null);
 String servletName = NBReadServlet.class.getName();
 Tomcat.addServlet(ctx, servletName, servlet);
 ctx.addServletMappingDecoded("/", servletName);
@@ -156,31 +159,416 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
 
 
 @Test
-public void testNonBlockingReadChunked() throws Exception {
+public void testNonBlockingReadChunkedNoSplits() throws Exception {
+String[] requestBody = new String[] {
+"14" + SimpleHttpClient.CRLF +
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitBeforeChunkHeader() throws 
Exception {
+String[] requestBody = new String[] {
+"",
+"14" + SimpleHttpClient.CRLF +
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitInChunkHeader() throws 
Exception {
+String[] requestBody = new String[] {
+"1",
+"4" + SimpleHttpClient.CRLF +
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitAfterChunkHeader() throws 
Exception {
+String[] requestBody = new String[] {
+"14",
+SimpleHttpClient.CRLF +
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitInHeaderCrlf() throws Exception 
{
+String[] requestBody = new String[] {
+"14\r",
+"\n" +
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitAfterHeaderCrlf() throws 
Exception {
+String[] requestBody = new String[] {
+"14" + SimpleHttpClient.CRLF,
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitBeforeExtensionDelimter() 
throws Exception {
+String[] requestBody = new String[] {
+"14",
+";a=b" + SimpleHttpClient.CRLF +
+"012345678901FINIS

(tomcat) 03/04: Refactor chunked input filter to use common HTTP header/trailer parser

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit cbed8e1836962d43120b81ae99d8d1b349265749
Author: Mark Thomas 
AuthorDate: Fri Apr 26 15:58:37 2024 +0100

Refactor chunked input filter to use common HTTP header/trailer parser

This adds non-blocking read support for chunked request bodies
---
 java/org/apache/coyote/http11/Http11Processor.java |   2 +-
 .../coyote/http11/filters/ChunkedInputFilter.java  | 576 -
 2 files changed, 230 insertions(+), 348 deletions(-)

diff --git a/java/org/apache/coyote/http11/Http11Processor.java 
b/java/org/apache/coyote/http11/Http11Processor.java
index 3a1897a84b..b2fac4af8c 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -167,7 +167,7 @@ public class Http11Processor extends AbstractProcessor {
 
 // Create and add the chunked filters.
 inputBuffer.addFilter(
-new ChunkedInputFilter(protocol.getMaxTrailerSize(), 
protocol.getAllowedTrailerHeadersInternal(),
+new ChunkedInputFilter(request, protocol.getMaxTrailerSize(), 
protocol.getAllowedTrailerHeadersInternal(),
 protocol.getMaxExtensionSize(), 
protocol.getMaxSwallowSize()));
 outputBuffer.addFilter(new ChunkedOutputFilter());
 
diff --git a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 
b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
index 741cd1078b..f350487771 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
@@ -16,11 +16,9 @@
  */
 package org.apache.coyote.http11.filters;
 
-import java.io.EOFException;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
-import java.util.Locale;
 import java.util.Set;
 
 import org.apache.coyote.ActionCode;
@@ -31,8 +29,9 @@ import org.apache.coyote.http11.Constants;
 import org.apache.coyote.http11.InputFilter;
 import org.apache.tomcat.util.buf.ByteChunk;
 import org.apache.tomcat.util.buf.HexUtils;
-import org.apache.tomcat.util.http.MimeHeaders;
-import org.apache.tomcat.util.http.parser.HttpParser;
+import org.apache.tomcat.util.http.parser.HttpHeaderParser;
+import org.apache.tomcat.util.http.parser.HttpHeaderParser.HeaderDataSource;
+import org.apache.tomcat.util.http.parser.HttpHeaderParser.HeaderParseStatus;
 import org.apache.tomcat.util.net.ApplicationBufferHandler;
 import org.apache.tomcat.util.res.StringManager;
 
@@ -42,7 +41,7 @@ import org.apache.tomcat.util.res.StringManager;
  *
  * @author Remy Maucherat
  */
-public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler {
+public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler, HeaderDataSource {
 
 private static final StringManager sm = 
StringManager.getManager(ChunkedInputFilter.class);
 
@@ -82,28 +81,15 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
 
 
 /**
- * Flag set to true when the end chunk has been read.
+ * Buffer used to store trailing headers. Is normally in read mode.
  */
-protected boolean endChunk = false;
-
-
-/**
- * Byte chunk used to store trailing headers.
- */
-protected final ByteChunk trailingHeaders = new ByteChunk();
-
-
-/**
- * Flag set to true if the next call to doRead() must parse a CRLF pair
- * before doing anything else.
- */
-protected boolean needCRLFParse = false;
+protected final ByteBuffer trailingHeaders;
 
 
 /**
  * Request being parsed.
  */
-private Request request;
+private final Request request;
 
 
 /**
@@ -112,38 +98,31 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
 private final long maxExtensionSize;
 
 
-/**
- * Limit for trailer size.
- */
-private final int maxTrailerSize;
-
-
-/**
- * Size of extensions processed for this request.
- */
-private long extensionSize;
-
-
 private final int maxSwallowSize;
 
+private final Set allowedTrailerHeaders;
 
-/**
- * Flag that indicates if an error has occurred.
+/*
+ * Parsing state.
  */
-private boolean error;
-
-
-private final Set allowedTrailerHeaders;
+private volatile ParseState parseState = ParseState.CHUNK_HEADER;
+private volatile boolean crFound = false;
+private volatile int chunkSizeDigitsRead = 0;
+private volatile boolean parsingExtension = false;
+private volatile long extensionSize;
+private final HttpHeaderParser httpHeaderParser;
 
 // --- Constructors
 
-public ChunkedInputFilter(int maxTrailerSize, Set 
allowedTrailerHeaders,
+public

(tomcat) branch 10.1.x updated: Remove incorrect Javadoc comment

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
 new aa49b80a35 Remove incorrect Javadoc comment
aa49b80a35 is described below

commit aa49b80a35ac498d7500281cbf156f0218c18e90
Author: Mark Thomas 
AuthorDate: Thu Apr 25 18:29:10 2024 +0100

Remove incorrect Javadoc comment
---
 java/org/apache/coyote/http11/filters/ChunkedInputFilter.java | 4 
 1 file changed, 4 deletions(-)

diff --git a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 
b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
index 83bccbd161..741cd1078b 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
@@ -299,10 +299,6 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
 }
 
 
-/**
- * Return the name of the associated encoding; Here, the value is
- * "identity".
- */
 @Override
 public ByteChunk getEncodingName() {
 return ENCODING;


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch main updated: Remove incorrect Javadoc comment

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
 new a8dad1dd05 Remove incorrect Javadoc comment
a8dad1dd05 is described below

commit a8dad1dd05605ced9288ddede1b71e26234b9799
Author: Mark Thomas 
AuthorDate: Thu Apr 25 18:29:10 2024 +0100

Remove incorrect Javadoc comment
---
 java/org/apache/coyote/http11/filters/ChunkedInputFilter.java | 4 
 1 file changed, 4 deletions(-)

diff --git a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 
b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
index 83bccbd161..741cd1078b 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
@@ -299,10 +299,6 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
 }
 
 
-/**
- * Return the name of the associated encoding; Here, the value is
- * "identity".
- */
 @Override
 public ByteChunk getEncodingName() {
 return ENCODING;


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 9.0.x updated: Remove incorrect Javadoc comment

2024-04-26 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt 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 044cf6d9e2 Remove incorrect Javadoc comment
044cf6d9e2 is described below

commit 044cf6d9e23084ff444b0638653e44c7b949d8f3
Author: Mark Thomas 
AuthorDate: Thu Apr 25 18:29:10 2024 +0100

Remove incorrect Javadoc comment
---
 java/org/apache/coyote/http11/filters/ChunkedInputFilter.java | 4 
 1 file changed, 4 deletions(-)

diff --git a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 
b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
index 83bccbd161..741cd1078b 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
@@ -299,10 +299,6 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
 }
 
 
-/**
- * Return the name of the associated encoding; Here, the value is
- * "identity".
- */
 @Override
 public ByteChunk getEncodingName() {
 return ENCODING;


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 9.0.x updated: Fix typo

2024-04-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt 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 cb241847f4 Fix typo
cb241847f4 is described below

commit cb241847f4f6bd0e210228f18039afb6cbaee17e
Author: Mark Thomas 
AuthorDate: Thu Apr 25 14:44:43 2024 +0100

Fix typo
---
 test/org/apache/coyote/http11/TestHttp11Processor.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/org/apache/coyote/http11/TestHttp11Processor.java 
b/test/org/apache/coyote/http11/TestHttp11Processor.java
index 55172aef19..a26a7f96a5 100644
--- a/test/org/apache/coyote/http11/TestHttp11Processor.java
+++ b/test/org/apache/coyote/http11/TestHttp11Processor.java
@@ -737,7 +737,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 public void run() {
 if (delayAsyncThread) {
 // Makes the difference between calling complete before
-// the request body is received of after.
+// the request body is received or after.
 try {
 Thread.sleep(1500);
 } catch (InterruptedException e) {


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 10.1.x updated: Fix typo

2024-04-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 4e7335771e Fix typo
4e7335771e is described below

commit 4e7335771e40fa5c2a05f649b2e5938db5b44ae3
Author: Mark Thomas 
AuthorDate: Thu Apr 25 14:44:43 2024 +0100

Fix typo
---
 test/org/apache/coyote/http11/TestHttp11Processor.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/org/apache/coyote/http11/TestHttp11Processor.java 
b/test/org/apache/coyote/http11/TestHttp11Processor.java
index d84ace56bf..65b2015c71 100644
--- a/test/org/apache/coyote/http11/TestHttp11Processor.java
+++ b/test/org/apache/coyote/http11/TestHttp11Processor.java
@@ -737,7 +737,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 public void run() {
 if (delayAsyncThread) {
 // Makes the difference between calling complete before
-// the request body is received of after.
+// the request body is received or after.
 try {
 Thread.sleep(1500);
 } catch (InterruptedException e) {


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch main updated: Fix typo

2024-04-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
 new 9955b03b6a Fix typo
9955b03b6a is described below

commit 9955b03b6adcfe36ac78b5e1cf416672e346f16a
Author: Mark Thomas 
AuthorDate: Thu Apr 25 14:44:43 2024 +0100

Fix typo
---
 test/org/apache/coyote/http11/TestHttp11Processor.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/org/apache/coyote/http11/TestHttp11Processor.java 
b/test/org/apache/coyote/http11/TestHttp11Processor.java
index dfa05bada4..857d51185d 100644
--- a/test/org/apache/coyote/http11/TestHttp11Processor.java
+++ b/test/org/apache/coyote/http11/TestHttp11Processor.java
@@ -737,7 +737,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 public void run() {
 if (delayAsyncThread) {
 // Makes the difference between calling complete before
-// the request body is received of after.
+// the request body is received or after.
 try {
 Thread.sleep(1500);
 } catch (InterruptedException e) {


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 10.1.x updated: Refactor storage of trailer fields to use MimeHeaders

2024-04-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 7883d8d913 Refactor storage of trailer fields to use MimeHeaders
7883d8d913 is described below

commit 7883d8d913ce3ab859e5f7448df76bc40e7c84e9
Author: Mark Thomas 
AuthorDate: Wed Apr 24 19:47:33 2024 +0100

Refactor storage of trailer fields to use MimeHeaders
---
 java/org/apache/catalina/connector/Request.java   |  4 ++--
 java/org/apache/coyote/Request.java   | 15 +--
 .../coyote/http11/filters/ChunkedInputFilter.java |  6 +++---
 java/org/apache/coyote/http2/Stream.java  |  2 +-
 java/org/apache/tomcat/util/buf/StringUtils.java  |  5 +
 java/org/apache/tomcat/util/http/MimeHeaders.java | 19 +++
 webapps/docs/changelog.xml|  8 
 7 files changed, 51 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/catalina/connector/Request.java 
b/java/org/apache/catalina/connector/Request.java
index 234275e158..c043e31b32 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -1839,8 +1839,8 @@ public class Request implements HttpServletRequest {
 if (!isTrailerFieldsReady()) {
 throw new 
IllegalStateException(sm.getString("coyoteRequest.trailersNotReady"));
 }
-Map result = new 
HashMap<>(coyoteRequest.getTrailerFields());
-return result;
+// No need for a defensive copy since a new Map is returned for every 
call.
+return coyoteRequest.getTrailerFields();
 }
 
 
diff --git a/java/org/apache/coyote/Request.java 
b/java/org/apache/coyote/Request.java
index 5059b875b4..f455585d52 100644
--- a/java/org/apache/coyote/Request.java
+++ b/java/org/apache/coyote/Request.java
@@ -110,7 +110,7 @@ public final class Request {
 private final MessageBytes localAddrMB = MessageBytes.newInstance();
 
 private final MimeHeaders headers = new MimeHeaders();
-private final Map trailerFields = new HashMap<>();
+private final MimeHeaders trailerFields = new MimeHeaders();
 
 /**
  * Path parameters
@@ -296,6 +296,11 @@ public final class Request {
 
 
 public Map getTrailerFields() {
+return trailerFields.toMap();
+}
+
+
+public MimeHeaders getMimeTrailerFields() {
 return trailerFields;
 }
 
@@ -769,7 +774,13 @@ public final class Request {
 characterEncoding = null;
 expectation = false;
 headers.recycle();
-trailerFields.clear();
+trailerFields.recycle();
+/*
+ *  Trailer fields are limited in size by bytes. The following call 
ensures that any request with a large number
+ *  of small trailer fields doesn't result in a long lasting, large 
array of headers inside the MimeHeader
+ *  instance.
+ */
+trailerFields.setLimit(MimeHeaders.DEFAULT_HEADER_SIZE);
 serverNameMB.recycle();
 serverPort = -1;
 localAddrMB.recycle();
diff --git a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 
b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
index c0b74a185f..83bccbd161 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
 import java.util.Locale;
-import java.util.Map;
 import java.util.Set;
 
 import org.apache.coyote.ActionCode;
@@ -32,6 +31,7 @@ import org.apache.coyote.http11.Constants;
 import org.apache.coyote.http11.InputFilter;
 import org.apache.tomcat.util.buf.ByteChunk;
 import org.apache.tomcat.util.buf.HexUtils;
+import org.apache.tomcat.util.http.MimeHeaders;
 import org.apache.tomcat.util.http.parser.HttpParser;
 import org.apache.tomcat.util.net.ApplicationBufferHandler;
 import org.apache.tomcat.util.res.StringManager;
@@ -467,7 +467,7 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
  * implementation wasn't viewed as practical.
  */
 
-Map headers = request.getTrailerFields();
+MimeHeaders headers = request.getMimeTrailerFields();
 
 byte chr = 0;
 
@@ -629,7 +629,7 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
 String value = new String(trailingHeaders.getBytes(), colonPos,
 lastSignificantChar - colonPos, 
StandardCharsets.ISO_8859_1);
 
-headers.put(headerName, value);
+headers.addValue(headerName).setString(value);
 }
 
 return true;
diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/h

(tomcat) branch 9.0.x updated: Refactor storage of trailer fields to use MimeHeaders

2024-04-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt 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 6c72f6ee5c Refactor storage of trailer fields to use MimeHeaders
6c72f6ee5c is described below

commit 6c72f6ee5cceee0fc52fe5909d23321e62e02181
Author: Mark Thomas 
AuthorDate: Wed Apr 24 19:47:33 2024 +0100

Refactor storage of trailer fields to use MimeHeaders
---
 java/org/apache/catalina/connector/Request.java   |  4 ++--
 java/org/apache/coyote/Request.java   | 15 +--
 .../coyote/http11/filters/ChunkedInputFilter.java |  6 +++---
 java/org/apache/coyote/http2/Stream.java  |  2 +-
 java/org/apache/tomcat/util/buf/StringUtils.java  |  5 +
 java/org/apache/tomcat/util/http/MimeHeaders.java | 19 +++
 webapps/docs/changelog.xml|  8 
 7 files changed, 51 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/catalina/connector/Request.java 
b/java/org/apache/catalina/connector/Request.java
index c28a9bf216..19fb94f889 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -1870,8 +1870,8 @@ public class Request implements HttpServletRequest {
 if (!isTrailerFieldsReady()) {
 throw new 
IllegalStateException(sm.getString("coyoteRequest.trailersNotReady"));
 }
-Map result = new 
HashMap<>(coyoteRequest.getTrailerFields());
-return result;
+// No need for a defensive copy since a new Map is returned for every 
call.
+return coyoteRequest.getTrailerFields();
 }
 
 
diff --git a/java/org/apache/coyote/Request.java 
b/java/org/apache/coyote/Request.java
index e6f1ea8ce2..72eb5171ff 100644
--- a/java/org/apache/coyote/Request.java
+++ b/java/org/apache/coyote/Request.java
@@ -94,7 +94,7 @@ public final class Request {
 private final MessageBytes localAddrMB = MessageBytes.newInstance();
 
 private final MimeHeaders headers = new MimeHeaders();
-private final Map trailerFields = new HashMap<>();
+private final MimeHeaders trailerFields = new MimeHeaders();
 
 /**
  * Path parameters
@@ -280,6 +280,11 @@ public final class Request {
 
 
 public Map getTrailerFields() {
+return trailerFields.toMap();
+}
+
+
+public MimeHeaders getMimeTrailerFields() {
 return trailerFields;
 }
 
@@ -721,7 +726,13 @@ public final class Request {
 characterEncoding = null;
 expectation = false;
 headers.recycle();
-trailerFields.clear();
+trailerFields.recycle();
+/*
+ *  Trailer fields are limited in size by bytes. The following call 
ensures that any request with a large number
+ *  of small trailer fields doesn't result in a long lasting, large 
array of headers inside the MimeHeader
+ *  instance.
+ */
+trailerFields.setLimit(MimeHeaders.DEFAULT_HEADER_SIZE);
 serverNameMB.recycle();
 serverPort = -1;
 localAddrMB.recycle();
diff --git a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 
b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
index c0b74a185f..83bccbd161 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
 import java.util.Locale;
-import java.util.Map;
 import java.util.Set;
 
 import org.apache.coyote.ActionCode;
@@ -32,6 +31,7 @@ import org.apache.coyote.http11.Constants;
 import org.apache.coyote.http11.InputFilter;
 import org.apache.tomcat.util.buf.ByteChunk;
 import org.apache.tomcat.util.buf.HexUtils;
+import org.apache.tomcat.util.http.MimeHeaders;
 import org.apache.tomcat.util.http.parser.HttpParser;
 import org.apache.tomcat.util.net.ApplicationBufferHandler;
 import org.apache.tomcat.util.res.StringManager;
@@ -467,7 +467,7 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
  * implementation wasn't viewed as practical.
  */
 
-Map headers = request.getTrailerFields();
+MimeHeaders headers = request.getMimeTrailerFields();
 
 byte chr = 0;
 
@@ -629,7 +629,7 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
 String value = new String(trailingHeaders.getBytes(), colonPos,
 lastSignificantChar - colonPos, 
StandardCharsets.ISO_8859_1);
 
-headers.put(headerName, value);
+headers.addValue(headerName).setString(value);
 }
 
 return true;
diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/http2/Stream

(tomcat) branch main updated: Refactor storage of trailer fields to use MimeHeaders

2024-04-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
 new f087decbc9 Refactor storage of trailer fields to use MimeHeaders
f087decbc9 is described below

commit f087decbc938eff084b7be92298457736fe783c2
Author: Mark Thomas 
AuthorDate: Wed Apr 24 19:47:33 2024 +0100

Refactor storage of trailer fields to use MimeHeaders
---
 java/org/apache/catalina/connector/Request.java   |  4 ++--
 java/org/apache/coyote/Request.java   | 15 +--
 .../coyote/http11/filters/ChunkedInputFilter.java |  6 +++---
 java/org/apache/coyote/http2/Stream.java  |  2 +-
 java/org/apache/tomcat/util/buf/StringUtils.java  |  5 +
 java/org/apache/tomcat/util/http/MimeHeaders.java | 19 +++
 webapps/docs/changelog.xml|  8 
 7 files changed, 51 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/catalina/connector/Request.java 
b/java/org/apache/catalina/connector/Request.java
index 390ca9daa1..6bf0f0a940 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -1763,8 +1763,8 @@ public class Request implements HttpServletRequest {
 if (!isTrailerFieldsReady()) {
 throw new 
IllegalStateException(sm.getString("coyoteRequest.trailersNotReady"));
 }
-Map result = new 
HashMap<>(coyoteRequest.getTrailerFields());
-return result;
+// No need for a defensive copy since a new Map is returned for every 
call.
+return coyoteRequest.getTrailerFields();
 }
 
 
diff --git a/java/org/apache/coyote/Request.java 
b/java/org/apache/coyote/Request.java
index 680aec6a7b..bf948b09a6 100644
--- a/java/org/apache/coyote/Request.java
+++ b/java/org/apache/coyote/Request.java
@@ -110,7 +110,7 @@ public final class Request {
 private final MessageBytes localAddrMB = MessageBytes.newInstance();
 
 private final MimeHeaders headers = new MimeHeaders();
-private final Map trailerFields = new HashMap<>();
+private final MimeHeaders trailerFields = new MimeHeaders();
 
 /**
  * Path parameters
@@ -293,6 +293,11 @@ public final class Request {
 
 
 public Map getTrailerFields() {
+return trailerFields.toMap();
+}
+
+
+public MimeHeaders getMimeTrailerFields() {
 return trailerFields;
 }
 
@@ -782,7 +787,13 @@ public final class Request {
 charsetHolder = CharsetHolder.EMPTY;
 expectation = false;
 headers.recycle();
-trailerFields.clear();
+trailerFields.recycle();
+/*
+ *  Trailer fields are limited in size by bytes. The following call 
ensures that any request with a large number
+ *  of small trailer fields doesn't result in a long lasting, large 
array of headers inside the MimeHeader
+ *  instance.
+ */
+trailerFields.setLimit(MimeHeaders.DEFAULT_HEADER_SIZE);
 serverNameMB.recycle();
 serverPort = -1;
 localAddrMB.recycle();
diff --git a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 
b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
index c0b74a185f..83bccbd161 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
 import java.util.Locale;
-import java.util.Map;
 import java.util.Set;
 
 import org.apache.coyote.ActionCode;
@@ -32,6 +31,7 @@ import org.apache.coyote.http11.Constants;
 import org.apache.coyote.http11.InputFilter;
 import org.apache.tomcat.util.buf.ByteChunk;
 import org.apache.tomcat.util.buf.HexUtils;
+import org.apache.tomcat.util.http.MimeHeaders;
 import org.apache.tomcat.util.http.parser.HttpParser;
 import org.apache.tomcat.util.net.ApplicationBufferHandler;
 import org.apache.tomcat.util.res.StringManager;
@@ -467,7 +467,7 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
  * implementation wasn't viewed as practical.
  */
 
-Map headers = request.getTrailerFields();
+MimeHeaders headers = request.getMimeTrailerFields();
 
 byte chr = 0;
 
@@ -629,7 +629,7 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
 String value = new String(trailingHeaders.getBytes(), colonPos,
 lastSignificantChar - colonPos, 
StandardCharsets.ISO_8859_1);
 
-headers.put(headerName, value);
+headers.addValue(headerName).setString(value);
 }
 
 return true;
diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/h

(tomcat) branch 9.0.x updated: Fix typo

2024-04-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt 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 268684e26f Fix typo
268684e26f is described below

commit 268684e26f87998c6e0499caa4f4d393ac5fe76e
Author: Mark Thomas 
AuthorDate: Wed Apr 24 17:06:36 2024 +0100

Fix typo
---
 test/org/apache/catalina/connector/TestRequest.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/org/apache/catalina/connector/TestRequest.java 
b/test/org/apache/catalina/connector/TestRequest.java
index 09cc1068f6..3face2f3e8 100644
--- a/test/org/apache/catalina/connector/TestRequest.java
+++ b/test/org/apache/catalina/connector/TestRequest.java
@@ -904,7 +904,7 @@ public class TestRequest extends TomcatBaseTest {
 
 
 @Test
-public void testGetReaderInvalidEbcoding() throws Exception {
+public void testGetReaderInvalidEncoding() throws Exception {
 doTestGetReader("X-Invalid", false);
 }
 


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 10.1.x updated: Fix typo

2024-04-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 0b67757413 Fix typo
0b67757413 is described below

commit 0b677574135f17d41522a30f2d42ea204e33ebba
Author: Mark Thomas 
AuthorDate: Wed Apr 24 17:06:36 2024 +0100

Fix typo
---
 test/org/apache/catalina/connector/TestRequest.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/org/apache/catalina/connector/TestRequest.java 
b/test/org/apache/catalina/connector/TestRequest.java
index 95ef70278b..6964427fc8 100644
--- a/test/org/apache/catalina/connector/TestRequest.java
+++ b/test/org/apache/catalina/connector/TestRequest.java
@@ -904,7 +904,7 @@ public class TestRequest extends TomcatBaseTest {
 
 
 @Test
-public void testGetReaderInvalidEbcoding() throws Exception {
+public void testGetReaderInvalidEncoding() throws Exception {
 doTestGetReader("X-Invalid", false);
 }
 


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch main updated: Fix typo

2024-04-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
 new eee84fd4cb Fix typo
eee84fd4cb is described below

commit eee84fd4cb5b0f2b02c575297c9d07bd44328c45
Author: Mark Thomas 
AuthorDate: Wed Apr 24 17:06:36 2024 +0100

Fix typo
---
 test/org/apache/catalina/connector/TestRequest.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/org/apache/catalina/connector/TestRequest.java 
b/test/org/apache/catalina/connector/TestRequest.java
index b2289a8bb3..4bfff53596 100644
--- a/test/org/apache/catalina/connector/TestRequest.java
+++ b/test/org/apache/catalina/connector/TestRequest.java
@@ -868,7 +868,7 @@ public class TestRequest extends TomcatBaseTest {
 
 
 @Test
-public void testGetReaderInvalidEbcoding() throws Exception {
+public void testGetReaderInvalidEncoding() throws Exception {
 doTestGetReader("X-Invalid", false);
 }
 


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch main updated: Ensure onAllDataRead() fires with chunked request body

2024-04-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
 new e62cf34b1c Ensure onAllDataRead() fires with chunked request body
e62cf34b1c is described below

commit e62cf34b1c1e4c56d1a448735337fe30a7eb96eb
Author: Mark Thomas 
AuthorDate: Tue Apr 23 13:48:49 2024 +0100

Ensure onAllDataRead() fires with chunked request body
---
 .../coyote/http11/filters/ChunkedInputFilter.java  | 15 
 .../catalina/nonblocking/TestNonBlockingAPI.java   | 45 ++
 webapps/docs/changelog.xml |  5 +++
 3 files changed, 65 insertions(+)

diff --git a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 
b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
index 13dcb7d53f..c0b74a185f 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
@@ -24,6 +24,7 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.coyote.ActionCode;
 import org.apache.coyote.BadRequestException;
 import org.apache.coyote.InputBuffer;
 import org.apache.coyote.Request;
@@ -167,6 +168,20 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
 }
 if (endChunk) {
 parseEndChunk();
+if (!request.isRequestThread()) {
+/*
+ * Perform the dispatch back to the container for the 
onAllDataRead() event. For non-chunked input
+ * this would be performed when isReady() is next called.
+ *
+ * Chunked input returns one chunk at a time for 
non-blocking reads. A consequence of this is that
+ * reading the final chunk returns -1 which signals the 
end of stream. The application code reading
+ * the request body probably won't call isReady() after 
receiving the -1 return value since it
+ * already knows it is at end of stream. Therefore we 
trigger the dispatch back to the container
+ * here which in turn ensures the onAllDataRead() event is 
fired.
+ */
+request.action(ActionCode.DISPATCH_READ, null);
+request.action(ActionCode.DISPATCH_EXECUTE, null);
+}
 return -1;
 }
 }
diff --git a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java 
b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
index 6d2e202031..66fbf2ac12 100644
--- a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
+++ b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
@@ -155,6 +155,51 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
 }
 
 
+@Test
+public void testNonBlockingReadChunked() throws Exception {
+Tomcat tomcat = getTomcatInstance();
+
+// No file system docBase required
+Context ctx = getProgrammaticRootContext();
+
+NBReadServlet servlet = new NBReadServlet(false, true);
+String servletName = NBReadServlet.class.getName();
+Tomcat.addServlet(ctx, servletName, servlet);
+ctx.addServletMappingDecoded("/", servletName);
+
+tomcat.start();
+
+Client client = new Client();
+client.setPort(getPort());
+client.setRequest(new String[] { "GET / HTTP/1.1" + 
SimpleHttpClient.CRLF +
+ "Host: localhost:" + getPort() + 
SimpleHttpClient.CRLF +
+ "Transfer-Encoding: chunked" + 
SimpleHttpClient.CRLF +
+ SimpleHttpClient.CRLF +
+ "14" + SimpleHttpClient.CRLF +
+ "01234567890123456789" + 
SimpleHttpClient.CRLF +
+ "14" + SimpleHttpClient.CRLF +
+ "012345678901FINISHED" + 
SimpleHttpClient.CRLF +
+ "0" + SimpleHttpClient.CRLF +
+ SimpleHttpClient.CRLF});
+client.connect();
+client.sendRequest();
+
+client.setUseContentLength(true);
+client.readResponse(true);
+
+Assert.assertTrue(client.isResponse200());
+Assert.assertTrue(client.isResponseBodyOK());
+}
+
+
+private static class Client extends SimpleHttpClient {
+@Override
+public boolean isResponseBodyOK() {
+return "OK".equals(getResponseBody());
+}
+}
+
+
 @Test
 public void testNonBlocki

(tomcat) branch 9.0.x updated: Ensure onAllDataRead() fires with chunked request body

2024-04-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt 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 9dede35c55 Ensure onAllDataRead() fires with chunked request body
9dede35c55 is described below

commit 9dede35c55f41590368eba01e24b1ca80a4c392d
Author: Mark Thomas 
AuthorDate: Tue Apr 23 13:48:49 2024 +0100

Ensure onAllDataRead() fires with chunked request body
---
 .../coyote/http11/filters/ChunkedInputFilter.java  | 15 
 .../catalina/nonblocking/TestNonBlockingAPI.java   | 45 ++
 webapps/docs/changelog.xml |  5 +++
 3 files changed, 65 insertions(+)

diff --git a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 
b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
index 13dcb7d53f..c0b74a185f 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
@@ -24,6 +24,7 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.coyote.ActionCode;
 import org.apache.coyote.BadRequestException;
 import org.apache.coyote.InputBuffer;
 import org.apache.coyote.Request;
@@ -167,6 +168,20 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
 }
 if (endChunk) {
 parseEndChunk();
+if (!request.isRequestThread()) {
+/*
+ * Perform the dispatch back to the container for the 
onAllDataRead() event. For non-chunked input
+ * this would be performed when isReady() is next called.
+ *
+ * Chunked input returns one chunk at a time for 
non-blocking reads. A consequence of this is that
+ * reading the final chunk returns -1 which signals the 
end of stream. The application code reading
+ * the request body probably won't call isReady() after 
receiving the -1 return value since it
+ * already knows it is at end of stream. Therefore we 
trigger the dispatch back to the container
+ * here which in turn ensures the onAllDataRead() event is 
fired.
+ */
+request.action(ActionCode.DISPATCH_READ, null);
+request.action(ActionCode.DISPATCH_EXECUTE, null);
+}
 return -1;
 }
 }
diff --git a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java 
b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
index acdad397ca..1df7859c2d 100644
--- a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
+++ b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
@@ -153,6 +153,51 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
 }
 
 
+@Test
+public void testNonBlockingReadChunked() throws Exception {
+Tomcat tomcat = getTomcatInstance();
+
+// No file system docBase required
+Context ctx = getProgrammaticRootContext();
+
+NBReadServlet servlet = new NBReadServlet(false, true);
+String servletName = NBReadServlet.class.getName();
+Tomcat.addServlet(ctx, servletName, servlet);
+ctx.addServletMappingDecoded("/", servletName);
+
+tomcat.start();
+
+Client client = new Client();
+client.setPort(getPort());
+client.setRequest(new String[] { "GET / HTTP/1.1" + 
SimpleHttpClient.CRLF +
+ "Host: localhost:" + getPort() + 
SimpleHttpClient.CRLF +
+ "Transfer-Encoding: chunked" + 
SimpleHttpClient.CRLF +
+ SimpleHttpClient.CRLF +
+ "14" + SimpleHttpClient.CRLF +
+ "01234567890123456789" + 
SimpleHttpClient.CRLF +
+ "14" + SimpleHttpClient.CRLF +
+ "012345678901FINISHED" + 
SimpleHttpClient.CRLF +
+ "0" + SimpleHttpClient.CRLF +
+ SimpleHttpClient.CRLF});
+client.connect();
+client.sendRequest();
+
+client.setUseContentLength(true);
+client.readResponse(true);
+
+Assert.assertTrue(client.isResponse200());
+Assert.assertTrue(client.isResponseBodyOK());
+}
+
+
+private static class Client extends SimpleHttpClient {
+@Override
+public boolean isResponseBodyOK() {
+return "OK".equals(getResponseBody());
+}
+}
+
+
 @Test
 public void testNonBlocki

(tomcat) branch 10.1.x updated: Ensure onAllDataRead() fires with chunked request body

2024-04-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 52f007711c Ensure onAllDataRead() fires with chunked request body
52f007711c is described below

commit 52f007711c73c4733c9acf4c53d988f193853306
Author: Mark Thomas 
AuthorDate: Tue Apr 23 13:48:49 2024 +0100

Ensure onAllDataRead() fires with chunked request body
---
 .../coyote/http11/filters/ChunkedInputFilter.java  | 15 
 .../catalina/nonblocking/TestNonBlockingAPI.java   | 45 ++
 webapps/docs/changelog.xml |  5 +++
 3 files changed, 65 insertions(+)

diff --git a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 
b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
index 13dcb7d53f..c0b74a185f 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
@@ -24,6 +24,7 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.coyote.ActionCode;
 import org.apache.coyote.BadRequestException;
 import org.apache.coyote.InputBuffer;
 import org.apache.coyote.Request;
@@ -167,6 +168,20 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
 }
 if (endChunk) {
 parseEndChunk();
+if (!request.isRequestThread()) {
+/*
+ * Perform the dispatch back to the container for the 
onAllDataRead() event. For non-chunked input
+ * this would be performed when isReady() is next called.
+ *
+ * Chunked input returns one chunk at a time for 
non-blocking reads. A consequence of this is that
+ * reading the final chunk returns -1 which signals the 
end of stream. The application code reading
+ * the request body probably won't call isReady() after 
receiving the -1 return value since it
+ * already knows it is at end of stream. Therefore we 
trigger the dispatch back to the container
+ * here which in turn ensures the onAllDataRead() event is 
fired.
+ */
+request.action(ActionCode.DISPATCH_READ, null);
+request.action(ActionCode.DISPATCH_EXECUTE, null);
+}
 return -1;
 }
 }
diff --git a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java 
b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
index c86a500239..eca6090712 100644
--- a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
+++ b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
@@ -154,6 +154,51 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
 }
 
 
+@Test
+public void testNonBlockingReadChunked() throws Exception {
+Tomcat tomcat = getTomcatInstance();
+
+// No file system docBase required
+Context ctx = getProgrammaticRootContext();
+
+NBReadServlet servlet = new NBReadServlet(false, true);
+String servletName = NBReadServlet.class.getName();
+Tomcat.addServlet(ctx, servletName, servlet);
+ctx.addServletMappingDecoded("/", servletName);
+
+tomcat.start();
+
+Client client = new Client();
+client.setPort(getPort());
+client.setRequest(new String[] { "GET / HTTP/1.1" + 
SimpleHttpClient.CRLF +
+ "Host: localhost:" + getPort() + 
SimpleHttpClient.CRLF +
+ "Transfer-Encoding: chunked" + 
SimpleHttpClient.CRLF +
+ SimpleHttpClient.CRLF +
+ "14" + SimpleHttpClient.CRLF +
+ "01234567890123456789" + 
SimpleHttpClient.CRLF +
+ "14" + SimpleHttpClient.CRLF +
+ "012345678901FINISHED" + 
SimpleHttpClient.CRLF +
+ "0" + SimpleHttpClient.CRLF +
+ SimpleHttpClient.CRLF});
+client.connect();
+client.sendRequest();
+
+client.setUseContentLength(true);
+client.readResponse(true);
+
+Assert.assertTrue(client.isResponse200());
+Assert.assertTrue(client.isResponseBodyOK());
+}
+
+
+private static class Client extends SimpleHttpClient {
+@Override
+public boolean isResponseBodyOK() {
+return "OK".equals(getResponseBody());
+}
+}
+
+
 @Test
 public void testNonBlocki

(tomcat) branch main updated: isReady() should always return true in blocking mode

2024-04-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
 new 74906a5d9e isReady() should always return true in blocking mode
74906a5d9e is described below

commit 74906a5d9e2e67c119630ac31bb7f2f2625e91b5
Author: Mark Thomas 
AuthorDate: Tue Apr 23 13:12:04 2024 +0100

isReady() should always return true in blocking mode
---
 java/org/apache/catalina/connector/InputBuffer.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/connector/InputBuffer.java 
b/java/org/apache/catalina/connector/InputBuffer.java
index db85a3415a..5dcae69de1 100644
--- a/java/org/apache/catalina/connector/InputBuffer.java
+++ b/java/org/apache/catalina/connector/InputBuffer.java
@@ -243,7 +243,7 @@ public class InputBuffer extends Reader implements 
ByteChunk.ByteInputChannel, A
 if (log.isDebugEnabled()) {
 log.debug(sm.getString("inputBuffer.requiresNonBlocking"));
 }
-return false;
+return true;
 }
 if (isFinished()) {
 // If this is a non-container thread, need to trigger a read


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 9.0.x updated (31fc71858f -> 725467428b)

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from 31fc71858f Dispatch after AsyncListener.onError() should actually 
dispatch
 new acc9a94f89 Fix typos
 new 3f9b18d778 Allow any positive value for socket.unlockTimeout rather 
than >=2s
 new 3d81c5cd9e Refactor to specify acceptor stop wait time in ms rather 
than s
 new 725467428b Reduce the default wait time for the acceptor unlock

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/org/apache/tomcat/util/net/AbstractEndpoint.java   | 12 
 java/org/apache/tomcat/util/net/Acceptor.java   | 12 ++--
 java/org/apache/tomcat/util/net/LocalStrings.properties |  2 ++
 java/org/apache/tomcat/util/net/Nio2Endpoint.java   |  6 +++---
 java/org/apache/tomcat/util/net/NioEndpoint.java|  7 ++-
 java/org/apache/tomcat/util/net/SocketProperties.java   | 13 -
 webapps/docs/changelog.xml  | 11 +++
 webapps/docs/config/http.xml|  7 +--
 8 files changed, 53 insertions(+), 17 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 02/04: Allow any positive value for socket.unlockTimeout rather than >=2s

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 3f9b18d7788300571178b6d3f95e96fdbd80504b
Author: Mark Thomas 
AuthorDate: Fri Apr 19 17:49:26 2024 +0100

Allow any positive value for socket.unlockTimeout rather than >=2s

Implement limit in setter so it always applies.
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java   |  6 +-
 java/org/apache/tomcat/util/net/LocalStrings.properties |  2 ++
 java/org/apache/tomcat/util/net/SocketProperties.java   | 13 -
 webapps/docs/changelog.xml  |  5 +
 webapps/docs/config/http.xml|  7 +--
 5 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index 19edc2f514..b047a5490e 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1183,13 +1183,9 @@ public abstract class AbstractEndpoint {
 
 try (java.net.Socket s = new java.net.Socket()) {
 int stmo = 2 * 1000;
-int utmo = 2 * 1000;
 if (getSocketProperties().getSoTimeout() > stmo) {
 stmo = getSocketProperties().getSoTimeout();
 }
-if (getSocketProperties().getUnlockTimeout() > utmo) {
-utmo = getSocketProperties().getUnlockTimeout();
-}
 s.setSoTimeout(stmo);
 // Newer MacOS versions (e.g. Ventura 13.2) appear to linger 
for ~1s on close when linger is disabled.
 // That causes delays when running the unit tests. Explicitly 
enabling linger but with a timeout of
@@ -1198,7 +1194,7 @@ public abstract class AbstractEndpoint {
 if (getLog().isTraceEnabled()) {
 getLog().trace("About to unlock socket for:" + 
unlockAddress);
 }
-s.connect(unlockAddress,utmo);
+s.connect(unlockAddress, 
getSocketProperties().getUnlockTimeout());
 if (getDeferAccept()) {
 /*
  * In the case of a deferred accept / accept filters we 
need to
diff --git a/java/org/apache/tomcat/util/net/LocalStrings.properties 
b/java/org/apache/tomcat/util/net/LocalStrings.properties
index 0945510492..10b4fc1f47 100644
--- a/java/org/apache/tomcat/util/net/LocalStrings.properties
+++ b/java/org/apache/tomcat/util/net/LocalStrings.properties
@@ -161,6 +161,8 @@ socket.apr.write.error=Unexpected error [{0}] writing data 
to the APR/native soc
 socket.closed=The socket associated with this connection has been closed.
 socket.sslreneg=Exception re-negotiating SSL connection
 
+socketProperties.negativeUnlockTimeout=The negative value for unlockTimeout 
has been ignored
+
 socketWrapper.readTimeout=Read timeout
 socketWrapper.writeTimeout=Write timeout
 
diff --git a/java/org/apache/tomcat/util/net/SocketProperties.java 
b/java/org/apache/tomcat/util/net/SocketProperties.java
index b08325a20c..d71f6bffb8 100644
--- a/java/org/apache/tomcat/util/net/SocketProperties.java
+++ b/java/org/apache/tomcat/util/net/SocketProperties.java
@@ -26,6 +26,10 @@ import java.nio.channels.AsynchronousSocketChannel;
 
 import javax.management.ObjectName;
 
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
+
 /**
  * Properties that can be set in the Connector element
  * in server.xml. All properties are prefixed with socket.
@@ -33,6 +37,9 @@ import javax.management.ObjectName;
  */
 public class SocketProperties {
 
+private static final Log log = LogFactory.getLog(SocketProperties.class);
+private static final StringManager sm = 
StringManager.getManager(SocketProperties.class);
+
 /**
  * Enable/disable socket processor cache, this bounded cache stores
  * SocketProcessor objects to reduce GC
@@ -462,7 +469,11 @@ public class SocketProperties {
 }
 
 public void setUnlockTimeout(int unlockTimeout) {
-this.unlockTimeout = unlockTimeout;
+if (unlockTimeout > 0) {
+this.unlockTimeout = unlockTimeout;
+} else {
+log.warn(sm.getString("socketProperties.negativeUnlockTimeout"));
+}
 }
 
 void setObjectName(ObjectName oname) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 8bb08ecb3c..c3f8e97f95 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -143,6 +143,11 @@
 Align non-secure and secure writes with NIO and skip the write attempt
 when there are no bytes to be written. (markt)
   
+  
+Allow any positive value for socket.unlockTimeout. If a

(tomcat) 01/04: Fix typos

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit acc9a94f89a1c3a6e6829c0bcb1c732e59df7bf1
Author: Mark Thomas 
AuthorDate: Fri Apr 19 17:44:32 2024 +0100

Fix typos
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index 53a0b807b3..19edc2f514 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1192,7 +1192,7 @@ public abstract class AbstractEndpoint {
 }
 s.setSoTimeout(stmo);
 // Newer MacOS versions (e.g. Ventura 13.2) appear to linger 
for ~1s on close when linger is disabled.
-// That causes delays when running the unit tests. Explicitly 
enableing linger but with a timeout of
+// That causes delays when running the unit tests. Explicitly 
enabling linger but with a timeout of
 // zero seconds seems to fix the issue.
 s.setSoLinger(true, 0);
 if (getLog().isTraceEnabled()) {
@@ -1216,7 +1216,7 @@ public abstract class AbstractEndpoint {
 getLog().trace("Socket unlock completed for:" + 
unlockAddress);
 }
 }
-// Wait for up to 1000ms acceptor threads to unlock. Particularly
+// Wait for up to 1000ms for acceptor thread to unlock. 
Particularly
 // for the unit tests, we want to exit this loop as quickly as
 // possible. However, we also don't want to trigger excessive CPU
 // usage if the unlock takes longer than expected. Therefore, we


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 04/04: Reduce the default wait time for the acceptor unlock

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 725467428b4cfe14b325168bf9849f3d5fe4ae9d
Author: Mark Thomas 
AuthorDate: Fri Apr 19 18:08:09 2024 +0100

Reduce the default wait time for the acceptor unlock
---
 java/org/apache/tomcat/util/net/NioEndpoint.java | 7 ++-
 webapps/docs/changelog.xml   | 6 ++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java 
b/java/org/apache/tomcat/util/net/NioEndpoint.java
index 434ce6d889..99966fd464 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -323,7 +323,12 @@ public class NioEndpoint extends 
AbstractJsseEndpoint
 }
 if (running) {
 running = false;
-acceptor.stopMillis(1);
+/*
+ * Need to wait for the acceptor to unlock but not too long. 100ms 
plus twice the unlock timeout should be
+ * plenty of time for the acceptor to unlock without being an 
excessively long wait if the unlock fails.
+ */
+int acceptorWaitMilliSeconds = 100 + 2 * 
getSocketProperties().getUnlockTimeout();
+acceptor.stopMillis(acceptorWaitMilliSeconds);
 if (poller != null) {
 poller.destroy();
 poller = null;
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index c3f8e97f95..3d11e31374 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -148,6 +148,12 @@
 negative or zero value is configured, the default of 250ms
 will be used. (mark)
   
+  
+Reduce the time spent waiting for the connector to unlock. The previous
+default of 10s was noticeably too long for cases where the unlock has
+failed. The wait time is now 100ms plus twice
+socket.unlockTimeout. (markt)
+  
 
   
   


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 03/04: Refactor to specify acceptor stop wait time in ms rather than s

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 3d81c5cd9e3836be806b651b0f81dc68f58fc4f4
Author: Mark Thomas 
AuthorDate: Fri Apr 19 18:04:36 2024 +0100

Refactor to specify acceptor stop wait time in ms rather than s
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java |  2 +-
 java/org/apache/tomcat/util/net/Acceptor.java | 12 ++--
 java/org/apache/tomcat/util/net/Nio2Endpoint.java |  6 +++---
 java/org/apache/tomcat/util/net/NioEndpoint.java  |  2 +-
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index b047a5490e..d6dfe75f5f 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1562,7 +1562,7 @@ public abstract class AbstractEndpoint {
 public final void closeServerSocketGraceful() {
 if (bindState == BindState.BOUND_ON_START) {
 // Stop accepting new connections
-acceptor.stop(-1);
+acceptor.stopMillis(-1);
 // Release locks that may be preventing the acceptor from stopping
 releaseConnectionLatch();
 unlockAccept();
diff --git a/java/org/apache/tomcat/util/net/Acceptor.java 
b/java/org/apache/tomcat/util/net/Acceptor.java
index bbfd8dd695..3b5cf500a3 100644
--- a/java/org/apache/tomcat/util/net/Acceptor.java
+++ b/java/org/apache/tomcat/util/net/Acceptor.java
@@ -200,12 +200,20 @@ public class Acceptor implements Runnable {
  *
  * @param waitSeconds The time to wait in seconds. Use a value less than
  *zero for no wait.
+ *
+ * @deprecated Unused. Will be remove in Tomcat 11 onwards.
  */
+@Deprecated
 public void stop(int waitSeconds) {
+stopMillis(waitSeconds * 1000);
+}
+
+
+public void stopMillis(int waitMilliseconds) {
 stopCalled = true;
-if (waitSeconds > 0) {
+if (waitMilliseconds > 0) {
 try {
-if (!stopLatch.await(waitSeconds, TimeUnit.SECONDS)) {
+if (!stopLatch.await(waitMilliseconds, TimeUnit.MILLISECONDS)) 
{
log.warn(sm.getString("acceptor.stop.fail", 
getThreadName()));
 }
 } catch (InterruptedException e) {
diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java 
b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
index 21b9f8acfb..0c8848bb98 100644
--- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java
+++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
@@ -210,7 +210,7 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint {
@@ -448,11 +448,11 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint
 }
 if (running) {
 running = false;
-acceptor.stop(10);
+acceptor.stopMillis(1);
 if (poller != null) {
 poller.destroy();
 poller = null;


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 10.1.x updated (443e9be641 -> b76216af5d)

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from 443e9be641 getDeferAccept() always returns false - remove unused code
 new d30a545b31 SocketTimeout has no impact for acceptor unlock - remove it
 new b79a946cbc Allow any positive value for socket.unlockTimeout rather 
than >=2s
 new ba98642273 Refactor to specify acceptor stop wait time in ms rather 
than s
 new b76216af5d Reduce the default wait time for the acceptor unlock

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/org/apache/tomcat/util/net/AbstractEndpoint.java   | 15 ---
 java/org/apache/tomcat/util/net/Acceptor.java   | 12 ++--
 java/org/apache/tomcat/util/net/LocalStrings.properties |  2 ++
 java/org/apache/tomcat/util/net/Nio2Endpoint.java   |  6 +++---
 java/org/apache/tomcat/util/net/NioEndpoint.java|  7 ++-
 java/org/apache/tomcat/util/net/SocketProperties.java   | 13 -
 webapps/docs/changelog.xml  | 11 +++
 webapps/docs/config/http.xml|  7 +--
 8 files changed, 53 insertions(+), 20 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 03/04: Refactor to specify acceptor stop wait time in ms rather than s

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit ba98642273f1ce9a81857506dffb6dc370d7d2f9
Author: Mark Thomas 
AuthorDate: Fri Apr 19 18:04:36 2024 +0100

Refactor to specify acceptor stop wait time in ms rather than s
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java |  2 +-
 java/org/apache/tomcat/util/net/Acceptor.java | 12 ++--
 java/org/apache/tomcat/util/net/Nio2Endpoint.java |  6 +++---
 java/org/apache/tomcat/util/net/NioEndpoint.java  |  2 +-
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index 460e7543f5..03a12d1959 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1493,7 +1493,7 @@ public abstract class AbstractEndpoint {
 public final void closeServerSocketGraceful() {
 if (bindState == BindState.BOUND_ON_START) {
 // Stop accepting new connections
-acceptor.stop(-1);
+acceptor.stopMillis(-1);
 // Release locks that may be preventing the acceptor from stopping
 releaseConnectionLatch();
 unlockAccept();
diff --git a/java/org/apache/tomcat/util/net/Acceptor.java 
b/java/org/apache/tomcat/util/net/Acceptor.java
index b1083b292a..d8deb8cb26 100644
--- a/java/org/apache/tomcat/util/net/Acceptor.java
+++ b/java/org/apache/tomcat/util/net/Acceptor.java
@@ -171,12 +171,20 @@ public class Acceptor implements Runnable {
  *
  * @param waitSeconds The time to wait in seconds. Use a value less than
  *zero for no wait.
+ *
+ * @deprecated Unused. Will be remove in Tomcat 11 onwards.
  */
+@Deprecated
 public void stop(int waitSeconds) {
+stopMillis(waitSeconds * 1000);
+}
+
+
+public void stopMillis(int waitMilliseconds) {
 stopCalled = true;
-if (waitSeconds > 0) {
+if (waitMilliseconds > 0) {
 try {
-if (!stopLatch.await(waitSeconds, TimeUnit.SECONDS)) {
+if (!stopLatch.await(waitMilliseconds, TimeUnit.MILLISECONDS)) 
{
log.warn(sm.getString("acceptor.stop.fail", 
getThreadName()));
 }
 } catch (InterruptedException e) {
diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java 
b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
index 5bbc3a11f8..0c3cbad675 100644
--- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java
+++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
@@ -199,7 +199,7 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint {
@@ -437,11 +437,11 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint
 }
 if (running) {
 running = false;
-acceptor.stop(10);
+acceptor.stopMillis(1);
 if (poller != null) {
 poller.destroy();
 poller = null;


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 01/04: SocketTimeout has no impact for acceptor unlock - remove it

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit d30a545b319abfcdadc9f94d26a529324c9401b5
Author: Mark Thomas 
AuthorDate: Fri Apr 19 17:45:56 2024 +0100

SocketTimeout has no impact for acceptor unlock - remove it
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index 7bae5f68ab..a46ee4ce9e 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1129,15 +1129,12 @@ public abstract class AbstractEndpoint {
 unlockAddress = getUnlockAddress(localAddress);
 
 try (java.net.Socket s = new java.net.Socket()) {
-int stmo = 2 * 1000;
 int utmo = 2 * 1000;
-if (getSocketProperties().getSoTimeout() > stmo) {
-stmo = getSocketProperties().getSoTimeout();
-}
 if (getSocketProperties().getUnlockTimeout() > utmo) {
 utmo = getSocketProperties().getUnlockTimeout();
 }
-s.setSoTimeout(stmo);
+// Never going to read from this socket so the timeout doesn't 
matter. Use the unlock timeout.
+s.setSoTimeout(utmo);
 // Newer MacOS versions (e.g. Ventura 13.2) appear to linger 
for ~1s on close when linger is disabled.
 // That causes delays when running the unit tests. Explicitly 
enabling linger but with a timeout of
 // zero seconds seems to fix the issue.


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 04/04: Reduce the default wait time for the acceptor unlock

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit b76216af5d8ad0608c3da5f0a9a273f3b46f647e
Author: Mark Thomas 
AuthorDate: Fri Apr 19 18:08:09 2024 +0100

Reduce the default wait time for the acceptor unlock
---
 java/org/apache/tomcat/util/net/NioEndpoint.java | 7 ++-
 webapps/docs/changelog.xml   | 6 ++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java 
b/java/org/apache/tomcat/util/net/NioEndpoint.java
index c53164e256..9f646e73eb 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -296,7 +296,12 @@ public class NioEndpoint extends 
AbstractJsseEndpoint
 }
 if (running) {
 running = false;
-acceptor.stopMillis(1);
+/*
+ * Need to wait for the acceptor to unlock but not too long. 100ms 
plus twice the unlock timeout should be
+ * plenty of time for the acceptor to unlock without being an 
excessively long wait if the unlock fails.
+ */
+int acceptorWaitMilliSeconds = 100 + 2 * 
getSocketProperties().getUnlockTimeout();
+acceptor.stopMillis(acceptorWaitMilliSeconds);
 if (poller != null) {
 poller.destroy();
 poller = null;
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 53ebb4a103..c2a903f944 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -158,6 +158,12 @@
 negative or zero value is configured, the default of 250ms
 will be used. (mark)
   
+  
+Reduce the time spent waiting for the connector to unlock. The previous
+default of 10s was noticeably too long for cases where the unlock has
+failed. The wait time is now 100ms plus twice
+socket.unlockTimeout. (markt)
+  
 
   
   


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 02/04: Allow any positive value for socket.unlockTimeout rather than >=2s

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit b79a946cbc3fa55073c733dbf4a9ab1c5fdbd003
Author: Mark Thomas 
AuthorDate: Fri Apr 19 17:49:26 2024 +0100

Allow any positive value for socket.unlockTimeout rather than >=2s

Implement limit in setter so it always applies.
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java   |  8 ++--
 java/org/apache/tomcat/util/net/LocalStrings.properties |  2 ++
 java/org/apache/tomcat/util/net/SocketProperties.java   | 13 -
 webapps/docs/changelog.xml  |  5 +
 webapps/docs/config/http.xml|  7 +--
 5 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index a46ee4ce9e..460e7543f5 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1129,12 +1129,8 @@ public abstract class AbstractEndpoint {
 unlockAddress = getUnlockAddress(localAddress);
 
 try (java.net.Socket s = new java.net.Socket()) {
-int utmo = 2 * 1000;
-if (getSocketProperties().getUnlockTimeout() > utmo) {
-utmo = getSocketProperties().getUnlockTimeout();
-}
 // Never going to read from this socket so the timeout doesn't 
matter. Use the unlock timeout.
-s.setSoTimeout(utmo);
+s.setSoTimeout(getSocketProperties().getUnlockTimeout());
 // Newer MacOS versions (e.g. Ventura 13.2) appear to linger 
for ~1s on close when linger is disabled.
 // That causes delays when running the unit tests. Explicitly 
enabling linger but with a timeout of
 // zero seconds seems to fix the issue.
@@ -1142,7 +1138,7 @@ public abstract class AbstractEndpoint {
 if (getLog().isTraceEnabled()) {
 getLog().trace("About to unlock socket for:" + 
unlockAddress);
 }
-s.connect(unlockAddress,utmo);
+s.connect(unlockAddress, 
getSocketProperties().getUnlockTimeout());
 if (getLog().isTraceEnabled()) {
 getLog().trace("Socket unlock completed for:" + 
unlockAddress);
 }
diff --git a/java/org/apache/tomcat/util/net/LocalStrings.properties 
b/java/org/apache/tomcat/util/net/LocalStrings.properties
index 8557463f7e..35c9d890c2 100644
--- a/java/org/apache/tomcat/util/net/LocalStrings.properties
+++ b/java/org/apache/tomcat/util/net/LocalStrings.properties
@@ -139,6 +139,8 @@ sniExtractor.tooEarly=It is illegal to call this method 
before the client hello
 socket.closed=The socket associated with this connection has been closed.
 socket.sslreneg=Exception re-negotiating SSL connection
 
+socketProperties.negativeUnlockTimeout=The negative value for unlockTimeout 
has been ignored
+
 socketWrapper.readTimeout=Read timeout
 socketWrapper.writeTimeout=Write timeout
 
diff --git a/java/org/apache/tomcat/util/net/SocketProperties.java 
b/java/org/apache/tomcat/util/net/SocketProperties.java
index b91d54f0e2..10b9fd765f 100644
--- a/java/org/apache/tomcat/util/net/SocketProperties.java
+++ b/java/org/apache/tomcat/util/net/SocketProperties.java
@@ -26,6 +26,10 @@ import java.nio.channels.AsynchronousSocketChannel;
 
 import javax.management.ObjectName;
 
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
+
 /**
  * Properties that can be set in the Connector element
  * in server.xml. All properties are prefixed with socket.
@@ -33,6 +37,9 @@ import javax.management.ObjectName;
  */
 public class SocketProperties {
 
+private static final Log log = LogFactory.getLog(SocketProperties.class);
+private static final StringManager sm = 
StringManager.getManager(SocketProperties.class);
+
 /**
  * Enable/disable socket processor cache, this bounded cache stores
  * SocketProcessor objects to reduce GC
@@ -451,7 +458,11 @@ public class SocketProperties {
 }
 
 public void setUnlockTimeout(int unlockTimeout) {
-this.unlockTimeout = unlockTimeout;
+if (unlockTimeout > 0) {
+this.unlockTimeout = unlockTimeout;
+} else {
+log.warn(sm.getString("socketProperties.negativeUnlockTimeout"));
+}
 }
 
 /**
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 3a295c0937..53ebb4a103 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -153,6 +153,11 @@
 Align non-secure and secure writes with NIO and skip the write attempt
 when there are no bytes to be written. (ma

(tomcat) branch 10.1.x updated: getDeferAccept() always returns false - remove unused code

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 443e9be641 getDeferAccept() always returns false - remove unused code
443e9be641 is described below

commit 443e9be641fd9a0db4d60cd111dd7d61423be055
Author: Mark Thomas 
AuthorDate: Fri Apr 19 19:41:28 2024 +0100

getDeferAccept() always returns false - remove unused code
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java | 14 --
 1 file changed, 14 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index e53f9e0286..7bae5f68ab 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -17,7 +17,6 @@
 package org.apache.tomcat.util.net;
 
 import java.io.IOException;
-import java.io.OutputStreamWriter;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.NetworkInterface;
@@ -1147,19 +1146,6 @@ public abstract class AbstractEndpoint {
 getLog().trace("About to unlock socket for:" + 
unlockAddress);
 }
 s.connect(unlockAddress,utmo);
-if (getDeferAccept()) {
-/*
- * In the case of a deferred accept / accept filters we 
need to
- * send data to wake up the accept. Send OPTIONS * to 
bypass
- * even BSD accept filters. The Acceptor will discard it.
- */
-OutputStreamWriter sw;
-
-sw = new OutputStreamWriter(s.getOutputStream(), 
"ISO-8859-1");
-sw.write("OPTIONS * HTTP/1.0\r\n" +
-"User-Agent: Tomcat wakeup connection\r\n\r\n");
-sw.flush();
-}
 if (getLog().isTraceEnabled()) {
 getLog().trace("Socket unlock completed for:" + 
unlockAddress);
 }


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 10.1.x updated: Fix typos

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 0b00fdb313 Fix typos
0b00fdb313 is described below

commit 0b00fdb3131c17de0051141b7ee4ba2e8632f032
Author: Mark Thomas 
AuthorDate: Fri Apr 19 17:44:32 2024 +0100

Fix typos
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index bfb90b0127..e53f9e0286 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1140,7 +1140,7 @@ public abstract class AbstractEndpoint {
 }
 s.setSoTimeout(stmo);
 // Newer MacOS versions (e.g. Ventura 13.2) appear to linger 
for ~1s on close when linger is disabled.
-// That causes delays when running the unit tests. Explicitly 
enableing linger but with a timeout of
+// That causes delays when running the unit tests. Explicitly 
enabling linger but with a timeout of
 // zero seconds seems to fix the issue.
 s.setSoLinger(true, 0);
 if (getLog().isTraceEnabled()) {
@@ -1164,7 +1164,7 @@ public abstract class AbstractEndpoint {
 getLog().trace("Socket unlock completed for:" + 
unlockAddress);
 }
 }
-// Wait for up to 1000ms acceptor threads to unlock. Particularly
+// Wait for up to 1000ms for acceptor thread to unlock. 
Particularly
 // for the unit tests, we want to exit this loop as quickly as
 // possible. However, we also don't want to trigger excessive CPU
 // usage if the unlock takes longer than expected. Therefore, we


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 05/06: Reduce the default wait time for the acceptor unlock

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 59c53815d0cead640663d6a1fcdef826335e283e
Author: Mark Thomas 
AuthorDate: Fri Apr 19 18:08:09 2024 +0100

Reduce the default wait time for the acceptor unlock
---
 java/org/apache/tomcat/util/net/NioEndpoint.java | 7 ++-
 webapps/docs/changelog.xml   | 6 ++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java 
b/java/org/apache/tomcat/util/net/NioEndpoint.java
index e949b11df4..30279002dd 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -297,7 +297,12 @@ public class NioEndpoint extends 
AbstractNetworkChannelEndpoint250ms
 will be used. (mark)
   
+  
+Reduce the time spent waiting for the connector to unlock. The previous
+default of 10s was noticeably too long for cases where the unlock has
+failed. The wait time is now 100ms plus twice
+socket.unlockTimeout. (markt)
+  
 
   
   


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 06/06: Remove deprecated code

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 1ddcd538a8b2328d02e98cb9d207940256a19f5e
Author: Mark Thomas 
AuthorDate: Fri Apr 19 19:16:07 2024 +0100

Remove deprecated code
---
 java/org/apache/tomcat/util/net/Acceptor.java | 16 
 1 file changed, 16 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/Acceptor.java 
b/java/org/apache/tomcat/util/net/Acceptor.java
index d8deb8cb26..d570bda50b 100644
--- a/java/org/apache/tomcat/util/net/Acceptor.java
+++ b/java/org/apache/tomcat/util/net/Acceptor.java
@@ -164,22 +164,6 @@ public class Acceptor implements Runnable {
 }
 
 
-/**
- * Signals the Acceptor to stop, optionally waiting for that stop process
- * to complete before returning. If a wait is requested and the stop does
- * not complete in that time a warning will be logged.
- *
- * @param waitSeconds The time to wait in seconds. Use a value less than
- *zero for no wait.
- *
- * @deprecated Unused. Will be remove in Tomcat 11 onwards.
- */
-@Deprecated
-public void stop(int waitSeconds) {
-stopMillis(waitSeconds * 1000);
-}
-
-
 public void stopMillis(int waitMilliseconds) {
 stopCalled = true;
 if (waitMilliseconds > 0) {


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 01/06: Fix typos

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 06ecc621637d2e9119a8640eaa71cd748e7013c3
Author: Mark Thomas 
AuthorDate: Fri Apr 19 17:44:32 2024 +0100

Fix typos
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index 2c8a77ddd2..f4f31085a4 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1295,7 +1295,7 @@ public abstract class AbstractEndpoint {
 }
 s.setSoTimeout(stmo);
 // Newer MacOS versions (e.g. Ventura 13.2) appear to linger 
for ~1s on close when linger is disabled.
-// That causes delays when running the unit tests. Explicitly 
enableing linger but with a timeout of
+// That causes delays when running the unit tests. Explicitly 
enabling linger but with a timeout of
 // zero seconds seems to fix the issue.
 s.setSoLinger(true, 0);
 if (getLog().isTraceEnabled()) {
@@ -1306,7 +1306,7 @@ public abstract class AbstractEndpoint {
 getLog().trace("Socket unlock completed for:" + 
unlockAddress);
 }
 }
-// Wait for up to 1000ms acceptor threads to unlock. Particularly
+// Wait for up to 1000ms for acceptor thread to unlock. 
Particularly
 // for the unit tests, we want to exit this loop as quickly as
 // possible. However, we also don't want to trigger excessive CPU
 // usage if the unlock takes longer than expected. Therefore, we


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 03/06: Allow any positive value for socket.unlockTimeout rather than >=2s

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 2bbee3883dd40f3612fc2620fc58b2f43ee5debd
Author: Mark Thomas 
AuthorDate: Fri Apr 19 17:49:26 2024 +0100

Allow any positive value for socket.unlockTimeout rather than >=2s

Implement limit in setter so it always applies.
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java   |  8 ++--
 java/org/apache/tomcat/util/net/LocalStrings.properties |  2 ++
 java/org/apache/tomcat/util/net/SocketProperties.java   | 13 -
 webapps/docs/changelog.xml  |  5 +
 webapps/docs/config/http.xml|  7 +--
 5 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index 1e0f3bf28b..c3a5ee523d 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1285,12 +1285,8 @@ public abstract class AbstractEndpoint {
 unlockAddress = getUnlockAddress(localAddress);
 
 try (java.net.Socket s = new java.net.Socket()) {
-int utmo = 2 * 1000;
-if (getSocketProperties().getUnlockTimeout() > utmo) {
-utmo = getSocketProperties().getUnlockTimeout();
-}
 // Never going to read from this socket so the timeout doesn't 
matter. Use the unlock timeout.
-s.setSoTimeout(utmo);
+s.setSoTimeout(getSocketProperties().getUnlockTimeout());
 // Newer MacOS versions (e.g. Ventura 13.2) appear to linger 
for ~1s on close when linger is disabled.
 // That causes delays when running the unit tests. Explicitly 
enabling linger but with a timeout of
 // zero seconds seems to fix the issue.
@@ -1298,7 +1294,7 @@ public abstract class AbstractEndpoint {
 if (getLog().isTraceEnabled()) {
 getLog().trace("About to unlock socket for:" + 
unlockAddress);
 }
-s.connect(unlockAddress,utmo);
+s.connect(unlockAddress, 
getSocketProperties().getUnlockTimeout());
 if (getLog().isTraceEnabled()) {
 getLog().trace("Socket unlock completed for:" + 
unlockAddress);
 }
diff --git a/java/org/apache/tomcat/util/net/LocalStrings.properties 
b/java/org/apache/tomcat/util/net/LocalStrings.properties
index 20460c9326..f10dfafc03 100644
--- a/java/org/apache/tomcat/util/net/LocalStrings.properties
+++ b/java/org/apache/tomcat/util/net/LocalStrings.properties
@@ -140,6 +140,8 @@ sniExtractor.tooEarly=It is illegal to call this method 
before the client hello
 socket.closed=The socket associated with this connection has been closed.
 socket.sslreneg=Exception re-negotiating SSL connection
 
+socketProperties.negativeUnlockTimeout=The negative value for unlockTimeout 
has been ignored
+
 socketWrapper.readTimeout=Read timeout
 socketWrapper.writeTimeout=Write timeout
 
diff --git a/java/org/apache/tomcat/util/net/SocketProperties.java 
b/java/org/apache/tomcat/util/net/SocketProperties.java
index b91d54f0e2..10b9fd765f 100644
--- a/java/org/apache/tomcat/util/net/SocketProperties.java
+++ b/java/org/apache/tomcat/util/net/SocketProperties.java
@@ -26,6 +26,10 @@ import java.nio.channels.AsynchronousSocketChannel;
 
 import javax.management.ObjectName;
 
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
+
 /**
  * Properties that can be set in the Connector element
  * in server.xml. All properties are prefixed with socket.
@@ -33,6 +37,9 @@ import javax.management.ObjectName;
  */
 public class SocketProperties {
 
+private static final Log log = LogFactory.getLog(SocketProperties.class);
+private static final StringManager sm = 
StringManager.getManager(SocketProperties.class);
+
 /**
  * Enable/disable socket processor cache, this bounded cache stores
  * SocketProcessor objects to reduce GC
@@ -451,7 +458,11 @@ public class SocketProperties {
 }
 
 public void setUnlockTimeout(int unlockTimeout) {
-this.unlockTimeout = unlockTimeout;
+if (unlockTimeout > 0) {
+this.unlockTimeout = unlockTimeout;
+} else {
+log.warn(sm.getString("socketProperties.negativeUnlockTimeout"));
+}
 }
 
 /**
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index f6eacba634..6cc139f23a 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -148,6 +148,11 @@
 Align non-secure and secure writes with NIO and skip the write attempt
 when there are no bytes to be written. (ma

(tomcat) branch main updated (cbefe8624e -> 1ddcd538a8)

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from cbefe8624e Fix disastrous cookie-logging patch.
 new 06ecc62163 Fix typos
 new 50d4b6fd94 SocketTimeout has no impact for acceptor unlock - remove it
 new 2bbee3883d Allow any positive value for socket.unlockTimeout rather 
than >=2s
 new ef2e8f9c06 Refactor to specify acceptor stop wait time in ms rather 
than s
 new 59c53815d0 Reduce the default wait time for the acceptor unlock
 new 1ddcd538a8 Remove deprecated code

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/org/apache/tomcat/util/net/AbstractEndpoint.java | 19 ++-
 java/org/apache/tomcat/util/net/Acceptor.java | 14 +++---
 .../apache/tomcat/util/net/LocalStrings.properties|  2 ++
 java/org/apache/tomcat/util/net/Nio2Endpoint.java |  6 +++---
 java/org/apache/tomcat/util/net/NioEndpoint.java  |  7 ++-
 java/org/apache/tomcat/util/net/SocketProperties.java | 13 -
 webapps/docs/changelog.xml| 11 +++
 webapps/docs/config/http.xml  |  7 +--
 8 files changed, 48 insertions(+), 31 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 04/06: Refactor to specify acceptor stop wait time in ms rather than s

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit ef2e8f9c0639a247e68c304a587a5e8b12f8bc3c
Author: Mark Thomas 
AuthorDate: Fri Apr 19 18:04:36 2024 +0100

Refactor to specify acceptor stop wait time in ms rather than s
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java |  2 +-
 java/org/apache/tomcat/util/net/Acceptor.java | 12 ++--
 java/org/apache/tomcat/util/net/Nio2Endpoint.java |  6 +++---
 java/org/apache/tomcat/util/net/NioEndpoint.java  |  2 +-
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index c3a5ee523d..4da1e460cb 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1661,7 +1661,7 @@ public abstract class AbstractEndpoint {
 public final void closeServerSocketGraceful() {
 if (bindState == BindState.BOUND_ON_START) {
 // Stop accepting new connections
-acceptor.stop(-1);
+acceptor.stopMillis(-1);
 // Release locks that may be preventing the acceptor from stopping
 releaseConnectionLatch();
 unlockAccept();
diff --git a/java/org/apache/tomcat/util/net/Acceptor.java 
b/java/org/apache/tomcat/util/net/Acceptor.java
index b1083b292a..d8deb8cb26 100644
--- a/java/org/apache/tomcat/util/net/Acceptor.java
+++ b/java/org/apache/tomcat/util/net/Acceptor.java
@@ -171,12 +171,20 @@ public class Acceptor implements Runnable {
  *
  * @param waitSeconds The time to wait in seconds. Use a value less than
  *zero for no wait.
+ *
+ * @deprecated Unused. Will be remove in Tomcat 11 onwards.
  */
+@Deprecated
 public void stop(int waitSeconds) {
+stopMillis(waitSeconds * 1000);
+}
+
+
+public void stopMillis(int waitMilliseconds) {
 stopCalled = true;
-if (waitSeconds > 0) {
+if (waitMilliseconds > 0) {
 try {
-if (!stopLatch.await(waitSeconds, TimeUnit.SECONDS)) {
+if (!stopLatch.await(waitMilliseconds, TimeUnit.MILLISECONDS)) 
{
log.warn(sm.getString("acceptor.stop.fail", 
getThreadName()));
 }
 } catch (InterruptedException e) {
diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java 
b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
index 6aba831e9d..7e1fbd77b0 100644
--- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java
+++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
@@ -199,7 +199,7 @@ public class Nio2Endpoint extends 
AbstractNetworkChannelEndpoint {
@@ -440,11 +440,11 @@ public class Nio2Endpoint extends 
AbstractNetworkChannelEndpoint

(tomcat) 02/06: SocketTimeout has no impact for acceptor unlock - remove it

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 50d4b6fd940928ca8a11420297503f563503b501
Author: Mark Thomas 
AuthorDate: Fri Apr 19 17:45:56 2024 +0100

SocketTimeout has no impact for acceptor unlock - remove it
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index f4f31085a4..1e0f3bf28b 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1285,15 +1285,12 @@ public abstract class AbstractEndpoint {
 unlockAddress = getUnlockAddress(localAddress);
 
 try (java.net.Socket s = new java.net.Socket()) {
-int stmo = 2 * 1000;
 int utmo = 2 * 1000;
-if (getSocketProperties().getSoTimeout() > stmo) {
-stmo = getSocketProperties().getSoTimeout();
-}
 if (getSocketProperties().getUnlockTimeout() > utmo) {
 utmo = getSocketProperties().getUnlockTimeout();
 }
-s.setSoTimeout(stmo);
+// Never going to read from this socket so the timeout doesn't 
matter. Use the unlock timeout.
+s.setSoTimeout(utmo);
 // Newer MacOS versions (e.g. Ventura 13.2) appear to linger 
for ~1s on close when linger is disabled.
 // That causes delays when running the unit tests. Explicitly 
enabling linger but with a timeout of
 // zero seconds seems to fix the issue.


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 9.0.x updated: Dispatch after AsyncListener.onError() should actually dispatch

2024-04-18 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt 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 31fc71858f Dispatch after AsyncListener.onError() should actually 
dispatch
31fc71858f is described below

commit 31fc71858f9212fb8c1c508d3cafb852d40a6ede
Author: Mark Thomas 
AuthorDate: Thu Apr 18 21:09:12 2024 +0100

Dispatch after AsyncListener.onError() should actually dispatch

The dispatch is now performed rather than completing the request using
the error page mechanism.
---
 .../org/apache/catalina/core/AsyncContextImpl.java |   6 +
 .../TestAsyncContextImplListenerOnComplete.java|  13 +-
 .../catalina/core/TestAsyncContextIoError.java | 213 +
 webapps/docs/changelog.xml |   6 +
 4 files changed, 235 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/core/AsyncContextImpl.java 
b/java/org/apache/catalina/core/AsyncContextImpl.java
index 52bddba3b9..908832a5b4 100644
--- a/java/org/apache/catalina/core/AsyncContextImpl.java
+++ b/java/org/apache/catalina/core/AsyncContextImpl.java
@@ -437,6 +437,12 @@ public class AsyncContextImpl implements AsyncContext, 
AsyncContextCallback {
 // complete() or dispatch(). Complete the async processing.
 complete();
 }
+} else if (request.isAsyncDispatching()) {
+/*
+ * AsyncListener.onError() called dispatch. Clear the error state 
on the response else the dispatch will
+ * trigger error page handling.
+ */
+request.getResponse().resetError();
 }
 }
 
diff --git 
a/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java 
b/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java
index 05e68cd0d3..950ace2dc8 100644
--- a/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java
+++ b/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java
@@ -30,6 +30,7 @@ import java.util.concurrent.TimeUnit;
 import javax.servlet.AsyncContext;
 import javax.servlet.AsyncEvent;
 import javax.servlet.AsyncListener;
+import javax.servlet.DispatcherType;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -107,9 +108,15 @@ public class TestAsyncContextImplListenerOnComplete 
extends TomcatBaseTest {
 resp.setContentType("text/event-stream");
 resp.setCharacterEncoding("UTF-8");
 resp.setStatus(200);
-AsyncContext context = req.startAsync();
-context.addListener(new ReproAsyncListener());
-eventSource.add(context);
+/*
+ * AsyncListener dispatches back to this servlet in onError(). We 
do not want to restart async processing in
+ * this case or we will enter a loop.
+ */
+if (req.getDispatcherType() == DispatcherType.REQUEST) {
+AsyncContext context = req.startAsync();
+context.addListener(new ReproAsyncListener());
+eventSource.add(context);
+}
 }
 
 private class ReproAsyncListener implements AsyncListener {
diff --git a/test/org/apache/catalina/core/TestAsyncContextIoError.java 
b/test/org/apache/catalina/core/TestAsyncContextIoError.java
new file mode 100644
index 00..a4c73e0982
--- /dev/null
+++ b/test/org/apache/catalina/core/TestAsyncContextIoError.java
@@ -0,0 +1,213 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.catalina.core;
+
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.AsyncEvent;
+import javax.servlet.AsyncListener;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.A

(tomcat) branch 10.1.x updated: Dispatch after AsyncListener.onError() should actually dispatch

2024-04-18 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 534ade1782 Dispatch after AsyncListener.onError() should actually 
dispatch
534ade1782 is described below

commit 534ade17826d8f3e78118df3751b6391f0ec92ca
Author: Mark Thomas 
AuthorDate: Thu Apr 18 21:09:12 2024 +0100

Dispatch after AsyncListener.onError() should actually dispatch

The dispatch is now performed rather than completing the request using
the error page mechanism.
---
 .../org/apache/catalina/core/AsyncContextImpl.java |   6 +
 .../TestAsyncContextImplListenerOnComplete.java|  13 +-
 .../catalina/core/TestAsyncContextIoError.java | 213 +
 webapps/docs/changelog.xml |   6 +
 4 files changed, 235 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/core/AsyncContextImpl.java 
b/java/org/apache/catalina/core/AsyncContextImpl.java
index 210d29a356..2cb3958120 100644
--- a/java/org/apache/catalina/core/AsyncContextImpl.java
+++ b/java/org/apache/catalina/core/AsyncContextImpl.java
@@ -438,6 +438,12 @@ public class AsyncContextImpl implements AsyncContext, 
AsyncContextCallback {
 // complete() or dispatch(). Complete the async processing.
 complete();
 }
+} else if (request.isAsyncDispatching()) {
+/*
+ * AsyncListener.onError() called dispatch. Clear the error state 
on the response else the dispatch will
+ * trigger error page handling.
+ */
+request.getResponse().resetError();
 }
 }
 
diff --git 
a/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java 
b/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java
index dfdc33b9d0..a316e95c25 100644
--- a/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java
+++ b/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java
@@ -29,6 +29,7 @@ import java.util.concurrent.TimeUnit;
 import jakarta.servlet.AsyncContext;
 import jakarta.servlet.AsyncEvent;
 import jakarta.servlet.AsyncListener;
+import jakarta.servlet.DispatcherType;
 import jakarta.servlet.http.HttpServlet;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
@@ -106,9 +107,15 @@ public class TestAsyncContextImplListenerOnComplete 
extends TomcatBaseTest {
 resp.setContentType("text/event-stream");
 resp.setCharacterEncoding("UTF-8");
 resp.setStatus(200);
-AsyncContext context = req.startAsync();
-context.addListener(new ReproAsyncListener());
-eventSource.add(context);
+/*
+ * AsyncListener dispatches back to this servlet in onError(). We 
do not want to restart async processing in
+ * this case or we will enter a loop.
+ */
+if (req.getDispatcherType() == DispatcherType.REQUEST) {
+AsyncContext context = req.startAsync();
+context.addListener(new ReproAsyncListener());
+eventSource.add(context);
+}
 }
 
 private class ReproAsyncListener implements AsyncListener {
diff --git a/test/org/apache/catalina/core/TestAsyncContextIoError.java 
b/test/org/apache/catalina/core/TestAsyncContextIoError.java
new file mode 100644
index 00..f8052d60b9
--- /dev/null
+++ b/test/org/apache/catalina/core/TestAsyncContextIoError.java
@@ -0,0 +1,213 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.catalina.core;
+
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import jakarta.servlet.AsyncContext;
+import jakarta.servlet.AsyncEvent;
+import jakarta.servlet.AsyncListener;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServlet;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+
+import 

(tomcat) branch main updated: Dispatch after AsyncListener.onError() should actually dispatch

2024-04-18 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
 new c96e797c77 Dispatch after AsyncListener.onError() should actually 
dispatch
c96e797c77 is described below

commit c96e797c7735bdc60cbc221b685d03c74eb86fbf
Author: Mark Thomas 
AuthorDate: Thu Apr 18 21:09:12 2024 +0100

Dispatch after AsyncListener.onError() should actually dispatch

The dispatch is now performed rather than completing the request using
the error page mechanism.
---
 .../org/apache/catalina/core/AsyncContextImpl.java |   6 +
 .../TestAsyncContextImplListenerOnComplete.java|  13 +-
 .../catalina/core/TestAsyncContextIoError.java | 213 +
 webapps/docs/changelog.xml |   6 +
 4 files changed, 235 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/core/AsyncContextImpl.java 
b/java/org/apache/catalina/core/AsyncContextImpl.java
index f2a1a3487e..ac0bece148 100644
--- a/java/org/apache/catalina/core/AsyncContextImpl.java
+++ b/java/org/apache/catalina/core/AsyncContextImpl.java
@@ -437,6 +437,12 @@ public class AsyncContextImpl implements AsyncContext, 
AsyncContextCallback {
 // complete() or dispatch(). Complete the async processing.
 complete();
 }
+} else if (request.isAsyncDispatching()) {
+/*
+ * AsyncListener.onError() called dispatch. Clear the error state 
on the response else the dispatch will
+ * trigger error page handling.
+ */
+request.getResponse().resetError();
 }
 }
 
diff --git 
a/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java 
b/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java
index dfdc33b9d0..a316e95c25 100644
--- a/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java
+++ b/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java
@@ -29,6 +29,7 @@ import java.util.concurrent.TimeUnit;
 import jakarta.servlet.AsyncContext;
 import jakarta.servlet.AsyncEvent;
 import jakarta.servlet.AsyncListener;
+import jakarta.servlet.DispatcherType;
 import jakarta.servlet.http.HttpServlet;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
@@ -106,9 +107,15 @@ public class TestAsyncContextImplListenerOnComplete 
extends TomcatBaseTest {
 resp.setContentType("text/event-stream");
 resp.setCharacterEncoding("UTF-8");
 resp.setStatus(200);
-AsyncContext context = req.startAsync();
-context.addListener(new ReproAsyncListener());
-eventSource.add(context);
+/*
+ * AsyncListener dispatches back to this servlet in onError(). We 
do not want to restart async processing in
+ * this case or we will enter a loop.
+ */
+if (req.getDispatcherType() == DispatcherType.REQUEST) {
+AsyncContext context = req.startAsync();
+context.addListener(new ReproAsyncListener());
+eventSource.add(context);
+}
 }
 
 private class ReproAsyncListener implements AsyncListener {
diff --git a/test/org/apache/catalina/core/TestAsyncContextIoError.java 
b/test/org/apache/catalina/core/TestAsyncContextIoError.java
new file mode 100644
index 00..f8052d60b9
--- /dev/null
+++ b/test/org/apache/catalina/core/TestAsyncContextIoError.java
@@ -0,0 +1,213 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.catalina.core;
+
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import jakarta.servlet.AsyncContext;
+import jakarta.servlet.AsyncEvent;
+import jakarta.servlet.AsyncListener;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServlet;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+
+import 

(tomcat) branch 9.0.x updated: Add API that allows the error status for the response to be reset

2024-04-18 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt 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 2a3d9c5c1b Add API that allows the error status for the response to be 
reset
2a3d9c5c1b is described below

commit 2a3d9c5c1ba7f7733171beb82fda254c4e73769c
Author: Mark Thomas 
AuthorDate: Thu Apr 18 19:45:41 2024 +0100

Add API that allows the error status for the response to be reset

This is required to fix an issue with async where a dispatch after an
error is still flagged as an error which causes the dispatch to be
skipped.
---
 java/org/apache/catalina/connector/Response.java | 5 +
 java/org/apache/coyote/Response.java | 7 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/connector/Response.java 
b/java/org/apache/catalina/connector/Response.java
index 06b0e4fad7..d751dc231f 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -429,6 +429,11 @@ public class Response implements HttpServletResponse {
 }
 
 
+public void resetError() {
+getCoyoteResponse().resetError();
+}
+
+
 /**
  * Perform whatever actions are required to flush and close the output 
stream or writer, in a single operation.
  *
diff --git a/java/org/apache/coyote/Response.java 
b/java/org/apache/coyote/Response.java
index 4af1c8a4c7..6ff483b09e 100644
--- a/java/org/apache/coyote/Response.java
+++ b/java/org/apache/coyote/Response.java
@@ -332,6 +332,11 @@ public final class Response {
 }
 
 
+public void resetError() {
+errorState.set(0);
+}
+
+
 //  Methods 
 
 public void reset() throws IllegalStateException {
@@ -624,7 +629,7 @@ public final class Response {
 committed = false;
 commitTime = -1;
 errorException = null;
-errorState.set(0);
+resetError();
 headers.recycle();
 trailerFieldsSupplier = null;
 // Servlet 3.1 non-blocking write listener


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 10.1.x updated: Add API that allows the error status for the response to be reset

2024-04-18 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
 new f14a31b109 Add API that allows the error status for the response to be 
reset
f14a31b109 is described below

commit f14a31b1092310a2ed74669ee63400fa9efb9ecd
Author: Mark Thomas 
AuthorDate: Thu Apr 18 19:45:41 2024 +0100

Add API that allows the error status for the response to be reset

This is required to fix an issue with async where a dispatch after an
error is still flagged as an error which causes the dispatch to be
skipped.
---
 java/org/apache/catalina/connector/Response.java | 5 +
 java/org/apache/coyote/Response.java | 7 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/connector/Response.java 
b/java/org/apache/catalina/connector/Response.java
index f1e496e681..b5906ed7f8 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -406,6 +406,11 @@ public class Response implements HttpServletResponse {
 }
 
 
+public void resetError() {
+getCoyoteResponse().resetError();
+}
+
+
 /**
  * Perform whatever actions are required to flush and close the output 
stream or writer, in a single operation.
  *
diff --git a/java/org/apache/coyote/Response.java 
b/java/org/apache/coyote/Response.java
index b1d88ee267..bc29233776 100644
--- a/java/org/apache/coyote/Response.java
+++ b/java/org/apache/coyote/Response.java
@@ -342,6 +342,11 @@ public final class Response {
 }
 
 
+public void resetError() {
+errorState.set(0);
+}
+
+
 //  Methods 
 
 public void reset() throws IllegalStateException {
@@ -634,7 +639,7 @@ public final class Response {
 committed = false;
 commitTimeNanos = -1;
 errorException = null;
-errorState.set(0);
+resetError();
 headers.recycle();
 trailerFieldsSupplier = null;
 // Servlet 3.1 non-blocking write listener


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch main updated: Add API that allows the error status for the response to be reset

2024-04-18 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
 new 21837baca3 Add API that allows the error status for the response to be 
reset
21837baca3 is described below

commit 21837baca3c764608173f4a5c69e85307cf92b18
Author: Mark Thomas 
AuthorDate: Thu Apr 18 19:45:41 2024 +0100

Add API that allows the error status for the response to be reset

This is required to fix an issue with async where a dispatch after an
error is still flagged as an error which causes the dispatch to be
skipped.
---
 java/org/apache/catalina/connector/Response.java | 5 +
 java/org/apache/coyote/Response.java | 7 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/connector/Response.java 
b/java/org/apache/catalina/connector/Response.java
index 0effa36218..a0d7c8d932 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -373,6 +373,11 @@ public class Response implements HttpServletResponse {
 }
 
 
+public void resetError() {
+getCoyoteResponse().resetError();
+}
+
+
 /**
  * Perform whatever actions are required to flush and close the output 
stream or writer, in a single operation.
  *
diff --git a/java/org/apache/coyote/Response.java 
b/java/org/apache/coyote/Response.java
index 8bc89249b7..ae157bfd6b 100644
--- a/java/org/apache/coyote/Response.java
+++ b/java/org/apache/coyote/Response.java
@@ -333,6 +333,11 @@ public final class Response {
 }
 
 
+public void resetError() {
+errorState.set(0);
+}
+
+
 //  Methods 
 
 public void reset() throws IllegalStateException {
@@ -656,7 +661,7 @@ public final class Response {
 committed = false;
 commitTimeNanos = -1;
 errorException = null;
-errorState.set(0);
+resetError();
 headers.recycle();
 trailerFieldsSupplier = null;
 // Servlet 3.1 non-blocking write listener


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 9.0.x updated: Remove commented out code.

2024-04-18 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt 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 01533cff0e Remove commented out code.
01533cff0e is described below

commit 01533cff0e01f45a42b74790eab28ef333f73fee
Author: Mark Thomas 
AuthorDate: Thu Apr 18 19:39:54 2024 +0100

Remove commented out code.
---
 test/javax/servlet/http/TestHttpServletResponseSendError.java | 9 -
 1 file changed, 9 deletions(-)

diff --git a/test/javax/servlet/http/TestHttpServletResponseSendError.java 
b/test/javax/servlet/http/TestHttpServletResponseSendError.java
index bdd7ca4879..8d99321a70 100644
--- a/test/javax/servlet/http/TestHttpServletResponseSendError.java
+++ b/test/javax/servlet/http/TestHttpServletResponseSendError.java
@@ -283,15 +283,6 @@ public class TestHttpServletResponseSendError extends 
TomcatBaseTest {
 e.printStackTrace();
 }
 
-/*
-if (errorPoint == AsyncErrorPoint.THREAD_B_AFTER_COMPLETE) {
-if (useDispatch) {
-ac.complete();
-} else {
-ac.dispatch("/dispatch");
-}
-}
- */
 if (throwException) {
 throw new SendErrorException();
 } else {


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 10.1.x updated: Remove commented out code.

2024-04-18 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 7435b0dd1d Remove commented out code.
7435b0dd1d is described below

commit 7435b0dd1d39787ed754647943f4a2dcb70e15fc
Author: Mark Thomas 
AuthorDate: Thu Apr 18 19:39:54 2024 +0100

Remove commented out code.
---
 test/jakarta/servlet/http/TestHttpServletResponseSendError.java | 9 -
 1 file changed, 9 deletions(-)

diff --git a/test/jakarta/servlet/http/TestHttpServletResponseSendError.java 
b/test/jakarta/servlet/http/TestHttpServletResponseSendError.java
index 1b777d108f..94cd9dd0c1 100644
--- a/test/jakarta/servlet/http/TestHttpServletResponseSendError.java
+++ b/test/jakarta/servlet/http/TestHttpServletResponseSendError.java
@@ -283,15 +283,6 @@ public class TestHttpServletResponseSendError extends 
TomcatBaseTest {
 e.printStackTrace();
 }
 
-/*
-if (errorPoint == AsyncErrorPoint.THREAD_B_AFTER_COMPLETE) {
-if (useDispatch) {
-ac.complete();
-} else {
-ac.dispatch("/dispatch");
-}
-}
- */
 if (throwException) {
 throw new SendErrorException();
 } else {


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch main updated: Remove commented out code.

2024-04-18 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
 new 9328072d13 Remove commented out code.
9328072d13 is described below

commit 9328072d1359a31fc7b74a8eda05392bf697854e
Author: Mark Thomas 
AuthorDate: Thu Apr 18 19:39:54 2024 +0100

Remove commented out code.
---
 test/jakarta/servlet/http/TestHttpServletResponseSendError.java | 9 -
 1 file changed, 9 deletions(-)

diff --git a/test/jakarta/servlet/http/TestHttpServletResponseSendError.java 
b/test/jakarta/servlet/http/TestHttpServletResponseSendError.java
index 1b777d108f..94cd9dd0c1 100644
--- a/test/jakarta/servlet/http/TestHttpServletResponseSendError.java
+++ b/test/jakarta/servlet/http/TestHttpServletResponseSendError.java
@@ -283,15 +283,6 @@ public class TestHttpServletResponseSendError extends 
TomcatBaseTest {
 e.printStackTrace();
 }
 
-/*
-if (errorPoint == AsyncErrorPoint.THREAD_B_AFTER_COMPLETE) {
-if (useDispatch) {
-ac.complete();
-} else {
-ac.dispatch("/dispatch");
-}
-}
- */
 if (throwException) {
 throw new SendErrorException();
 } else {


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 02/02: Fix typo

2024-04-17 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 15d192a944580be723fa1df53e7e7d9cb68f762d
Author: Mark Thomas 
AuthorDate: Wed Apr 17 12:56:17 2024 +0100

Fix typo
---
 webapps/docs/architecture/startup/6_catalina_start_4.svg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/webapps/docs/architecture/startup/6_catalina_start_4.svg 
b/webapps/docs/architecture/startup/6_catalina_start_4.svg
index 74e24e2927..3595e8f2de 100644
--- a/webapps/docs/architecture/startup/6_catalina_start_4.svg
+++ b/webapps/docs/architecture/startup/6_catalina_start_4.svg
@@ -629,7 +629,7 @@
 >createWarpper() // Invoked by a WebWrapperRule (not Directly by the 
Digester)createWrapper() // Invoked by a WebWrapperRule (not Directly by the 
Digester)

(tomcat) branch main updated (79009baf0a -> 15d192a944)

2024-04-17 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from 79009baf0a Align NioChannel and SecureNioChannel
 new f6d0e9cfa8 Convert original Rational Rose mdl file to svgs
 new 15d192a944 Fix typo

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../docs/architecture/startup/1_catalina_load.svg  | 523 ++
 .../architecture/startup/2_catalina_initliaze.svg  | 333 +
 .../architecture/startup/3_catalina_start_1.svg| 762 +
 .../architecture/startup/4_catalina_start_2.svg| 559 +++
 .../architecture/startup/5_catalina_start_3.svg| 394 +++
 .../architecture/startup/6_catalina_start_4.svg| 723 +++
 6 files changed, 3294 insertions(+)
 create mode 100644 webapps/docs/architecture/startup/1_catalina_load.svg
 create mode 100644 webapps/docs/architecture/startup/2_catalina_initliaze.svg
 create mode 100644 webapps/docs/architecture/startup/3_catalina_start_1.svg
 create mode 100644 webapps/docs/architecture/startup/4_catalina_start_2.svg
 create mode 100644 webapps/docs/architecture/startup/5_catalina_start_3.svg
 create mode 100644 webapps/docs/architecture/startup/6_catalina_start_4.svg


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch main updated: Align NioChannel and SecureNioChannel

2024-04-17 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
 new 79009baf0a Align NioChannel and SecureNioChannel
79009baf0a is described below

commit 79009baf0af9e0f2b02753a352e31e5bb3f85396
Author: Mark Thomas 
AuthorDate: Wed Apr 17 10:42:29 2024 +0100

Align NioChannel and SecureNioChannel

Skipping empty writes can provide a performance improvement for some
frameworks - typically those that call flush() more than they need to
---
 java/org/apache/tomcat/util/net/NioChannel.java | 4 
 webapps/docs/changelog.xml  | 4 
 2 files changed, 8 insertions(+)

diff --git a/java/org/apache/tomcat/util/net/NioChannel.java 
b/java/org/apache/tomcat/util/net/NioChannel.java
index 6ddf5637f0..c350577a4b 100644
--- a/java/org/apache/tomcat/util/net/NioChannel.java
+++ b/java/org/apache/tomcat/util/net/NioChannel.java
@@ -115,6 +115,10 @@ public class NioChannel implements ByteChannel, 
ScatteringByteChannel, Gathering
 @Override
 public int write(ByteBuffer src) throws IOException {
 checkInterruptStatus();
+if (!src.hasRemaining()) {
+// Nothing left to write
+return 0;
+}
 return sc.write(src);
 }
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 0cf84d9b86..8ef77e52aa 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -130,6 +130,10 @@
   
 Add OpenSSL FFM classes to tomcat-embed-core.jar. (remm)
   
+  
+Align non-secure and secure writes with NIO and skip the write attempt
+when there are no bytes to be written. (markt)
+  
 
   
   


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 9.0.x updated: Align NioChannel and SecureNioChannel

2024-04-17 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt 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 72823b4ea0 Align NioChannel and SecureNioChannel
72823b4ea0 is described below

commit 72823b4ea06b68ece3663d8d8d998359967673b0
Author: Mark Thomas 
AuthorDate: Wed Apr 17 10:42:29 2024 +0100

Align NioChannel and SecureNioChannel

Skipping empty writes can provide a performance improvement for some
frameworks - typically those that call flush() more than they need to
---
 java/org/apache/tomcat/util/net/NioChannel.java | 4 
 webapps/docs/changelog.xml  | 8 
 2 files changed, 12 insertions(+)

diff --git a/java/org/apache/tomcat/util/net/NioChannel.java 
b/java/org/apache/tomcat/util/net/NioChannel.java
index 96493ed75a..da0d165d1b 100644
--- a/java/org/apache/tomcat/util/net/NioChannel.java
+++ b/java/org/apache/tomcat/util/net/NioChannel.java
@@ -133,6 +133,10 @@ public class NioChannel implements ByteChannel, 
ScatteringByteChannel, Gathering
 @Override
 public int write(ByteBuffer src) throws IOException {
 checkInterruptStatus();
+if (!src.hasRemaining()) {
+// Nothing left to write
+return 0;
+}
 return sc.write(src);
 }
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index d24e2b190a..de4e1b77a2 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -127,6 +127,14 @@
   
 
   
+  
+
+  
+Align non-secure and secure writes with NIO and skip the write attempt
+when there are no bytes to be written. (markt)
+  
+
+  
   
 
   


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 10.1.x updated: Align NioChannel and SecureNioChannel

2024-04-17 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 474701d1c4 Align NioChannel and SecureNioChannel
474701d1c4 is described below

commit 474701d1c4872bcd9e530444d61677863d8bc09d
Author: Mark Thomas 
AuthorDate: Wed Apr 17 10:42:29 2024 +0100

Align NioChannel and SecureNioChannel

Skipping empty writes can provide a performance improvement for some
frameworks - typically those that call flush() more than they need to
---
 java/org/apache/tomcat/util/net/NioChannel.java | 4 
 webapps/docs/changelog.xml  | 4 
 2 files changed, 8 insertions(+)

diff --git a/java/org/apache/tomcat/util/net/NioChannel.java 
b/java/org/apache/tomcat/util/net/NioChannel.java
index 6ddf5637f0..c350577a4b 100644
--- a/java/org/apache/tomcat/util/net/NioChannel.java
+++ b/java/org/apache/tomcat/util/net/NioChannel.java
@@ -115,6 +115,10 @@ public class NioChannel implements ByteChannel, 
ScatteringByteChannel, Gathering
 @Override
 public int write(ByteBuffer src) throws IOException {
 checkInterruptStatus();
+if (!src.hasRemaining()) {
+// Nothing left to write
+return 0;
+}
 return sc.write(src);
 }
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 423e024c74..ff466e8bdd 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -135,6 +135,10 @@
   
 Add OpenSSL FFM classes to tomcat-embed-core.jar. (remm)
   
+  
+Align non-secure and secure writes with NIO and skip the write attempt
+when there are no bytes to be written. (markt)
+  
 
   
   


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 01/02: This appears to be unnecessary with Eclipse 4.31+

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 592d75ca528fb9dd22eb32675a3acf9a35202782
Author: Mark Thomas 
AuthorDate: Tue Apr 16 19:42:50 2024 +0100

This appears to be unnecessary with Eclipse 4.31+
---
 java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java | 1 -
 1 file changed, 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java 
b/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java
index 6f6f381578..20ed59a3f9 100644
--- a/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java
+++ b/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java
@@ -1165,7 +1165,6 @@ public class ThreadPoolExecutor extends 
AbstractExecutorService {
  *
  * @param w the worker
  */
-@SuppressWarnings("null")  // task cannot be null
 final void runWorker(Worker w) {
 Thread wt = Thread.currentThread();
 Runnable task = w.firstTask;


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 02/02: Silence remaining IDE wanrings for 9.0.x with Eclipse 4.31+

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 2d5b58fbe9becc36da7e165c1ef3ecdf5d691878
Author: Mark Thomas 
AuthorDate: Tue Apr 16 19:43:59 2024 +0100

Silence remaining IDE wanrings for 9.0.x with Eclipse 4.31+
---
 java/org/apache/catalina/connector/InputBuffer.java | 1 +
 1 file changed, 1 insertion(+)

diff --git a/java/org/apache/catalina/connector/InputBuffer.java 
b/java/org/apache/catalina/connector/InputBuffer.java
index 162c6fd314..347f7b6291 100644
--- a/java/org/apache/catalina/connector/InputBuffer.java
+++ b/java/org/apache/catalina/connector/InputBuffer.java
@@ -324,6 +324,7 @@ public class InputBuffer extends Reader implements 
ByteChunk.ByteInputChannel, A
 }
 
 
+@SuppressWarnings("deprecation")
 private void handleReadException(Exception e) throws IOException {
 // Set flag used by asynchronous processing to detect errors on 
non-container threads
 coyoteRequest.setErrorException(e);


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 9.0.x updated (6b850a416a -> 2d5b58fbe9)

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from 6b850a416a Fix order and typo
 new 592d75ca52 This appears to be unnecessary with Eclipse 4.31+
 new 2d5b58fbe9 Silence remaining IDE wanrings for 9.0.x with Eclipse 4.31+

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/org/apache/catalina/connector/InputBuffer.java | 1 +
 java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 10.1.x updated: Silence remaining IDE wanrings for 10.1.x with Eclipse 4.31+

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
 new bbb3821e56 Silence remaining IDE wanrings for 10.1.x with Eclipse 4.31+
bbb3821e56 is described below

commit bbb3821e56e4b9928b09d0ce6057f5f1500c960f
Author: Mark Thomas 
AuthorDate: Tue Apr 16 19:43:59 2024 +0100

Silence remaining IDE wanrings for 10.1.x with Eclipse 4.31+
---
 java/org/apache/catalina/connector/InputBuffer.java | 1 +
 1 file changed, 1 insertion(+)

diff --git a/java/org/apache/catalina/connector/InputBuffer.java 
b/java/org/apache/catalina/connector/InputBuffer.java
index e22ef9694c..b708466f3d 100644
--- a/java/org/apache/catalina/connector/InputBuffer.java
+++ b/java/org/apache/catalina/connector/InputBuffer.java
@@ -324,6 +324,7 @@ public class InputBuffer extends Reader implements 
ByteChunk.ByteInputChannel, A
 }
 
 
+@SuppressWarnings("deprecation")
 private void handleReadException(Exception e) throws IOException {
 // Set flag used by asynchronous processing to detect errors on 
non-container threads
 coyoteRequest.setErrorException(e);


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 10.1.x updated: This appears to be unnecessary with Eclipse 4.31+

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 143484b769 This appears to be unnecessary with Eclipse 4.31+
143484b769 is described below

commit 143484b769af938c828cbf12f8ac54ca114267bb
Author: Mark Thomas 
AuthorDate: Tue Apr 16 19:42:50 2024 +0100

This appears to be unnecessary with Eclipse 4.31+
---
 java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java | 1 -
 1 file changed, 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java 
b/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java
index 7b7a919a91..c2e1c3a582 100644
--- a/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java
+++ b/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java
@@ -1165,7 +1165,6 @@ public class ThreadPoolExecutor extends 
AbstractExecutorService {
  *
  * @param w the worker
  */
-@SuppressWarnings("null")  // task cannot be null
 final void runWorker(Worker w) {
 Thread wt = Thread.currentThread();
 Runnable task = w.firstTask;


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch main updated: Update the @SuppressWarnings for Eclipse 4.32M1 and Java 22

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
 new dab2b10275 Update the @SuppressWarnings for Eclipse 4.32M1 and Java 22
dab2b10275 is described below

commit dab2b1027521ccad85685a7c2b868fc4abab82c8
Author: Mark Thomas 
AuthorDate: Tue Apr 16 19:27:30 2024 +0100

Update the @SuppressWarnings for Eclipse 4.32M1 and Java 22
---
 java/org/apache/catalina/authenticator/SpnegoAuthenticator.java  | 1 +
 java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java | 2 ++
 java/org/apache/catalina/valves/StuckThreadDetectionValve.java   | 5 +
 java/org/apache/catalina/webresources/CachedResource.java| 1 +
 java/org/apache/coyote/Request.java  | 2 ++
 java/org/apache/tomcat/dbcp/dbcp2/DelegatingStatement.java   | 2 +-
 java/org/apache/tomcat/util/Diagnostics.java | 1 +
 test/org/apache/juli/TestThreadNameCache.java| 1 +
 8 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java 
b/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java
index ab4a8c3287..dab5cdfed3 100644
--- a/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java
+++ b/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java
@@ -134,6 +134,7 @@ public class SpnegoAuthenticator extends AuthenticatorBase {
 }
 
 
+@SuppressWarnings("removal")
 @Override
 protected boolean doAuthenticate(Request request, HttpServletResponse 
response) throws IOException {
 
diff --git 
a/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java 
b/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java
index c413317186..8c70ac3401 100644
--- a/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java
+++ b/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java
@@ -119,9 +119,11 @@ public class ThreadLocalLeakPreventionListener extends 
FrameworkListener {
 }
 
 if (executor instanceof ThreadPoolExecutor) {
+@SuppressWarnings("resource")
 ThreadPoolExecutor threadPoolExecutor = 
(ThreadPoolExecutor) executor;
 threadPoolExecutor.contextStopping();
 } else if (executor instanceof StandardThreadExecutor) {
+@SuppressWarnings("resource")
 StandardThreadExecutor stdThreadExecutor = 
(StandardThreadExecutor) executor;
 stdThreadExecutor.contextStopping();
 }
diff --git a/java/org/apache/catalina/valves/StuckThreadDetectionValve.java 
b/java/org/apache/catalina/valves/StuckThreadDetectionValve.java
index a523029d75..0e451d5a0c 100644
--- a/java/org/apache/catalina/valves/StuckThreadDetectionValve.java
+++ b/java/org/apache/catalina/valves/StuckThreadDetectionValve.java
@@ -135,6 +135,7 @@ public class StuckThreadDetectionValve extends ValveBase {
 
 private void notifyStuckThreadDetected(MonitoredThread monitoredThread, 
long activeTime, int numStuckThreads) {
 if (log.isWarnEnabled()) {
+@SuppressWarnings("deprecation")
 String msg = 
sm.getString("stuckThreadDetectionValve.notifyStuckThreadDetected",
 monitoredThread.getThread().getName(), 
Long.valueOf(activeTime), monitoredThread.getStartTime(),
 Integer.valueOf(numStuckThreads), 
monitoredThread.getRequestUri(), Integer.valueOf(threshold),
@@ -171,6 +172,7 @@ public class StuckThreadDetectionValve extends ValveBase {
 // GC'ing, as the reference is removed from the Map in the finally 
clause
 
 Thread currentThread = Thread.currentThread();
+@SuppressWarnings("deprecation")
 Long key = Long.valueOf(currentThread.getId());
 StringBuffer requestUrl = request.getRequestURL();
 if (request.getQueryString() != null) {
@@ -227,6 +229,7 @@ public class StuckThreadDetectionValve extends ValveBase {
 return stuckCount.get();
 }
 
+@SuppressWarnings("deprecation")
 public long[] getStuckThreadIds() {
 List idList = new ArrayList<>();
 for (MonitoredThread monitoredThread : activeThreads.values()) {
@@ -342,6 +345,7 @@ public class StuckThreadDetectionValve extends ValveBase {
 }
 try {
 if (log.isWarnEnabled()) {
+@SuppressWarnings("deprecation")
 String msg = 
sm.getString("stuckThreadDetectionValve.notifyStuckThreadInterrupted",
 this.getThread().getName(), 
Long.valueOf(getActiveTimeInMillis()), this.getStartT

(tomcat) branch main updated: This appears to be unnecessary with Java 17+ and the Eclipse 4.31

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
 new 5495a4a2da This appears to be unnecessary with Java 17+ and the 
Eclipse 4.31
5495a4a2da is described below

commit 5495a4a2dac7189322f8f8bbe5c00e64997d4797
Author: Mark Thomas 
AuthorDate: Tue Apr 16 18:48:30 2024 +0100

This appears to be unnecessary with Java 17+ and the Eclipse 4.31
---
 java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java | 1 -
 1 file changed, 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java 
b/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java
index 2cde45c15d..cc9fc70cf6 100644
--- a/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java
+++ b/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java
@@ -1123,7 +1123,6 @@ public class ThreadPoolExecutor extends 
AbstractExecutorService {
  *
  * @param w the worker
  */
-@SuppressWarnings("null")  // task cannot be null
 final void runWorker(Worker w) {
 Thread wt = Thread.currentThread();
 Runnable task = w.firstTask;


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch main updated: Fix order and typo

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
 new a91f8d0fbf Fix order and typo
a91f8d0fbf is described below

commit a91f8d0fbf091904cd6baaab5027e766c8da2e91
Author: Mark Thomas 
AuthorDate: Tue Apr 16 17:27:37 2024 +0100

Fix order and typo
---
 res/ide-support/eclipse/java-compiler-errors-warnings.txt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/res/ide-support/eclipse/java-compiler-errors-warnings.txt 
b/res/ide-support/eclipse/java-compiler-errors-warnings.txt
index 3c1ce23c03..8078c129d7 100644
--- a/res/ide-support/eclipse/java-compiler-errors-warnings.txt
+++ b/res/ide-support/eclipse/java-compiler-errors-warnings.txt
@@ -18,7 +18,7 @@
 # Java -> Compiler -> Errors/Warnings
 ===
 
-The following settings are for Eclipse 4.15
+The following settings are for Eclipse 4.15 onwards
 W = Warning
 I = Ignore
 E = Error
@@ -40,10 +40,10 @@ Potential programming problems
  - All  - W
except the following:
 
+   - Unlikely argument type for...- W
+ [ ] Perform strict...
- Incomplete 'switch' cases on enum- W
  [ ] Signal even if 'default' case exists
-   - Unlikely argument type for...- W
- [ ] Perfprm strict...
- 'switch' is missing 'default' case   - I
- Potential resource leak  - I
 


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 9.0.x updated: Fix order and typo

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt 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 6b850a416a Fix order and typo
6b850a416a is described below

commit 6b850a416a0a85c42d4d78796d0aa2798b94a16d
Author: Mark Thomas 
AuthorDate: Tue Apr 16 17:27:37 2024 +0100

Fix order and typo
---
 res/ide-support/eclipse/java-compiler-errors-warnings.txt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/res/ide-support/eclipse/java-compiler-errors-warnings.txt 
b/res/ide-support/eclipse/java-compiler-errors-warnings.txt
index 3c1ce23c03..8078c129d7 100644
--- a/res/ide-support/eclipse/java-compiler-errors-warnings.txt
+++ b/res/ide-support/eclipse/java-compiler-errors-warnings.txt
@@ -18,7 +18,7 @@
 # Java -> Compiler -> Errors/Warnings
 ===
 
-The following settings are for Eclipse 4.15
+The following settings are for Eclipse 4.15 onwards
 W = Warning
 I = Ignore
 E = Error
@@ -40,10 +40,10 @@ Potential programming problems
  - All  - W
except the following:
 
+   - Unlikely argument type for...- W
+ [ ] Perform strict...
- Incomplete 'switch' cases on enum- W
  [ ] Signal even if 'default' case exists
-   - Unlikely argument type for...- W
- [ ] Perfprm strict...
- 'switch' is missing 'default' case   - I
- Potential resource leak  - I
 


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 10.1.x updated: Fix order and typo

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 0073ca2b1a Fix order and typo
0073ca2b1a is described below

commit 0073ca2b1ad3fff4e5d3c3941dc7bdf508378508
Author: Mark Thomas 
AuthorDate: Tue Apr 16 17:27:37 2024 +0100

Fix order and typo
---
 res/ide-support/eclipse/java-compiler-errors-warnings.txt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/res/ide-support/eclipse/java-compiler-errors-warnings.txt 
b/res/ide-support/eclipse/java-compiler-errors-warnings.txt
index 3c1ce23c03..8078c129d7 100644
--- a/res/ide-support/eclipse/java-compiler-errors-warnings.txt
+++ b/res/ide-support/eclipse/java-compiler-errors-warnings.txt
@@ -18,7 +18,7 @@
 # Java -> Compiler -> Errors/Warnings
 ===
 
-The following settings are for Eclipse 4.15
+The following settings are for Eclipse 4.15 onwards
 W = Warning
 I = Ignore
 E = Error
@@ -40,10 +40,10 @@ Potential programming problems
  - All  - W
except the following:
 
+   - Unlikely argument type for...- W
+ [ ] Perform strict...
- Incomplete 'switch' cases on enum- W
  [ ] Signal even if 'default' case exists
-   - Unlikely argument type for...- W
- [ ] Perfprm strict...
- 'switch' is missing 'default' case   - I
- Potential resource leak  - I
 


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 01/02: Switch to the Base64 encoder and decoder provided by the JRE.

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 9ce43c498064e54504c29af65d32cd815f1ee0f9
Author: Mark Thomas 
AuthorDate: Tue Apr 16 15:31:37 2024 +0100

Switch to the Base64 encoder and decoder provided by the JRE.

This removes the dependency on the internal fork of Commons Codec.
---
 .../authenticator/SpnegoAuthenticator.java |  9 +++
 .../realm/MessageDigestCredentialHandler.java  |  6 ++---
 .../apache/coyote/http2/Http2UpgradeHandler.java   |  4 ++--
 .../http/fileupload/util/mime/MimeUtility.java |  5 ++--
 .../tomcat/util/http/parser/StructuredField.java   |  4 ++--
 java/org/apache/tomcat/util/net/jsse/PEMFile.java  |  7 +++---
 .../tomcat/websocket/WsWebSocketContainer.java |  4 ++--
 .../tomcat/websocket/server/UpgradeUtil.java   | 28 +++---
 .../authenticator/TestAuthInfoResponseHeaders.java |  4 ++--
 .../TestNonLoginAndBasicAuthenticator.java |  4 ++--
 .../TestSSOnonLoginAndBasicAuthenticator.java  |  4 ++--
 .../core/TestPropertiesRoleMappingListener.java|  4 ++--
 .../filters/TestRestCsrfPreventionFilter2.java |  4 ++--
 test/org/apache/coyote/http2/Http2TestBase.java|  4 ++--
 webapps/docs/changelog.xml |  8 +++
 15 files changed, 47 insertions(+), 52 deletions(-)

diff --git a/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java 
b/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java
index 08ae4e1426..7f7656dae4 100644
--- a/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java
+++ b/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java
@@ -22,6 +22,7 @@ import java.security.Principal;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
+import java.util.Base64;
 import java.util.LinkedHashMap;
 import java.util.regex.Pattern;
 
@@ -37,7 +38,6 @@ import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.buf.ByteChunk;
 import org.apache.tomcat.util.buf.MessageBytes;
-import org.apache.tomcat.util.codec.binary.Base64;
 import org.apache.tomcat.util.compat.JreVendor;
 import org.ietf.jgss.GSSContext;
 import org.ietf.jgss.GSSCredential;
@@ -165,8 +165,9 @@ public class SpnegoAuthenticator extends AuthenticatorBase {
 
 authorizationBC.setOffset(authorizationBC.getOffset() + 10);
 
-byte[] decoded = Base64.decodeBase64(authorizationBC.getBuffer(), 
authorizationBC.getOffset(),
-authorizationBC.getLength());
+byte[] encoded = new byte[authorizationBC.getLength()];
+System.arraycopy(authorizationBC.getBuffer(), 0, encoded, 0, 
authorizationBC.getLength());
+byte[] decoded = Base64.getDecoder().decode(encoded);
 
 if (getApplyJava8u40Fix()) {
 SpnegoTokenFixer.fix(decoded);
@@ -263,7 +264,7 @@ public class SpnegoAuthenticator extends AuthenticatorBase {
 }
 
 // Send response token on success and failure
-response.setHeader(AUTH_HEADER_NAME, AUTH_HEADER_VALUE_NEGOTIATE + " " 
+ Base64.encodeBase64String(outToken));
+response.setHeader(AUTH_HEADER_NAME, AUTH_HEADER_VALUE_NEGOTIATE + " " 
+ Base64.getEncoder().encodeToString(outToken));
 
 if (principal != null) {
 register(request, response, principal, Constants.SPNEGO_METHOD, 
principal.getName(), null);
diff --git a/java/org/apache/catalina/realm/MessageDigestCredentialHandler.java 
b/java/org/apache/catalina/realm/MessageDigestCredentialHandler.java
index 7945af8490..e3aa771d60 100644
--- a/java/org/apache/catalina/realm/MessageDigestCredentialHandler.java
+++ b/java/org/apache/catalina/realm/MessageDigestCredentialHandler.java
@@ -21,12 +21,12 @@ import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.security.NoSuchAlgorithmException;
 import java.util.Arrays;
+import java.util.Base64;
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.buf.B2CConverter;
 import org.apache.tomcat.util.buf.HexUtils;
-import org.apache.tomcat.util.codec.binary.Base64;
 import org.apache.tomcat.util.security.ConcurrentMessageDigest;
 
 /**
@@ -110,7 +110,7 @@ public class MessageDigestCredentialHandler extends 
DigestCredentialHandlerBase
 String base64ServerDigest = storedCredentials.substring(5);
 byte[] userDigest = 
ConcurrentMessageDigest.digest(getAlgorithm(),
 
inputCredentials.getBytes(StandardCharsets.ISO_8859_1));
-String base64UserDigest = 
Base64.encodeBase64String(userDigest);
+String base64UserDigest = 
Base64.getEncoder().encodeToString(userDigest);
 
 return DigestCredentialHandlerBase.equ

(tomcat) 02/02: Deprecate the internal fork of Commons Codec

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 64746104ce3e06da628c86679a2bca63a4fd94d6
Author: Mark Thomas 
AuthorDate: Tue Apr 16 15:37:40 2024 +0100

Deprecate the internal fork of Commons Codec
---
 java/org/apache/tomcat/util/codec/binary/Base64.java   | 3 +++
 java/org/apache/tomcat/util/codec/binary/BaseNCodec.java   | 3 +++
 java/org/apache/tomcat/util/codec/binary/StringUtils.java  | 3 +++
 java/org/apache/tomcat/util/codec/binary/package-info.java | 2 ++
 webapps/docs/changelog.xml | 4 +++-
 5 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/codec/binary/Base64.java 
b/java/org/apache/tomcat/util/codec/binary/Base64.java
index e38bf3df17..5f6fdbd7a5 100644
--- a/java/org/apache/tomcat/util/codec/binary/Base64.java
+++ b/java/org/apache/tomcat/util/codec/binary/Base64.java
@@ -46,7 +46,10 @@ package org.apache.tomcat.util.codec.binary;
  *
  * @see http://www.ietf.org/rfc/rfc2045.txt;>RFC 2045
  * @since 1.0
+ *
+ * @deprecated Unused. This class will be removed in Tomcat 11 onwards.
  */
+@Deprecated
 public class Base64 extends BaseNCodec {
 
 /**
diff --git a/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java 
b/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
index 7492773fe0..2eaa78e940 100644
--- a/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
+++ b/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
@@ -27,7 +27,10 @@ import org.apache.tomcat.util.res.StringManager;
  * 
  * This class is thread-safe.
  * 
+ *
+ * @deprecated Unused. This class will be removed in Tomcat 11 onwards.
  */
+@Deprecated
 public abstract class BaseNCodec {
 
 protected static final StringManager sm = 
StringManager.getManager(BaseNCodec.class);
diff --git a/java/org/apache/tomcat/util/codec/binary/StringUtils.java 
b/java/org/apache/tomcat/util/codec/binary/StringUtils.java
index ab050f3509..619964105b 100644
--- a/java/org/apache/tomcat/util/codec/binary/StringUtils.java
+++ b/java/org/apache/tomcat/util/codec/binary/StringUtils.java
@@ -29,7 +29,10 @@ import java.nio.charset.StandardCharsets;
  * @see Charset
  * @see StandardCharsets
  * @since 1.4
+ *
+ * @deprecated Unused. This class will be removed in Tomcat 11 onwards.
  */
+@Deprecated
 public class StringUtils {
 
 /**
diff --git a/java/org/apache/tomcat/util/codec/binary/package-info.java 
b/java/org/apache/tomcat/util/codec/binary/package-info.java
index 605aeded44..c41bd15a4e 100644
--- a/java/org/apache/tomcat/util/codec/binary/package-info.java
+++ b/java/org/apache/tomcat/util/codec/binary/package-info.java
@@ -17,5 +17,7 @@
 
 /**
  * Base64 String encoding and decoding.
+ *
+ * Unused. This package will be removed in Tomcat 11 onwards.
  */
 package org.apache.tomcat.util.codec.binary;
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 95655b67a4..d24e2b190a 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -131,7 +131,9 @@
 
   
 Switch to using the Base64 encoder and decoder provided by the JRE
-rather than the version provided by Commons Codec. (markt)
+rather than the version provided by Commons Codec. The internal fork of
+Commons Codec has been deprecated and will be removed in Tomcat 11.
+    (markt)
   
 
   


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 9.0.x updated (d7ae6515dc -> 64746104ce)

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from d7ae6515dc Fix Gump issue - Gump tests with OpenSSL master which is 
now 3.4.x
 new 9ce43c4980 Switch to the Base64 encoder and decoder provided by the 
JRE.
 new 64746104ce Deprecate the internal fork of Commons Codec

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../authenticator/SpnegoAuthenticator.java |  9 +++
 .../realm/MessageDigestCredentialHandler.java  |  6 ++---
 .../apache/coyote/http2/Http2UpgradeHandler.java   |  4 ++--
 .../apache/tomcat/util/codec/binary/Base64.java|  3 +++
 .../tomcat/util/codec/binary/BaseNCodec.java   |  3 +++
 .../tomcat/util/codec/binary/StringUtils.java  |  3 +++
 .../tomcat/util/codec/binary/package-info.java |  2 ++
 .../http/fileupload/util/mime/MimeUtility.java |  5 ++--
 .../tomcat/util/http/parser/StructuredField.java   |  4 ++--
 java/org/apache/tomcat/util/net/jsse/PEMFile.java  |  7 +++---
 .../tomcat/websocket/WsWebSocketContainer.java |  4 ++--
 .../tomcat/websocket/server/UpgradeUtil.java   | 28 +++---
 .../authenticator/TestAuthInfoResponseHeaders.java |  4 ++--
 .../TestNonLoginAndBasicAuthenticator.java |  4 ++--
 .../TestSSOnonLoginAndBasicAuthenticator.java  |  4 ++--
 .../core/TestPropertiesRoleMappingListener.java|  4 ++--
 .../filters/TestRestCsrfPreventionFilter2.java |  4 ++--
 test/org/apache/coyote/http2/Http2TestBase.java|  4 ++--
 webapps/docs/changelog.xml | 10 
 19 files changed, 60 insertions(+), 52 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 01/02: Switch to the Base64 encoder and decoder provided by the JRE.

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 2c470e1bb039e532f02d6e4a08efd21275a8d8e5
Author: Mark Thomas 
AuthorDate: Tue Apr 16 15:31:37 2024 +0100

Switch to the Base64 encoder and decoder provided by the JRE.

This removes the dependency on the internal fork of Commons Codec.
---
 .../authenticator/SpnegoAuthenticator.java |  9 +++
 .../realm/MessageDigestCredentialHandler.java  |  6 ++---
 .../apache/coyote/http2/Http2UpgradeHandler.java   |  4 ++--
 .../http/fileupload/util/mime/MimeUtility.java |  5 ++--
 .../tomcat/util/http/parser/StructuredField.java   |  4 ++--
 java/org/apache/tomcat/util/net/jsse/PEMFile.java  |  7 +++---
 .../tomcat/websocket/WsWebSocketContainer.java |  4 ++--
 .../tomcat/websocket/server/UpgradeUtil.java   | 28 +++---
 .../authenticator/TestAuthInfoResponseHeaders.java |  4 ++--
 .../TestNonLoginAndBasicAuthenticator.java |  4 ++--
 .../TestSSOnonLoginAndBasicAuthenticator.java  |  4 ++--
 .../core/TestPropertiesRoleMappingListener.java|  4 ++--
 .../filters/TestRestCsrfPreventionFilter2.java |  4 ++--
 test/org/apache/coyote/http2/Http2TestBase.java|  4 ++--
 webapps/docs/changelog.xml |  8 +++
 15 files changed, 47 insertions(+), 52 deletions(-)

diff --git a/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java 
b/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java
index 6377416ea4..ab4a8c3287 100644
--- a/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java
+++ b/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java
@@ -22,6 +22,7 @@ import java.security.Principal;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
+import java.util.Base64;
 import java.util.LinkedHashMap;
 import java.util.regex.Pattern;
 
@@ -38,7 +39,6 @@ import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.buf.ByteChunk;
 import org.apache.tomcat.util.buf.MessageBytes;
-import org.apache.tomcat.util.codec.binary.Base64;
 import org.apache.tomcat.util.compat.JreVendor;
 import org.ietf.jgss.GSSContext;
 import org.ietf.jgss.GSSCredential;
@@ -166,8 +166,9 @@ public class SpnegoAuthenticator extends AuthenticatorBase {
 
 authorizationBC.setOffset(authorizationBC.getOffset() + 10);
 
-byte[] decoded = Base64.decodeBase64(authorizationBC.getBuffer(), 
authorizationBC.getOffset(),
-authorizationBC.getLength());
+byte[] encoded = new byte[authorizationBC.getLength()];
+System.arraycopy(authorizationBC.getBuffer(), 0, encoded, 0, 
authorizationBC.getLength());
+byte[] decoded = Base64.getDecoder().decode(encoded);
 
 if (getApplyJava8u40Fix()) {
 SpnegoTokenFixer.fix(decoded);
@@ -264,7 +265,7 @@ public class SpnegoAuthenticator extends AuthenticatorBase {
 }
 
 // Send response token on success and failure
-response.setHeader(AUTH_HEADER_NAME, AUTH_HEADER_VALUE_NEGOTIATE + " " 
+ Base64.encodeBase64String(outToken));
+response.setHeader(AUTH_HEADER_NAME, AUTH_HEADER_VALUE_NEGOTIATE + " " 
+ Base64.getEncoder().encodeToString(outToken));
 
 if (principal != null) {
 register(request, response, principal, Constants.SPNEGO_METHOD, 
principal.getName(), null);
diff --git a/java/org/apache/catalina/realm/MessageDigestCredentialHandler.java 
b/java/org/apache/catalina/realm/MessageDigestCredentialHandler.java
index 7945af8490..e3aa771d60 100644
--- a/java/org/apache/catalina/realm/MessageDigestCredentialHandler.java
+++ b/java/org/apache/catalina/realm/MessageDigestCredentialHandler.java
@@ -21,12 +21,12 @@ import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.security.NoSuchAlgorithmException;
 import java.util.Arrays;
+import java.util.Base64;
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.buf.B2CConverter;
 import org.apache.tomcat.util.buf.HexUtils;
-import org.apache.tomcat.util.codec.binary.Base64;
 import org.apache.tomcat.util.security.ConcurrentMessageDigest;
 
 /**
@@ -110,7 +110,7 @@ public class MessageDigestCredentialHandler extends 
DigestCredentialHandlerBase
 String base64ServerDigest = storedCredentials.substring(5);
 byte[] userDigest = 
ConcurrentMessageDigest.digest(getAlgorithm(),
 
inputCredentials.getBytes(StandardCharsets.ISO_8859_1));
-String base64UserDigest = 
Base64.encodeBase64String(userDigest);
+String base64UserDigest = 
Base64.getEncoder().encodeToString(userDigest);
 
 return DigestCredentialHandlerBase.equ

(tomcat) 02/02: Deprecate the internal fork of Commons Codec

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 972f2913c46e6312cdba5d4d1e2a9362db778be4
Author: Mark Thomas 
AuthorDate: Tue Apr 16 15:37:40 2024 +0100

Deprecate the internal fork of Commons Codec
---
 java/org/apache/tomcat/util/codec/binary/Base64.java   | 3 +++
 java/org/apache/tomcat/util/codec/binary/BaseNCodec.java   | 3 +++
 java/org/apache/tomcat/util/codec/binary/StringUtils.java  | 3 +++
 java/org/apache/tomcat/util/codec/binary/package-info.java | 2 ++
 webapps/docs/changelog.xml | 4 +++-
 5 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/codec/binary/Base64.java 
b/java/org/apache/tomcat/util/codec/binary/Base64.java
index e38bf3df17..5f6fdbd7a5 100644
--- a/java/org/apache/tomcat/util/codec/binary/Base64.java
+++ b/java/org/apache/tomcat/util/codec/binary/Base64.java
@@ -46,7 +46,10 @@ package org.apache.tomcat.util.codec.binary;
  *
  * @see http://www.ietf.org/rfc/rfc2045.txt;>RFC 2045
  * @since 1.0
+ *
+ * @deprecated Unused. This class will be removed in Tomcat 11 onwards.
  */
+@Deprecated
 public class Base64 extends BaseNCodec {
 
 /**
diff --git a/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java 
b/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
index 7492773fe0..2eaa78e940 100644
--- a/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
+++ b/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
@@ -27,7 +27,10 @@ import org.apache.tomcat.util.res.StringManager;
  * 
  * This class is thread-safe.
  * 
+ *
+ * @deprecated Unused. This class will be removed in Tomcat 11 onwards.
  */
+@Deprecated
 public abstract class BaseNCodec {
 
 protected static final StringManager sm = 
StringManager.getManager(BaseNCodec.class);
diff --git a/java/org/apache/tomcat/util/codec/binary/StringUtils.java 
b/java/org/apache/tomcat/util/codec/binary/StringUtils.java
index ab050f3509..619964105b 100644
--- a/java/org/apache/tomcat/util/codec/binary/StringUtils.java
+++ b/java/org/apache/tomcat/util/codec/binary/StringUtils.java
@@ -29,7 +29,10 @@ import java.nio.charset.StandardCharsets;
  * @see Charset
  * @see StandardCharsets
  * @since 1.4
+ *
+ * @deprecated Unused. This class will be removed in Tomcat 11 onwards.
  */
+@Deprecated
 public class StringUtils {
 
 /**
diff --git a/java/org/apache/tomcat/util/codec/binary/package-info.java 
b/java/org/apache/tomcat/util/codec/binary/package-info.java
index 605aeded44..c41bd15a4e 100644
--- a/java/org/apache/tomcat/util/codec/binary/package-info.java
+++ b/java/org/apache/tomcat/util/codec/binary/package-info.java
@@ -17,5 +17,7 @@
 
 /**
  * Base64 String encoding and decoding.
+ *
+ * Unused. This package will be removed in Tomcat 11 onwards.
  */
 package org.apache.tomcat.util.codec.binary;
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index f946c6f347..423e024c74 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -141,7 +141,9 @@
 
   
 Switch to using the Base64 encoder and decoder provided by the JRE
-rather than the version provided by Commons Codec. (markt)
+rather than the version provided by Commons Codec. The internal fork of
+Commons Codec has been deprecated and will be removed in Tomcat 11.
+    (markt)
   
 
   


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 10.1.x updated (ea37a83dd4 -> 972f2913c4)

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from ea37a83dd4 Fix Gump issue - Gump tests with OpenSSL master which is 
now 3.4.x
 new 2c470e1bb0 Switch to the Base64 encoder and decoder provided by the 
JRE.
 new 972f2913c4 Deprecate the internal fork of Commons Codec

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../authenticator/SpnegoAuthenticator.java |  9 +++
 .../realm/MessageDigestCredentialHandler.java  |  6 ++---
 .../apache/coyote/http2/Http2UpgradeHandler.java   |  4 ++--
 .../apache/tomcat/util/codec/binary/Base64.java|  3 +++
 .../tomcat/util/codec/binary/BaseNCodec.java   |  3 +++
 .../tomcat/util/codec/binary/StringUtils.java  |  3 +++
 .../tomcat/util/codec/binary/package-info.java |  2 ++
 .../http/fileupload/util/mime/MimeUtility.java |  5 ++--
 .../tomcat/util/http/parser/StructuredField.java   |  4 ++--
 java/org/apache/tomcat/util/net/jsse/PEMFile.java  |  7 +++---
 .../tomcat/websocket/WsWebSocketContainer.java |  4 ++--
 .../tomcat/websocket/server/UpgradeUtil.java   | 28 +++---
 .../authenticator/TestAuthInfoResponseHeaders.java |  4 ++--
 .../TestNonLoginAndBasicAuthenticator.java |  4 ++--
 .../TestSSOnonLoginAndBasicAuthenticator.java  |  4 ++--
 .../core/TestPropertiesRoleMappingListener.java|  4 ++--
 .../filters/TestRestCsrfPreventionFilter2.java |  4 ++--
 test/org/apache/coyote/http2/Http2TestBase.java|  4 ++--
 webapps/docs/changelog.xml | 10 
 19 files changed, 60 insertions(+), 52 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch main updated (973881f808 -> 0e55afa1fc)

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from 973881f808 Fix Gump issue - Gump tests with OpenSSL master which is 
now 3.4.x
 new bd23ba3b79 Switch to the Base64 encoder and decoder provided by the 
JRE.
 new 0e55afa1fc Remove the internal fork of Commons Codec.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 MERGE.txt  |   9 -
 .../authenticator/SpnegoAuthenticator.java |   9 +-
 .../realm/MessageDigestCredentialHandler.java  |   6 +-
 .../apache/coyote/http2/Http2UpgradeHandler.java   |   4 +-
 .../apache/tomcat/util/codec/binary/Base64.java| 661 -
 .../tomcat/util/codec/binary/BaseNCodec.java   | 478 ---
 .../util/codec/binary/LocalStrings.properties  |  21 -
 .../util/codec/binary/LocalStrings_fr.properties   |  20 -
 .../util/codec/binary/LocalStrings_ja.properties   |  20 -
 .../util/codec/binary/LocalStrings_ko.properties   |  19 -
 .../codec/binary/LocalStrings_zh_CN.properties |  19 -
 .../tomcat/util/codec/binary/StringUtils.java  | 116 
 .../tomcat/util/codec/binary/package-info.java |  21 -
 .../http/fileupload/util/mime/MimeUtility.java |   5 +-
 .../tomcat/util/http/parser/StructuredField.java   |   4 +-
 java/org/apache/tomcat/util/net/jsse/PEMFile.java  |   7 +-
 .../tomcat/websocket/WsWebSocketContainer.java |   4 +-
 .../tomcat/websocket/server/UpgradeUtil.java   |  28 +-
 .../authenticator/TestAuthInfoResponseHeaders.java |   4 +-
 .../TestNonLoginAndBasicAuthenticator.java |   4 +-
 .../TestSSOnonLoginAndBasicAuthenticator.java  |   4 +-
 .../core/TestPropertiesRoleMappingListener.java|   4 +-
 .../filters/TestRestCsrfPreventionFilter2.java |   4 +-
 test/org/apache/coyote/http2/Http2TestBase.java|   4 +-
 webapps/docs/changelog.xml |   9 +
 25 files changed, 48 insertions(+), 1436 deletions(-)
 delete mode 100644 java/org/apache/tomcat/util/codec/binary/Base64.java
 delete mode 100644 java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
 delete mode 100644 
java/org/apache/tomcat/util/codec/binary/LocalStrings.properties
 delete mode 100644 
java/org/apache/tomcat/util/codec/binary/LocalStrings_fr.properties
 delete mode 100644 
java/org/apache/tomcat/util/codec/binary/LocalStrings_ja.properties
 delete mode 100644 
java/org/apache/tomcat/util/codec/binary/LocalStrings_ko.properties
 delete mode 100644 
java/org/apache/tomcat/util/codec/binary/LocalStrings_zh_CN.properties
 delete mode 100644 java/org/apache/tomcat/util/codec/binary/StringUtils.java
 delete mode 100644 java/org/apache/tomcat/util/codec/binary/package-info.java


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 02/02: Remove the internal fork of Commons Codec.

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 0e55afa1fc821f70d6e81fe20c096cfba1d2d932
Author: Mark Thomas 
AuthorDate: Tue Apr 16 15:33:41 2024 +0100

Remove the internal fork of Commons Codec.
---
 MERGE.txt  |   9 -
 .../apache/tomcat/util/codec/binary/Base64.java| 661 -
 .../tomcat/util/codec/binary/BaseNCodec.java   | 478 ---
 .../util/codec/binary/LocalStrings.properties  |  21 -
 .../util/codec/binary/LocalStrings_fr.properties   |  20 -
 .../util/codec/binary/LocalStrings_ja.properties   |  20 -
 .../util/codec/binary/LocalStrings_ko.properties   |  19 -
 .../codec/binary/LocalStrings_zh_CN.properties |  19 -
 .../tomcat/util/codec/binary/StringUtils.java  | 116 
 .../tomcat/util/codec/binary/package-info.java |  21 -
 webapps/docs/changelog.xml |   3 +-
 11 files changed, 2 insertions(+), 1385 deletions(-)

diff --git a/MERGE.txt b/MERGE.txt
index c3e81ab842..a4c15506df 100644
--- a/MERGE.txt
+++ b/MERGE.txt
@@ -39,15 +39,6 @@ src/main/java/org/apache/bcel
 The SHA1 ID / tag for the most recent commit to be merged to Tomcat is:
 rel/commons-bcel-6.8.2 (2024-02-25)
 
-Codec
--
-Unused code is removed
-Sub-tree:
-src/main/java/org/apache/commons/codec
-The SHA1 ID / tag for the most recent commit to be merged to Tomcat is:
-rel/commons-codec-1.16.1 (2024-02-09)
-Note: Only classes required for Base64 encoding/decoding. The rest are removed.
-
 FileUpload
 --
 Unused code is removed
diff --git a/java/org/apache/tomcat/util/codec/binary/Base64.java 
b/java/org/apache/tomcat/util/codec/binary/Base64.java
deleted file mode 100644
index e38bf3df17..00
--- a/java/org/apache/tomcat/util/codec/binary/Base64.java
+++ /dev/null
@@ -1,661 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.util.codec.binary;
-
-/**
- * Provides Base64 encoding and decoding as defined by http://www.ietf.org/rfc/rfc2045.txt;>RFC 2045.
- *
- * 
- * This class implements section 6.8. Base64 
Content-Transfer-Encoding from RFC 2045 Multipurpose
- * Internet Mail Extensions (MIME) Part One: Format of Internet Message 
Bodies by Freed and Borenstein.
- * 
- * 
- * The class can be parameterized in the following manner with various 
constructors:
- * 
- * 
- * URL-safe mode: Default off.
- * Line length: Default 76. Line length that aren't multiples of 4 will 
still essentially end up being multiples of
- * 4 in the encoded data.
- * Line separator: Default is CRLF ("\r\n")
- * 
- * 
- * The URL-safe parameter is only applied to encode operations. Decoding 
seamlessly handles both modes.
- * 
- * 
- * Since this class operates directly on byte streams, and not character 
streams, it is hard-coded to only
- * encode/decode character encodings which are compatible with the lower 127 
ASCII chart (ISO-8859-1, Windows-1252,
- * UTF-8, etc).
- * 
- * 
- * This class is thread-safe.
- * 
- *
- * @see http://www.ietf.org/rfc/rfc2045.txt;>RFC 2045
- * @since 1.0
- */
-public class Base64 extends BaseNCodec {
-
-/**
- * BASE64 characters are 6 bits in length.
- * They are formed by taking a block of 3 octets to form a 24-bit string,
- * which is converted into 4 BASE64 characters.
- */
-private static final int BITS_PER_ENCODED_BYTE = 6;
-private static final int BYTES_PER_UNENCODED_BLOCK = 3;
-private static final int BYTES_PER_ENCODED_BLOCK = 4;
-
-/**
- * This array is a lookup table that translates 6-bit positive integer 
index values into their "Base64 Alphabet"
- * equivalents as specified in Table 1 of RFC 2045.
- * 
- * Thanks to "commons" project in ws.apache.org for this code.
- * https://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/
- * 
- */
-private static final byte[] STANDARD_ENCODE_TABLE = {
-'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
-'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',

(tomcat) 01/02: Switch to the Base64 encoder and decoder provided by the JRE.

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit bd23ba3b79f21210891f036e54c3b80886401ef0
Author: Mark Thomas 
AuthorDate: Tue Apr 16 15:31:37 2024 +0100

Switch to the Base64 encoder and decoder provided by the JRE.

This removes the dependency on the internal fork of Commons Codec.
---
 .../authenticator/SpnegoAuthenticator.java |  9 +++
 .../realm/MessageDigestCredentialHandler.java  |  6 ++---
 .../apache/coyote/http2/Http2UpgradeHandler.java   |  4 ++--
 .../http/fileupload/util/mime/MimeUtility.java |  5 ++--
 .../tomcat/util/http/parser/StructuredField.java   |  4 ++--
 java/org/apache/tomcat/util/net/jsse/PEMFile.java  |  7 +++---
 .../tomcat/websocket/WsWebSocketContainer.java |  4 ++--
 .../tomcat/websocket/server/UpgradeUtil.java   | 28 +++---
 .../authenticator/TestAuthInfoResponseHeaders.java |  4 ++--
 .../TestNonLoginAndBasicAuthenticator.java |  4 ++--
 .../TestSSOnonLoginAndBasicAuthenticator.java  |  4 ++--
 .../core/TestPropertiesRoleMappingListener.java|  4 ++--
 .../filters/TestRestCsrfPreventionFilter2.java |  4 ++--
 test/org/apache/coyote/http2/Http2TestBase.java|  4 ++--
 webapps/docs/changelog.xml |  8 +++
 15 files changed, 47 insertions(+), 52 deletions(-)

diff --git a/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java 
b/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java
index 6377416ea4..ab4a8c3287 100644
--- a/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java
+++ b/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java
@@ -22,6 +22,7 @@ import java.security.Principal;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
+import java.util.Base64;
 import java.util.LinkedHashMap;
 import java.util.regex.Pattern;
 
@@ -38,7 +39,6 @@ import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.buf.ByteChunk;
 import org.apache.tomcat.util.buf.MessageBytes;
-import org.apache.tomcat.util.codec.binary.Base64;
 import org.apache.tomcat.util.compat.JreVendor;
 import org.ietf.jgss.GSSContext;
 import org.ietf.jgss.GSSCredential;
@@ -166,8 +166,9 @@ public class SpnegoAuthenticator extends AuthenticatorBase {
 
 authorizationBC.setOffset(authorizationBC.getOffset() + 10);
 
-byte[] decoded = Base64.decodeBase64(authorizationBC.getBuffer(), 
authorizationBC.getOffset(),
-authorizationBC.getLength());
+byte[] encoded = new byte[authorizationBC.getLength()];
+System.arraycopy(authorizationBC.getBuffer(), 0, encoded, 0, 
authorizationBC.getLength());
+byte[] decoded = Base64.getDecoder().decode(encoded);
 
 if (getApplyJava8u40Fix()) {
 SpnegoTokenFixer.fix(decoded);
@@ -264,7 +265,7 @@ public class SpnegoAuthenticator extends AuthenticatorBase {
 }
 
 // Send response token on success and failure
-response.setHeader(AUTH_HEADER_NAME, AUTH_HEADER_VALUE_NEGOTIATE + " " 
+ Base64.encodeBase64String(outToken));
+response.setHeader(AUTH_HEADER_NAME, AUTH_HEADER_VALUE_NEGOTIATE + " " 
+ Base64.getEncoder().encodeToString(outToken));
 
 if (principal != null) {
 register(request, response, principal, Constants.SPNEGO_METHOD, 
principal.getName(), null);
diff --git a/java/org/apache/catalina/realm/MessageDigestCredentialHandler.java 
b/java/org/apache/catalina/realm/MessageDigestCredentialHandler.java
index 7945af8490..e3aa771d60 100644
--- a/java/org/apache/catalina/realm/MessageDigestCredentialHandler.java
+++ b/java/org/apache/catalina/realm/MessageDigestCredentialHandler.java
@@ -21,12 +21,12 @@ import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.security.NoSuchAlgorithmException;
 import java.util.Arrays;
+import java.util.Base64;
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.buf.B2CConverter;
 import org.apache.tomcat.util.buf.HexUtils;
-import org.apache.tomcat.util.codec.binary.Base64;
 import org.apache.tomcat.util.security.ConcurrentMessageDigest;
 
 /**
@@ -110,7 +110,7 @@ public class MessageDigestCredentialHandler extends 
DigestCredentialHandlerBase
 String base64ServerDigest = storedCredentials.substring(5);
 byte[] userDigest = 
ConcurrentMessageDigest.digest(getAlgorithm(),
 
inputCredentials.getBytes(StandardCharsets.ISO_8859_1));
-String base64UserDigest = 
Base64.encodeBase64String(userDigest);
+String base64UserDigest = 
Base64.getEncoder().encodeToString(userDigest);
 
 return DigestCredentialHandlerBase.equ

(tomcat) branch 9.0.x updated: Fix Gump issue - Gump tests with OpenSSL master which is now 3.4.x

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt 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 d7ae6515dc Fix Gump issue - Gump tests with OpenSSL master which is 
now 3.4.x
d7ae6515dc is described below

commit d7ae6515dcd82aa72f3bd05200dd32717454a286
Author: Mark Thomas 
AuthorDate: Tue Apr 16 14:46:41 2024 +0100

Fix Gump issue - Gump tests with OpenSSL master which is now 3.4.x
---
 test/org/apache/tomcat/util/net/openssl/ciphers/TesterOpenSSL.java | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/test/org/apache/tomcat/util/net/openssl/ciphers/TesterOpenSSL.java 
b/test/org/apache/tomcat/util/net/openssl/ciphers/TesterOpenSSL.java
index 6f51c27f8a..28a2582d70 100644
--- a/test/org/apache/tomcat/util/net/openssl/ciphers/TesterOpenSSL.java
+++ b/test/org/apache/tomcat/util/net/openssl/ciphers/TesterOpenSSL.java
@@ -49,8 +49,10 @@ public class TesterOpenSSL {
 } catch (IOException e) {
 versionString = "";
 }
-if (versionString.startsWith("OpenSSL 3.3.")) {
-// Note: Gump currently tests 11.x with OpenSSL 3.3.x
+if (versionString.startsWith("OpenSSL 3.4.")) {
+// Note: Gump currently tests 11.x with OpenSSL HEAD which is 
current 3.4.x
+VERSION = 30400;
+} else if (versionString.startsWith("OpenSSL 3.3.")) {
 VERSION = 30300;
 } else if (versionString.startsWith("OpenSSL 3.2.")) {
 VERSION = 30200;


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 10.1.x updated: Fix Gump issue - Gump tests with OpenSSL master which is now 3.4.x

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
 new ea37a83dd4 Fix Gump issue - Gump tests with OpenSSL master which is 
now 3.4.x
ea37a83dd4 is described below

commit ea37a83dd41e6e4b136e9314ff2bef455c829c93
Author: Mark Thomas 
AuthorDate: Tue Apr 16 14:46:41 2024 +0100

Fix Gump issue - Gump tests with OpenSSL master which is now 3.4.x
---
 test/org/apache/tomcat/util/net/openssl/ciphers/TesterOpenSSL.java | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/test/org/apache/tomcat/util/net/openssl/ciphers/TesterOpenSSL.java 
b/test/org/apache/tomcat/util/net/openssl/ciphers/TesterOpenSSL.java
index 6f51c27f8a..28a2582d70 100644
--- a/test/org/apache/tomcat/util/net/openssl/ciphers/TesterOpenSSL.java
+++ b/test/org/apache/tomcat/util/net/openssl/ciphers/TesterOpenSSL.java
@@ -49,8 +49,10 @@ public class TesterOpenSSL {
 } catch (IOException e) {
 versionString = "";
 }
-if (versionString.startsWith("OpenSSL 3.3.")) {
-// Note: Gump currently tests 11.x with OpenSSL 3.3.x
+if (versionString.startsWith("OpenSSL 3.4.")) {
+// Note: Gump currently tests 11.x with OpenSSL HEAD which is 
current 3.4.x
+VERSION = 30400;
+} else if (versionString.startsWith("OpenSSL 3.3.")) {
 VERSION = 30300;
 } else if (versionString.startsWith("OpenSSL 3.2.")) {
 VERSION = 30200;


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch main updated: Fix Gump issue - Gump tests with OpenSSL master which is now 3.4.x

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
 new 973881f808 Fix Gump issue - Gump tests with OpenSSL master which is 
now 3.4.x
973881f808 is described below

commit 973881f8083c5f7064ce61441640bd2069de65c5
Author: Mark Thomas 
AuthorDate: Tue Apr 16 14:46:41 2024 +0100

Fix Gump issue - Gump tests with OpenSSL master which is now 3.4.x
---
 test/org/apache/tomcat/util/net/openssl/ciphers/TesterOpenSSL.java | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/test/org/apache/tomcat/util/net/openssl/ciphers/TesterOpenSSL.java 
b/test/org/apache/tomcat/util/net/openssl/ciphers/TesterOpenSSL.java
index 6f51c27f8a..28a2582d70 100644
--- a/test/org/apache/tomcat/util/net/openssl/ciphers/TesterOpenSSL.java
+++ b/test/org/apache/tomcat/util/net/openssl/ciphers/TesterOpenSSL.java
@@ -49,8 +49,10 @@ public class TesterOpenSSL {
 } catch (IOException e) {
 versionString = "";
 }
-if (versionString.startsWith("OpenSSL 3.3.")) {
-// Note: Gump currently tests 11.x with OpenSSL 3.3.x
+if (versionString.startsWith("OpenSSL 3.4.")) {
+// Note: Gump currently tests 11.x with OpenSSL HEAD which is 
current 3.4.x
+VERSION = 30400;
+} else if (versionString.startsWith("OpenSSL 3.3.")) {
 VERSION = 30300;
 } else if (versionString.startsWith("OpenSSL 3.2.")) {
 VERSION = 30200;


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 9.0.x updated: Fix comment (thanks to Chuck)

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt 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 22190db22c Fix comment (thanks to Chuck)
22190db22c is described below

commit 22190db22c67fd4bfb5537c4bc7f4a1f4091aa01
Author: Mark Thomas 
AuthorDate: Tue Apr 16 14:20:04 2024 +0100

Fix comment (thanks to Chuck)
---
 java/org/apache/catalina/authenticator/BasicAuthenticator.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/authenticator/BasicAuthenticator.java 
b/java/org/apache/catalina/authenticator/BasicAuthenticator.java
index 63ac050f69..c293af288c 100644
--- a/java/org/apache/catalina/authenticator/BasicAuthenticator.java
+++ b/java/org/apache/catalina/authenticator/BasicAuthenticator.java
@@ -226,8 +226,7 @@ public class BasicAuthenticator extends AuthenticatorBase {
 }
 
 /*
- * The authorization method string is case-insensitive and must have 
at exactly one space character as a
- * delimiter.
+ * The authorization method string is case-insensitive and must have 
exactly one space character as a delimiter.
  */
 private void parseMethod() throws IllegalArgumentException {
 if (authorization.startsWithIgnoreCase(METHOD, 0)) {


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 10.1.x updated: Fix comment (thanks to Chuck)

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 63f72b89ff Fix comment (thanks to Chuck)
63f72b89ff is described below

commit 63f72b89fffe8ad60b1d3c8edf6221f78a11c539
Author: Mark Thomas 
AuthorDate: Tue Apr 16 14:20:04 2024 +0100

Fix comment (thanks to Chuck)
---
 java/org/apache/catalina/authenticator/BasicAuthenticator.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/authenticator/BasicAuthenticator.java 
b/java/org/apache/catalina/authenticator/BasicAuthenticator.java
index 7060cca97c..1bfd552cf1 100644
--- a/java/org/apache/catalina/authenticator/BasicAuthenticator.java
+++ b/java/org/apache/catalina/authenticator/BasicAuthenticator.java
@@ -226,8 +226,7 @@ public class BasicAuthenticator extends AuthenticatorBase {
 }
 
 /*
- * The authorization method string is case-insensitive and must have 
at exactly one space character as a
- * delimiter.
+ * The authorization method string is case-insensitive and must have 
exactly one space character as a delimiter.
  */
 private void parseMethod() throws IllegalArgumentException {
 if (authorization.startsWithIgnoreCase(METHOD, 0)) {


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch main updated: Fix comment (thanks to Chuck)

2024-04-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
 new b0d06dc8ca Fix comment (thanks to Chuck)
b0d06dc8ca is described below

commit b0d06dc8cae59b624adc91777f3e42552a3b141b
Author: Mark Thomas 
AuthorDate: Tue Apr 16 14:20:04 2024 +0100

Fix comment (thanks to Chuck)
---
 java/org/apache/catalina/authenticator/BasicAuthenticator.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/authenticator/BasicAuthenticator.java 
b/java/org/apache/catalina/authenticator/BasicAuthenticator.java
index 28114ec24a..8421dc54b1 100644
--- a/java/org/apache/catalina/authenticator/BasicAuthenticator.java
+++ b/java/org/apache/catalina/authenticator/BasicAuthenticator.java
@@ -180,8 +180,7 @@ public class BasicAuthenticator extends AuthenticatorBase {
 }
 
 /*
- * The authorization method string is case-insensitive and must have 
at exactly one space character as a
- * delimiter.
+ * The authorization method string is case-insensitive and must have 
exactly one space character as a delimiter.
  */
 private void parseMethod() throws IllegalArgumentException {
 if (authorization.startsWithIgnoreCase(METHOD, 0)) {


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



<    1   2   3   4   5   6   7   8   9   10   >