Re: Refactoring heads up

2024-04-26 Thread Rémy Maucherat
On Fri, Apr 26, 2024 at 7:20 PM Mark Thomas  wrote:
>
> On 24/04/2024 17:52, Mark Thomas wrote:
>
> 
>
> > My plan is to commit these changes to 11.0.x with the low risk parts
> > (e.g. new methods) back-ported. Then, once we can see what is left, we
> > can decide how quickly/slowly we want to back-port the complete fix to
> > 10.1.x and 9.0.x (the issue was reported against 10.1.x).
>
> All is looking good so far.
>
> The complete refactoring has been applied to 11.0.x
>
> 10.1.x and 9.0.x have the new header parser and are using it for the
> ChunkedInputFilter.
>
> The question is how long do we want to wait before back-porting the
> standard HTTP header parsing? Essentially this means back-porting this
> commit:
>
> https://github.com/apache/tomcat/commit/e5acf2cf0f745350c85d81532826d92b1882469a
>
> Thoughts?

Nice overall. You can wait a bit just in case ...
I was not aware that non blocking was not working there.

Rémy

> I'm thinking wait at least one release cycle before back-porting just in
> case of regressions given that this affects every request.
>
> Mark
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>

-
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 support for timescales with time-taken access log token. (#721)

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

schultz 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 a7e9d7da69 Add support for timescales with time-taken access log 
token. (#721)
a7e9d7da69 is described below

commit a7e9d7da695f0f0de8d4a5494e1dc655f20cf62f
Author: Christopher Schultz 
AuthorDate: Fri Apr 26 13:17:57 2024 -0400

Add support for timescales with time-taken access log token. (#721)

Add support for timescales with time-taken access log token.

Add support for nanosecond and fractional-second timescales.
---
 .../catalina/valves/AbstractAccessLogValve.java| 32 +++---
 .../catalina/valves/ExtendedAccessLogValve.java| 14 +-
 webapps/docs/changelog.xml |  5 
 webapps/docs/config/valve.xml  |  9 --
 4 files changed, 52 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/catalina/valves/AbstractAccessLogValve.java 
b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
index 5c4e67dde6..286647cfed 100644
--- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
+++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
@@ -1316,6 +1316,19 @@ public abstract class AbstractAccessLogValve extends 
ValveBase implements Access
 
buf.append(Long.toString(TimeUnit.NANOSECONDS.toSeconds(time)));
 }
 },
+SECONDS_FRACTIONAL {
+@Override
+public void append(CharArrayWriter buf, long time) {
+time = time / 100; // Convert to millis
+buf.append(Long.toString(time / 1000));
+buf.append('.');
+int remains = (int) (time % 1000);
+buf.append(Long.toString(remains / 100));
+remains = remains % 100;
+buf.append(Long.toString(remains / 10));
+buf.append(Long.toString(remains % 10));
+}
+},
 MILLISECONDS {
 @Override
 public void append(CharArrayWriter buf, long time) {
@@ -1327,6 +1340,12 @@ public abstract class AbstractAccessLogValve extends 
ValveBase implements Access
 public void append(CharArrayWriter buf, long time) {
 
buf.append(Long.toString(TimeUnit.NANOSECONDS.toMicros(time)));
 }
+},
+NANOSECONDS {
+@Override
+public void append(CharArrayWriter buf, long time) {
+buf.append(Long.toString(time));
+}
 };
 
 /**
@@ -1337,10 +1356,11 @@ public abstract class AbstractAccessLogValve extends 
ValveBase implements Access
  */
 public abstract void append(CharArrayWriter buf, long time);
 }
+
 private final Style style;
 
 /**
- * Create a new ElapsedTimeElement that will log the time in the 
specified style.
+ * Creates a new ElapsedTimeElement that will log the time in the 
specified style.
  *
  * @param style The elapsed-time style to use.
  */
@@ -1760,10 +1780,14 @@ public abstract class AbstractAccessLogValve extends 
ValveBase implements Access
 return new DateAndTimeElement(name);
 case 'T':
 // ms for milliseconds, us for microseconds, and s for seconds
-if ("ms".equals(name)) {
-return new ElapsedTimeElement(false, true);
+if ("ns".equals(name)) {
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.NANOSECONDS);
 } else if ("us".equals(name)) {
-return new ElapsedTimeElement(true, false);
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.MICROSECONDS);
+} else if ("ms".equals(name)) {
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.MILLISECONDS);
+} else if ("fracsec".equals(name)) {
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.SECONDS_FRACTIONAL);
 } else {
 return new ElapsedTimeElement(false, false);
 }
diff --git a/java/org/apache/catalina/valves/ExtendedAccessLogValve.java 
b/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
index c75e41dc01..8b9c9f090c 100644
--- a/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
+++ b/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
@@ -535,7 +535,19 @@ public class ExtendedAccessLogValve extends AccessLogValve 
{
 if (tokenizer.hasSubToken()) {
 String nextToken = tokenizer.getToken();
 if 

Re: Refactoring heads up

2024-04-26 Thread Christopher Schultz

Mark,

On 4/26/24 13:17, Mark Thomas wrote:

On 24/04/2024 17:52, Mark Thomas wrote:



My plan is to commit these changes to 11.0.x with the low risk parts 
(e.g. new methods) back-ported. Then, once we can see what is left, we 
can decide how quickly/slowly we want to back-port the complete fix to 
10.1.x and 9.0.x (the issue was reported against 10.1.x).


All is looking good so far.

The complete refactoring has been applied to 11.0.x

10.1.x and 9.0.x have the new header parser and are using it for the 
ChunkedInputFilter.


The question is how long do we want to wait before back-porting the 
standard HTTP header parsing? Essentially this means back-porting this 
commit:


https://github.com/apache/tomcat/commit/e5acf2cf0f745350c85d81532826d92b1882469a

Thoughts?

I'm thinking wait at least one release cycle before back-porting just in 
case of regressions given that this affects every request.


+1 for waiting until next cycle to back-port.

I don't think we have to wait any longer than that.

-chris

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



Re: Unit tests using tcnative/panama [Was: [Bug 68910] Improve LibreSSL version check in tcnative.m4]

2024-04-26 Thread Christopher Schultz




On 4/18/24 06:05, Rainer Jung wrote:

Am 18.04.24 um 09:08 schrieb bugzi...@apache.org:

https://bz.apache.org/bugzilla/show_bug.cgi?id=68910

--- Comment #3 from Michael Osipov  ---
(In reply to Christopher Schultz from comment #1)

(In reply to Michael Osipov from comment #0)

since we also do support LibreSSL [...]


Note: Support for LibreSSL is more of an aspiration and less of a
requirement. We don't technically advertise support for LibreSSL, but I
would like to be able to support it.


FYI. Just ran 10.1.x with LibreSSL 3.5.2:
    [concat] 
TEST-org.apache.catalina.valves.rewrite.TestResolverSSL.NIO.txt
    [concat] 
TEST-org.apache.catalina.valves.rewrite.TestResolverSSL.NIO2.txt

    [concat] TEST-org.apache.tomcat.util.net.TestClientCert.NIO.txt
    [concat] TEST-org.apache.tomcat.util.net.TestClientCert.NIO2.txt
    [concat] 
TEST-org.apache.tomcat.util.net.TestCustomSslTrustManager.NIO.txt
    [concat] 
TEST-org.apache.tomcat.util.net.TestCustomSslTrustManager.NIO2.txt
    [concat] 
TEST-org.apache.tomcat.util.net.openssl.TestOpenSSLConf.NIO.txt
    [concat] 
TEST-org.apache.tomcat.util.net.openssl.TestOpenSSLConf.NIO2.txt


The rest is passing. These are failing for renegotiation or protocol 
mismatch.

That looks very promising.


Probably not relevant for this specific topic but maybe of general 
interest:


For other reasons I tried to identify, which unit tests actually load 
and execute with tcnative and/or panama, and those are very few. Most 
tests do not use these. Apart from the ones you mentioned as failing:


org.apache.catalina.valves.rewrite.TestResolverSSL
org.apache.tomcat.util.net.TestClientCert
org.apache.tomcat.util.net.TestCustomSslTrustManager
org.apache.tomcat.util.net.openssl.TestOpenSSLConf

the only other tests I found using tcnative and/or openssl connectors are:

org.apache.coyote.http2.TestLargeUpload
org.apache.tomcat.util.net.TestClientCertTls13
org.apache.tomcat.util.net.TestSSLHostConfigCompat
org.apache.tomcat.util.net.TestSSLHostConfigIntegration
org.apache.tomcat.util.net.TestSsl
org.apache.tomcat.websocket.TestWebSocketFrameClientSSL
org.apache.tomcat.websocket.TestWsWebSocketContainerSSL

So almost all of the tests actually using a connector to run servlets 
etc. only use plain http connectors (or fixed JSSE, but I think such do 
not exist).


A few more might only use the commandline openssl binary. Those are not 
included in the above lists.


I was thinking about this the other day as well, since there are 
tcnative+APR-based tests in Tomcat 9 which are executed separately from 
NIO and NIO2. I wasn't ever sure if/how the native library was being 
loaded. I wonder if on test-start (for those tests which actually use 
the connector), we could advertise which strategy is actually being used 
at runtime? I'm aware that FFM isn't supported pre-10.1.23 and that the 
APR connector has been removed in 10.1 but when running 10.1/11 tests it 
would be nice to know that the tests are failing because some specific 
test isn't working via e.g. FFM rather than the native library just 
didn't load properly and therefore ALL tests are failing.


-chris

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



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

2024-04-26 Thread Christopher Schultz

Mark,

Thanks for back-porting this. I thought I had already done so.

-chris

On 4/26/24 12:58, ma...@apache.org wrote:

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



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



Re: (tomcat) branch main updated: Fix disastrous cookie-logging patch.

2024-04-26 Thread Christopher Schultz

Chuck,

On 4/19/24 10:48, Chuck Caldarale wrote:

On Apr 19, 2024, at 09:18, Christopher Schultz  
wrote:

Hopefully this patch has the intended effect. ;)



I’m not convinced this change will have any measurable performance
improvement. The JVM C2 compiler is pretty good with escape analysis,
so an unused StringBuilder object may not even get allocated.
It should get allocated, since the constructor needs to be called. But 
it may be allocated in a cheap memory region and immediately become 
speedily-collected garbage.



Also, there’s now an added comparison for each iteration of the
cookies loop, plus the additional code for an object allocation. This
enlarges the body of the loop, putting more pressure on the microcode
cache in the CPU, possibly making each iteration take longer.

That's a fair criticism.


Are there any practical examples that show a performance benefit or GC 
reduction?


None.

I made this change merely based upon code inspection. Since this code 
executes for every single request, I guessed without evidence that 
reduction of memory-churn would be beneficial.


-chris


On 4/19/24 10:17, schu...@apache.org wrote:

This is an automated email from the ASF dual-hosted git repository.
schultz 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 cbefe8624e Fix disastrous cookie-logging patch.
cbefe8624e is described below
commit cbefe8624ee5d6255955134d08498f9926295126
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 0576b83442..dd29a5ec37 100644
--- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
+++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
@@ -1513,17 +1513,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


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




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



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



[Bug 68947] `tomcat-embed-core` `10.1.23` requires Java 11 but includes Java 22 sources

2024-04-26 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=68947

--- Comment #3 from Michael Osipov  ---
Though, I didn't take a look isn't that why we MRJARs have been invented and we
didn't use that feature so far?

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch main updated: Add support for timescales with time-taken access log token. (#721)

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

schultz 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 e9046d96a6 Add support for timescales with time-taken access log 
token. (#721)
e9046d96a6 is described below

commit e9046d96a6fd3b23b9b3288154f4bb7ea2f7f2cd
Author: Christopher Schultz 
AuthorDate: Fri Apr 26 13:17:57 2024 -0400

Add support for timescales with time-taken access log token. (#721)

Add support for timescales with time-taken access log token.

Add support for nanosecond and fractional-second timescales.
---
 .../catalina/valves/AbstractAccessLogValve.java| 32 +++---
 .../catalina/valves/ExtendedAccessLogValve.java| 14 +-
 webapps/docs/changelog.xml |  5 
 webapps/docs/config/valve.xml  |  9 --
 4 files changed, 52 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/catalina/valves/AbstractAccessLogValve.java 
b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
index dd29a5ec37..2628c654e2 100644
--- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
+++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
@@ -1314,6 +1314,19 @@ public abstract class AbstractAccessLogValve extends 
ValveBase implements Access
 
buf.append(Long.toString(TimeUnit.NANOSECONDS.toSeconds(time)));
 }
 },
+SECONDS_FRACTIONAL {
+@Override
+public void append(CharArrayWriter buf, long time) {
+time = time / 100; // Convert to millis
+buf.append(Long.toString(time / 1000));
+buf.append('.');
+int remains = (int) (time % 1000);
+buf.append(Long.toString(remains / 100));
+remains = remains % 100;
+buf.append(Long.toString(remains / 10));
+buf.append(Long.toString(remains % 10));
+}
+},
 MILLISECONDS {
 @Override
 public void append(CharArrayWriter buf, long time) {
@@ -1325,6 +1338,12 @@ public abstract class AbstractAccessLogValve extends 
ValveBase implements Access
 public void append(CharArrayWriter buf, long time) {
 
buf.append(Long.toString(TimeUnit.NANOSECONDS.toMicros(time)));
 }
+},
+NANOSECONDS {
+@Override
+public void append(CharArrayWriter buf, long time) {
+buf.append(Long.toString(time));
+}
 };
 
 /**
@@ -1335,10 +1354,11 @@ public abstract class AbstractAccessLogValve extends 
ValveBase implements Access
  */
 public abstract void append(CharArrayWriter buf, long time);
 }
+
 private final Style style;
 
 /**
- * Create a new ElapsedTimeElement that will log the time in the 
specified style.
+ * Creates a new ElapsedTimeElement that will log the time in the 
specified style.
  *
  * @param style The elapsed-time style to use.
  */
@@ -1758,10 +1778,14 @@ public abstract class AbstractAccessLogValve extends 
ValveBase implements Access
 return new DateAndTimeElement(name);
 case 'T':
 // ms for milliseconds, us for microseconds, and s for seconds
-if ("ms".equals(name)) {
-return new ElapsedTimeElement(false, true);
+if ("ns".equals(name)) {
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.NANOSECONDS);
 } else if ("us".equals(name)) {
-return new ElapsedTimeElement(true, false);
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.MICROSECONDS);
+} else if ("ms".equals(name)) {
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.MILLISECONDS);
+} else if ("fracsec".equals(name)) {
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.SECONDS_FRACTIONAL);
 } else {
 return new ElapsedTimeElement(false, false);
 }
diff --git a/java/org/apache/catalina/valves/ExtendedAccessLogValve.java 
b/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
index f7368b9523..6f5fbe6c6e 100644
--- a/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
+++ b/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
@@ -541,7 +541,19 @@ public class ExtendedAccessLogValve extends AccessLogValve 
{
 if (tokenizer.hasSubToken()) {
 String nextToken = tokenizer.getToken();
 if 

Re: [PR] Add support for timescales with time-taken access log token. [tomcat]

2024-04-26 Thread via GitHub


ChristopherSchultz merged PR #721:
URL: https://github.com/apache/tomcat/pull/721


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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



Re: Refactoring heads up

2024-04-26 Thread Mark Thomas

On 24/04/2024 17:52, Mark Thomas wrote:



My plan is to commit these changes to 11.0.x with the low risk parts 
(e.g. new methods) back-ported. Then, once we can see what is left, we 
can decide how quickly/slowly we want to back-port the complete fix to 
10.1.x and 9.0.x (the issue was reported against 10.1.x).


All is looking good so far.

The complete refactoring has been applied to 11.0.x

10.1.x and 9.0.x have the new header parser and are using it for the 
ChunkedInputFilter.


The question is how long do we want to wait before back-porting the 
standard HTTP header parsing? Essentially this means back-porting this 
commit:


https://github.com/apache/tomcat/commit/e5acf2cf0f745350c85d81532826d92b1882469a

Thoughts?

I'm thinking wait at least one release cycle before back-porting just in 
case of regressions given that this affects every request.


Mark

-
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 +
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitAfterExtensionDelimter() 

(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
+

(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 +
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitAfterExtensionDelimter() 

(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
+

(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
+

(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 +
+"012345678901FINISHED" + SimpleHttpClient.CRLF +
+"0" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF};
+
+doTestNonBlockingReadChunked(requestBody);
+}
+
+
+@Test
+public void testNonBlockingReadChunkedSplitAfterExtensionDelimter() 

(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 9.0.x updated: Remove redundant override javadoc

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

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


The following commit(s) were added to refs/heads/9.0.x by this push:
 new 4d23ff3142 Remove redundant override javadoc
4d23ff3142 is described below

commit 4d23ff314207f5d99c4bc8d74c1e5040f176308f
Author: remm 
AuthorDate: Fri Apr 26 15:09:15 2024 +0200

Remove redundant override javadoc
---
 java/org/apache/catalina/core/ContainerBase.java   | 142 -
 java/org/apache/catalina/core/StandardContext.java | 572 ++---
 java/org/apache/catalina/core/StandardEngine.java  |  48 +-
 java/org/apache/catalina/core/StandardHost.java|  97 +---
 .../org/apache/catalina/core/StandardPipeline.java |  64 ---
 java/org/apache/catalina/core/StandardServer.java  |  93 +---
 java/org/apache/catalina/core/StandardService.java |  65 +--
 java/org/apache/catalina/core/StandardWrapper.java | 174 +--
 .../apache/catalina/util/LifecycleMBeanBase.java   |  26 -
 9 files changed, 60 insertions(+), 1221 deletions(-)

diff --git a/java/org/apache/catalina/core/ContainerBase.java 
b/java/org/apache/catalina/core/ContainerBase.java
index 43201c19ed..7f26093591 100644
--- a/java/org/apache/catalina/core/ContainerBase.java
+++ b/java/org/apache/catalina/core/ContainerBase.java
@@ -280,32 +280,18 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 }
 
 
-/**
- * Get the delay between the invocation of the backgroundProcess method on 
this container and its children. Child
- * containers will not be invoked if their delay value is not negative 
(which would mean they are using their own
- * thread). Setting this to a positive value will cause a thread to be 
spawn. After waiting the specified amount of
- * time, the thread will invoke the executePeriodic method on this 
container and all its children.
- */
 @Override
 public int getBackgroundProcessorDelay() {
 return backgroundProcessorDelay;
 }
 
 
-/**
- * Set the delay between the invocation of the execute method on this 
container and its children.
- *
- * @param delay The delay in seconds between the invocation of 
backgroundProcess methods
- */
 @Override
 public void setBackgroundProcessorDelay(int delay) {
 backgroundProcessorDelay = delay;
 }
 
 
-/**
- * Return the Logger for this Container.
- */
 @Override
 public Log getLogger() {
 if (logger != null) {
@@ -316,9 +302,6 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 }
 
 
-/**
- * @return the abbreviated name of this container for logging messages
- */
 @Override
 public String getLogName() {
 
@@ -343,10 +326,6 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 }
 
 
-/**
- * Return the Cluster with which this Container is associated. If there is 
no associated Cluster, return the Cluster
- * associated with our parent Container (if any); otherwise return 
null.
- */
 @Override
 public Cluster getCluster() {
 Lock readLock = clusterLock.readLock();
@@ -381,11 +360,6 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 }
 
 
-/**
- * Set the Cluster with which this Container is associated.
- *
- * @param cluster The newly associated Cluster
- */
 @Override
 public void setCluster(Cluster cluster) {
 
@@ -429,25 +403,12 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 }
 
 
-/**
- * Return a name string (suitable for use by humans) that describes this 
Container. Within the set of child
- * containers belonging to a particular parent, Container names must be 
unique.
- */
 @Override
 public String getName() {
 return name;
 }
 
 
-/**
- * Set a name string (suitable for use by humans) that describes this 
Container. Within the set of child containers
- * belonging to a particular parent, Container names must be unique.
- *
- * @param name New name of this container
- *
- * @exception IllegalStateException if this Container has already been 
added to the children of a parent Container
- *  (after which the name may not be 
changed)
- */
 @Override
 public void setName(String name) {
 if (name == null) {
@@ -482,24 +443,12 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 }
 
 
-/**
- * Return the Container for which this Container is a child, if there is 
one. If there is no defined parent, return
- * null.
- */
 @Override
 public Container getParent() {
 return parent;
 }
 
 
-/**
- * Set the parent Container to which this Container is being 

(tomcat) branch 10.1.x updated: Remove redundant override javadoc

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

remm 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 4e92dc6044 Remove redundant override javadoc
4e92dc6044 is described below

commit 4e92dc60442f87b43ed0c64794270c5ee20e0009
Author: remm 
AuthorDate: Fri Apr 26 15:09:15 2024 +0200

Remove redundant override javadoc
---
 java/org/apache/catalina/core/ContainerBase.java   | 142 -
 java/org/apache/catalina/core/StandardContext.java | 572 ++---
 java/org/apache/catalina/core/StandardEngine.java  |  48 +-
 java/org/apache/catalina/core/StandardHost.java|  97 +---
 .../org/apache/catalina/core/StandardPipeline.java |  64 ---
 java/org/apache/catalina/core/StandardServer.java  |  93 +---
 java/org/apache/catalina/core/StandardService.java |  65 +--
 java/org/apache/catalina/core/StandardWrapper.java | 159 +-
 .../apache/catalina/util/LifecycleMBeanBase.java   |  26 -
 9 files changed, 60 insertions(+), 1206 deletions(-)

diff --git a/java/org/apache/catalina/core/ContainerBase.java 
b/java/org/apache/catalina/core/ContainerBase.java
index 43201c19ed..7f26093591 100644
--- a/java/org/apache/catalina/core/ContainerBase.java
+++ b/java/org/apache/catalina/core/ContainerBase.java
@@ -280,32 +280,18 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 }
 
 
-/**
- * Get the delay between the invocation of the backgroundProcess method on 
this container and its children. Child
- * containers will not be invoked if their delay value is not negative 
(which would mean they are using their own
- * thread). Setting this to a positive value will cause a thread to be 
spawn. After waiting the specified amount of
- * time, the thread will invoke the executePeriodic method on this 
container and all its children.
- */
 @Override
 public int getBackgroundProcessorDelay() {
 return backgroundProcessorDelay;
 }
 
 
-/**
- * Set the delay between the invocation of the execute method on this 
container and its children.
- *
- * @param delay The delay in seconds between the invocation of 
backgroundProcess methods
- */
 @Override
 public void setBackgroundProcessorDelay(int delay) {
 backgroundProcessorDelay = delay;
 }
 
 
-/**
- * Return the Logger for this Container.
- */
 @Override
 public Log getLogger() {
 if (logger != null) {
@@ -316,9 +302,6 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 }
 
 
-/**
- * @return the abbreviated name of this container for logging messages
- */
 @Override
 public String getLogName() {
 
@@ -343,10 +326,6 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 }
 
 
-/**
- * Return the Cluster with which this Container is associated. If there is 
no associated Cluster, return the Cluster
- * associated with our parent Container (if any); otherwise return 
null.
- */
 @Override
 public Cluster getCluster() {
 Lock readLock = clusterLock.readLock();
@@ -381,11 +360,6 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 }
 
 
-/**
- * Set the Cluster with which this Container is associated.
- *
- * @param cluster The newly associated Cluster
- */
 @Override
 public void setCluster(Cluster cluster) {
 
@@ -429,25 +403,12 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 }
 
 
-/**
- * Return a name string (suitable for use by humans) that describes this 
Container. Within the set of child
- * containers belonging to a particular parent, Container names must be 
unique.
- */
 @Override
 public String getName() {
 return name;
 }
 
 
-/**
- * Set a name string (suitable for use by humans) that describes this 
Container. Within the set of child containers
- * belonging to a particular parent, Container names must be unique.
- *
- * @param name New name of this container
- *
- * @exception IllegalStateException if this Container has already been 
added to the children of a parent Container
- *  (after which the name may not be 
changed)
- */
 @Override
 public void setName(String name) {
 if (name == null) {
@@ -482,24 +443,12 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 }
 
 
-/**
- * Return the Container for which this Container is a child, if there is 
one. If there is no defined parent, return
- * null.
- */
 @Override
 public Container getParent() {
 return parent;
 }
 
 
-/**
- * Set the parent Container to which this Container is 

(tomcat) branch main updated: Remove redundant override javadoc

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

remm 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 c1664157ce Remove redundant override javadoc
c1664157ce is described below

commit c1664157ce1e8b26a85acfd4b9b800eaea626409
Author: remm 
AuthorDate: Fri Apr 26 15:09:15 2024 +0200

Remove redundant override javadoc
---
 java/org/apache/catalina/core/ContainerBase.java   | 142 -
 java/org/apache/catalina/core/StandardContext.java | 572 ++---
 java/org/apache/catalina/core/StandardEngine.java  |  48 +-
 java/org/apache/catalina/core/StandardHost.java|  97 +---
 .../org/apache/catalina/core/StandardPipeline.java |  64 ---
 java/org/apache/catalina/core/StandardServer.java  |  93 +---
 java/org/apache/catalina/core/StandardService.java |  65 +--
 java/org/apache/catalina/core/StandardWrapper.java | 159 +-
 .../apache/catalina/util/LifecycleMBeanBase.java   |  26 -
 9 files changed, 60 insertions(+), 1206 deletions(-)

diff --git a/java/org/apache/catalina/core/ContainerBase.java 
b/java/org/apache/catalina/core/ContainerBase.java
index 7963ededb9..1a3220f52c 100644
--- a/java/org/apache/catalina/core/ContainerBase.java
+++ b/java/org/apache/catalina/core/ContainerBase.java
@@ -257,32 +257,18 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 }
 
 
-/**
- * Get the delay between the invocation of the backgroundProcess method on 
this container and its children. Child
- * containers will not be invoked if their delay value is not negative 
(which would mean they are using their own
- * thread). Setting this to a positive value will cause a thread to be 
spawn. After waiting the specified amount of
- * time, the thread will invoke the executePeriodic method on this 
container and all its children.
- */
 @Override
 public int getBackgroundProcessorDelay() {
 return backgroundProcessorDelay;
 }
 
 
-/**
- * Set the delay between the invocation of the execute method on this 
container and its children.
- *
- * @param delay The delay in seconds between the invocation of 
backgroundProcess methods
- */
 @Override
 public void setBackgroundProcessorDelay(int delay) {
 backgroundProcessorDelay = delay;
 }
 
 
-/**
- * Return the Logger for this Container.
- */
 @Override
 public Log getLogger() {
 if (logger != null) {
@@ -293,9 +279,6 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 }
 
 
-/**
- * @return the abbreviated name of this container for logging messages
- */
 @Override
 public String getLogName() {
 
@@ -320,10 +303,6 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 }
 
 
-/**
- * Return the Cluster with which this Container is associated. If there is 
no associated Cluster, return the Cluster
- * associated with our parent Container (if any); otherwise return 
null.
- */
 @Override
 public Cluster getCluster() {
 Lock readLock = clusterLock.readLock();
@@ -358,11 +337,6 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 }
 
 
-/**
- * Set the Cluster with which this Container is associated.
- *
- * @param cluster The newly associated Cluster
- */
 @Override
 public void setCluster(Cluster cluster) {
 
@@ -406,25 +380,12 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 }
 
 
-/**
- * Return a name string (suitable for use by humans) that describes this 
Container. Within the set of child
- * containers belonging to a particular parent, Container names must be 
unique.
- */
 @Override
 public String getName() {
 return name;
 }
 
 
-/**
- * Set a name string (suitable for use by humans) that describes this 
Container. Within the set of child containers
- * belonging to a particular parent, Container names must be unique.
- *
- * @param name New name of this container
- *
- * @exception IllegalStateException if this Container has already been 
added to the children of a parent Container
- *  (after which the name may not be 
changed)
- */
 @Override
 public void setName(String name) {
 if (name == null) {
@@ -459,24 +420,12 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 }
 
 
-/**
- * Return the Container for which this Container is a child, if there is 
one. If there is no defined parent, return
- * null.
- */
 @Override
 public Container getParent() {
 return parent;
 }
 
 
-/**
- * Set the parent Container to which this Container is being 

(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