Re: [PR] fix bz #69316 FastHttpDateFormat - getCurrentDate() returns inaccurate result [tomcat]

2024-09-12 Thread via GitHub


markt-asf commented on code in PR #751:
URL: https://github.com/apache/tomcat/pull/751#discussion_r1756307644


##
java/org/apache/tomcat/util/http/FastHttpDateFormat.java:
##
@@ -104,8 +104,9 @@ public final class FastHttpDateFormat {
  */
 public static String getCurrentDate() {
 long now = System.currentTimeMillis();
-// Handle case where time moves backwards (e.g. system time corrected)
-if (Math.abs(now - currentDateGenerated) > 1000) {
+// Ignore millisecond part.
+now -= now % 1000L;

Review Comment:
   Is `long now = System.currentTimeMillis() / 1000L;` not faster?



-- 
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: [PR] fix bz #69316 FastHttpDateFormat - getCurrentDate() returns inaccurate result [tomcat]

2024-09-12 Thread via GitHub


Chenjp commented on code in PR #751:
URL: https://github.com/apache/tomcat/pull/751#discussion_r1756465922


##
java/org/apache/tomcat/util/http/FastHttpDateFormat.java:
##
@@ -104,8 +104,9 @@ public final class FastHttpDateFormat {
  */
 public static String getCurrentDate() {
 long now = System.currentTimeMillis();
-// Handle case where time moves backwards (e.g. system time corrected)
-if (Math.abs(now - currentDateGenerated) > 1000) {
+// Ignore millisecond part.
+now -= now % 1000L;

Review Comment:
   Without significant improvement .
   1. solution1: Duration: ***322245800ns*** (1 times)
   ```java
   public static String getCurrentDate() {
   long now = System.currentTimeMillis() / 1000L;
   if (now != currentDateGenerated) {
   currentDate = FORMAT_RFC5322.format(new Date(now*1000L));
   currentDateGenerated = now;
   }
   return currentDate;
   }
   ```
   2. solution2: Duration: ***328164000ns*** (1 times)
   ```java
   public static String getCurrentDate() {
   long now = System.currentTimeMillis();
   // Ignore millisecond part.
   now -= now % 1000L;
   if (now != currentDateGenerated) {
   currentDate = FORMAT_RFC5322.format(new Date(now));
   currentDateGenerated = now;
   }
   return currentDate;
   }
   ```
   
   



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



(tomcat) branch main updated: Remove unused code

2024-09-12 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 eec1b2347a Remove unused code
eec1b2347a is described below

commit eec1b2347abc357d38ada154e61a53be1081adb8
Author: remm 
AuthorDate: Thu Sep 12 11:19:13 2024 +0200

Remove unused code
---
 java/org/apache/tomcat/util/buf/ByteBufferUtils.java | 17 +
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/java/org/apache/tomcat/util/buf/ByteBufferUtils.java 
b/java/org/apache/tomcat/util/buf/ByteBufferUtils.java
index db1f68287d..552ce94c3a 100644
--- a/java/org/apache/tomcat/util/buf/ByteBufferUtils.java
+++ b/java/org/apache/tomcat/util/buf/ByteBufferUtils.java
@@ -31,14 +31,10 @@ public class ByteBufferUtils {
 private static final Log log = LogFactory.getLog(ByteBufferUtils.class);
 
 private static final Object unsafe;
-private static final Method cleanerMethod;
-private static final Method cleanMethod;
 private static final Method invokeCleanerMethod;
 
 static {
 ByteBuffer tempBuffer = ByteBuffer.allocateDirect(0);
-Method cleanerMethodLocal = null;
-Method cleanMethodLocal = null;
 Object unsafeLocal = null;
 Method invokeCleanerMethodLocal = null;
 try {
@@ -54,8 +50,6 @@ public class ByteBufferUtils {
 unsafeLocal = null;
 invokeCleanerMethodLocal = null;
 }
-cleanerMethod = cleanerMethodLocal;
-cleanMethod = cleanMethodLocal;
 unsafe = unsafeLocal;
 invokeCleanerMethod = invokeCleanerMethodLocal;
 }
@@ -101,16 +95,7 @@ public class ByteBufferUtils {
 }
 
 public static void cleanDirectBuffer(ByteBuffer buf) {
-if (cleanMethod != null) {
-try {
-cleanMethod.invoke(cleanerMethod.invoke(buf));
-} catch (IllegalAccessException | IllegalArgumentException | 
InvocationTargetException |
-SecurityException e) {
-if (log.isDebugEnabled()) {
-log.debug(sm.getString("byteBufferUtils.cleaner"), e);
-}
-}
-} else if (invokeCleanerMethod != null) {
+if (invokeCleanerMethod != null) {
 try {
 invokeCleanerMethod.invoke(unsafe, buf);
 } catch (IllegalAccessException | IllegalArgumentException | 
InvocationTargetException |


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



(tomcat) branch 11.0.x updated: Remove unused code

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

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


The following commit(s) were added to refs/heads/11.0.x by this push:
 new e34c8f6b9b Remove unused code
e34c8f6b9b is described below

commit e34c8f6b9b4112a47e1dde01b739646f85399eae
Author: remm 
AuthorDate: Thu Sep 12 11:19:13 2024 +0200

Remove unused code
---
 java/org/apache/tomcat/util/buf/ByteBufferUtils.java | 17 +
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/java/org/apache/tomcat/util/buf/ByteBufferUtils.java 
b/java/org/apache/tomcat/util/buf/ByteBufferUtils.java
index db1f68287d..552ce94c3a 100644
--- a/java/org/apache/tomcat/util/buf/ByteBufferUtils.java
+++ b/java/org/apache/tomcat/util/buf/ByteBufferUtils.java
@@ -31,14 +31,10 @@ public class ByteBufferUtils {
 private static final Log log = LogFactory.getLog(ByteBufferUtils.class);
 
 private static final Object unsafe;
-private static final Method cleanerMethod;
-private static final Method cleanMethod;
 private static final Method invokeCleanerMethod;
 
 static {
 ByteBuffer tempBuffer = ByteBuffer.allocateDirect(0);
-Method cleanerMethodLocal = null;
-Method cleanMethodLocal = null;
 Object unsafeLocal = null;
 Method invokeCleanerMethodLocal = null;
 try {
@@ -54,8 +50,6 @@ public class ByteBufferUtils {
 unsafeLocal = null;
 invokeCleanerMethodLocal = null;
 }
-cleanerMethod = cleanerMethodLocal;
-cleanMethod = cleanMethodLocal;
 unsafe = unsafeLocal;
 invokeCleanerMethod = invokeCleanerMethodLocal;
 }
@@ -101,16 +95,7 @@ public class ByteBufferUtils {
 }
 
 public static void cleanDirectBuffer(ByteBuffer buf) {
-if (cleanMethod != null) {
-try {
-cleanMethod.invoke(cleanerMethod.invoke(buf));
-} catch (IllegalAccessException | IllegalArgumentException | 
InvocationTargetException |
-SecurityException e) {
-if (log.isDebugEnabled()) {
-log.debug(sm.getString("byteBufferUtils.cleaner"), e);
-}
-}
-} else if (invokeCleanerMethod != null) {
+if (invokeCleanerMethod != null) {
 try {
 invokeCleanerMethod.invoke(unsafe, buf);
 } catch (IllegalAccessException | IllegalArgumentException | 
InvocationTargetException |


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



(tomcat) branch 10.1.x updated: Remove unused code

2024-09-12 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 730310c69b Remove unused code
730310c69b is described below

commit 730310c69b46104657f3e593d7b4d98d34844b8b
Author: remm 
AuthorDate: Thu Sep 12 11:19:13 2024 +0200

Remove unused code
---
 java/org/apache/tomcat/util/buf/ByteBufferUtils.java | 17 +
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/java/org/apache/tomcat/util/buf/ByteBufferUtils.java 
b/java/org/apache/tomcat/util/buf/ByteBufferUtils.java
index db1f68287d..552ce94c3a 100644
--- a/java/org/apache/tomcat/util/buf/ByteBufferUtils.java
+++ b/java/org/apache/tomcat/util/buf/ByteBufferUtils.java
@@ -31,14 +31,10 @@ public class ByteBufferUtils {
 private static final Log log = LogFactory.getLog(ByteBufferUtils.class);
 
 private static final Object unsafe;
-private static final Method cleanerMethod;
-private static final Method cleanMethod;
 private static final Method invokeCleanerMethod;
 
 static {
 ByteBuffer tempBuffer = ByteBuffer.allocateDirect(0);
-Method cleanerMethodLocal = null;
-Method cleanMethodLocal = null;
 Object unsafeLocal = null;
 Method invokeCleanerMethodLocal = null;
 try {
@@ -54,8 +50,6 @@ public class ByteBufferUtils {
 unsafeLocal = null;
 invokeCleanerMethodLocal = null;
 }
-cleanerMethod = cleanerMethodLocal;
-cleanMethod = cleanMethodLocal;
 unsafe = unsafeLocal;
 invokeCleanerMethod = invokeCleanerMethodLocal;
 }
@@ -101,16 +95,7 @@ public class ByteBufferUtils {
 }
 
 public static void cleanDirectBuffer(ByteBuffer buf) {
-if (cleanMethod != null) {
-try {
-cleanMethod.invoke(cleanerMethod.invoke(buf));
-} catch (IllegalAccessException | IllegalArgumentException | 
InvocationTargetException |
-SecurityException e) {
-if (log.isDebugEnabled()) {
-log.debug(sm.getString("byteBufferUtils.cleaner"), e);
-}
-}
-} else if (invokeCleanerMethod != null) {
+if (invokeCleanerMethod != null) {
 try {
 invokeCleanerMethod.invoke(unsafe, buf);
 } catch (IllegalAccessException | IllegalArgumentException | 
InvocationTargetException |


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



[Bug 69320] New: ERR_HTTP2_PROTOCOL_ERROR

2024-09-12 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69320

Bug ID: 69320
   Summary: ERR_HTTP2_PROTOCOL_ERROR
   Product: Tomcat 10
   Version: 10.1.29
  Hardware: PC
OS: Linux
Status: NEW
  Severity: normal
  Priority: P2
 Component: Catalina
  Assignee: dev@tomcat.apache.org
  Reporter: elatl...@gmail.com
  Target Milestone: --

10.1.29 has a regression causing ERR_HTTP2_PROTOCOL_ERROR

nothing in the logs

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



[Bug 69320] ERR_HTTP2_PROTOCOL_ERROR

2024-09-12 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69320

elatl...@gmail.com changed:

   What|Removed |Added

   Priority|P2  |P5
   Severity|normal  |blocker

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



[Bug 69320] ERR_HTTP2_PROTOCOL_ERROR

2024-09-12 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69320

--- Comment #1 from Chuck Caldarale  ---
Without some useful supporting information, this will be closed as WORKSFORME.

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



[Bug 69320] ERR_HTTP2_PROTOCOL_ERROR

2024-09-12 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69320

--- Comment #2 from elatl...@gmail.com ---
I sent an email to us...@infra.apache.org because commenting on this bug is
producing a bug (Too many connections at
/usr/lib/x86_64-linux-gnu/perl5/5.34/DBI.pm line 691.)

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



[PR] Tests the compatibility with rewrite from httpd for non existent headers [tomcat]

2024-09-12 Thread via GitHub


PaulLodge opened a new pull request, #752:
URL: https://github.com/apache/tomcat/pull/752

   This test adds code coverage for CVE-2010-3718, I noticed it was missing 
from the code coverage, the fix also contains a very small code refactor that 
allows the test to work.


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



[Bug 69320] ERR_HTTP2_PROTOCOL_ERROR

2024-09-12 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69320

--- Comment #3 from elatl...@gmail.com ---
Please let me know what "supporting information" I can share. This regression
is not happening in any other 10.x build.

The last log line is just

12-Sep-2024 08:46:35.076 INFO [main] org.apache.catalina.startup.Catalina.start
Server startup in [12546] milliseconds

Http11NioProtocol and Http2Protocol are in use.

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



Re: [PR] Tests the compatibility with rewrite from httpd for non existent headers [tomcat]

2024-09-12 Thread via GitHub


n828cl commented on PR #752:
URL: https://github.com/apache/tomcat/pull/752#issuecomment-2346272595

   The new method testRewriteEmptyHeader() does not appear to be invoked from 
anywhere. Is some of the change missing?


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



[PR] Add ParameterLimitValve to enforce request parameter limits for specific URLs [tomcat]

2024-09-12 Thread via GitHub


dsoumis opened a new pull request, #753:
URL: https://github.com/apache/tomcat/pull/753

   This is an effort of introducing Parameter Limit Valve to allow limiting the 
number of parameters in HTTP requests, but explicitly allowing more parameters 
for specific URLs.
   
   It's worth to be noted that if the Parameter Limit Valve is configured, it 
operates independently of the Connector's maxParameterCount attribute. The 
Connector's maxParameterCount sets a global limit, while the Parameter Limit 
Valve offers additional flexibility by allowing different limits for specific 
URLs. However, if the maxParameterCount defined in the Connector is lower, it 
effectively overrides the valve by preventing large requests from ever reaching 
it.


-- 
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: [PR] Tests the compatibility with rewrite from httpd for non existent headers [tomcat]

2024-09-12 Thread via GitHub


rmaucher merged PR #752:
URL: https://github.com/apache/tomcat/pull/752


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



(tomcat) branch main updated (eec1b2347a -> 67dc904530)

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

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


from eec1b2347a Remove unused code
 add 98b4e8d35c Tests the compatibility with rewrite from httpd for non 
existent headers
 new 67dc904530 Merge pull request #752 from 
PaulLodge/httpd-rewrite-non-existent-header

The 1 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/rewrite/TestRewriteValve.java  | 31 --
 1 file changed, 29 insertions(+), 2 deletions(-)


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



(tomcat) 01/01: Merge pull request #752 from PaulLodge/httpd-rewrite-non-existent-header

2024-09-12 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

commit 67dc904530a42aeaca0b5c6af3dbb6f61e68917a
Merge: eec1b2347a 98b4e8d35c
Author: Rémy Maucherat 
AuthorDate: Thu Sep 12 15:38:11 2024 +0200

Merge pull request #752 from PaulLodge/httpd-rewrite-non-existent-header

Tests the compatibility with rewrite from httpd for non existent headers

 .../catalina/valves/rewrite/TestRewriteValve.java  | 31 --
 1 file changed, 29 insertions(+), 2 deletions(-)


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



(tomcat) branch 11.0.x updated: Tests the compatibility with rewrite from httpd for non existent headers

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

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


The following commit(s) were added to refs/heads/11.0.x by this push:
 new 904b6e79ed Tests the compatibility with rewrite from httpd for non 
existent headers
904b6e79ed is described below

commit 904b6e79ed21435dd9e8017d808f30683d9eeb3c
Author: Paul Lodge 
AuthorDate: Thu Sep 12 13:09:51 2024 +0200

Tests the compatibility with rewrite from httpd for non existent headers
---
 .../catalina/valves/rewrite/TestRewriteValve.java  | 31 --
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java 
b/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
index 464a960384..da4d1c1052 100644
--- a/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
+++ b/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.net.HttpURLConnection;
 import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -617,6 +618,23 @@ public class TestRewriteValve extends TomcatBaseTest {
 "/c", null, "aAa");
 }
 
+@Test
+public void testRewriteEmptyHeader() throws Exception {
+
+// Disable the following of redirects for this test only
+boolean originalValue = HttpURLConnection.getFollowRedirects();
+HttpURLConnection.setFollowRedirects(false);
+try {
+Map> resHead = new HashMap<>();
+Map> reqHead = new HashMap<>();
+reqHead.put("\"\"", Arrays.asList(new String[]{"Test"}));
+doTestRewriteEx("RewriteCond %{HTTP:} .+\nRewriteRule .* - [F]", 
"",
+null, null, null, false, resHead, reqHead);
+} finally {
+HttpURLConnection.setFollowRedirects(originalValue);
+}
+}
+
 
 @Test
 public void testHostRewrite() throws Exception {
@@ -740,6 +758,12 @@ public class TestRewriteValve extends TomcatBaseTest {
 
 private void doTestRewrite(String config, String request, String 
expectedURI, String expectedQueryString,
 String expectedAttributeValue, boolean valveSkip) throws Exception 
{
+doTestRewriteEx(config, request, expectedURI, expectedQueryString,
+expectedAttributeValue, valveSkip, null, null);
+}
+
+private void doTestRewriteEx(String config, String request, String 
expectedURI, String expectedQueryString,
+String expectedAttributeValue, boolean valveSkip, Map> resHead, Map> reqHead ) throws Exception {
 
 Tomcat tomcat = getTomcatInstance();
 
@@ -769,7 +793,10 @@ public class TestRewriteValve extends TomcatBaseTest {
 tomcat.start();
 
 ByteChunk res = new ByteChunk();
-int rc = getUrl("http://localhost:"; + getPort() + request, res, null);
+int rc = methodUrl("http://localhost:"; + getPort() + request, res, 
DEFAULT_CLIENT_TIMEOUT_MS,
+reqHead,
+resHead,
+"GET", true);
 res.setCharset(StandardCharsets.UTF_8);
 
 if (expectedURI == null) {
@@ -855,7 +882,7 @@ public class TestRewriteValve extends TomcatBaseTest {
 tomcat.start();
 
 Map> reqHead = new HashMap<>();
-reqHead.put("cookie", List.of("test=data"));
+reqHead.put("cookie", Arrays.asList("test=data"));
 ByteChunk res = new ByteChunk();
 int rc = methodUrl("http://localhost:"; + getPort() + 
"/source/cookieTest", res, DEFAULT_CLIENT_TIMEOUT_MS,
 reqHead, null, "GET", false);


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



(tomcat) branch 10.1.x updated: Tests the compatibility with rewrite from httpd for non existent headers

2024-09-12 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 6bb7babff4 Tests the compatibility with rewrite from httpd for non 
existent headers
6bb7babff4 is described below

commit 6bb7babff48448084c7ce9e9d464da3f7f9ceeb9
Author: Paul Lodge 
AuthorDate: Thu Sep 12 13:09:51 2024 +0200

Tests the compatibility with rewrite from httpd for non existent headers
---
 .../catalina/valves/rewrite/TestRewriteValve.java  | 31 --
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java 
b/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
index 464a960384..da4d1c1052 100644
--- a/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
+++ b/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.net.HttpURLConnection;
 import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -617,6 +618,23 @@ public class TestRewriteValve extends TomcatBaseTest {
 "/c", null, "aAa");
 }
 
+@Test
+public void testRewriteEmptyHeader() throws Exception {
+
+// Disable the following of redirects for this test only
+boolean originalValue = HttpURLConnection.getFollowRedirects();
+HttpURLConnection.setFollowRedirects(false);
+try {
+Map> resHead = new HashMap<>();
+Map> reqHead = new HashMap<>();
+reqHead.put("\"\"", Arrays.asList(new String[]{"Test"}));
+doTestRewriteEx("RewriteCond %{HTTP:} .+\nRewriteRule .* - [F]", 
"",
+null, null, null, false, resHead, reqHead);
+} finally {
+HttpURLConnection.setFollowRedirects(originalValue);
+}
+}
+
 
 @Test
 public void testHostRewrite() throws Exception {
@@ -740,6 +758,12 @@ public class TestRewriteValve extends TomcatBaseTest {
 
 private void doTestRewrite(String config, String request, String 
expectedURI, String expectedQueryString,
 String expectedAttributeValue, boolean valveSkip) throws Exception 
{
+doTestRewriteEx(config, request, expectedURI, expectedQueryString,
+expectedAttributeValue, valveSkip, null, null);
+}
+
+private void doTestRewriteEx(String config, String request, String 
expectedURI, String expectedQueryString,
+String expectedAttributeValue, boolean valveSkip, Map> resHead, Map> reqHead ) throws Exception {
 
 Tomcat tomcat = getTomcatInstance();
 
@@ -769,7 +793,10 @@ public class TestRewriteValve extends TomcatBaseTest {
 tomcat.start();
 
 ByteChunk res = new ByteChunk();
-int rc = getUrl("http://localhost:"; + getPort() + request, res, null);
+int rc = methodUrl("http://localhost:"; + getPort() + request, res, 
DEFAULT_CLIENT_TIMEOUT_MS,
+reqHead,
+resHead,
+"GET", true);
 res.setCharset(StandardCharsets.UTF_8);
 
 if (expectedURI == null) {
@@ -855,7 +882,7 @@ public class TestRewriteValve extends TomcatBaseTest {
 tomcat.start();
 
 Map> reqHead = new HashMap<>();
-reqHead.put("cookie", List.of("test=data"));
+reqHead.put("cookie", Arrays.asList("test=data"));
 ByteChunk res = new ByteChunk();
 int rc = methodUrl("http://localhost:"; + getPort() + 
"/source/cookieTest", res, DEFAULT_CLIENT_TIMEOUT_MS,
 reqHead, null, "GET", false);


-
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: Tests the compatibility with rewrite from httpd for non existent headers

2024-09-12 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 f035e6a278 Tests the compatibility with rewrite from httpd for non 
existent headers
f035e6a278 is described below

commit f035e6a27867855e587a5b4e5226c285271c7057
Author: Paul Lodge 
AuthorDate: Thu Sep 12 13:09:51 2024 +0200

Tests the compatibility with rewrite from httpd for non existent headers
---
 .../catalina/valves/rewrite/TestRewriteValve.java  | 28 +-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java 
b/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
index bd2163ba45..3a08886229 100644
--- a/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
+++ b/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
@@ -618,6 +618,23 @@ public class TestRewriteValve extends TomcatBaseTest {
 "/c", null, "aAa");
 }
 
+@Test
+public void testRewriteEmptyHeader() throws Exception {
+
+// Disable the following of redirects for this test only
+boolean originalValue = HttpURLConnection.getFollowRedirects();
+HttpURLConnection.setFollowRedirects(false);
+try {
+Map> resHead = new HashMap<>();
+Map> reqHead = new HashMap<>();
+reqHead.put("\"\"", Arrays.asList(new String[]{"Test"}));
+doTestRewriteEx("RewriteCond %{HTTP:} .+\nRewriteRule .* - [F]", 
"",
+null, null, null, false, resHead, reqHead);
+} finally {
+HttpURLConnection.setFollowRedirects(originalValue);
+}
+}
+
 
 @Test
 public void testHostRewrite() throws Exception {
@@ -741,6 +758,12 @@ public class TestRewriteValve extends TomcatBaseTest {
 
 private void doTestRewrite(String config, String request, String 
expectedURI, String expectedQueryString,
 String expectedAttributeValue, boolean valveSkip) throws Exception 
{
+doTestRewriteEx(config, request, expectedURI, expectedQueryString,
+expectedAttributeValue, valveSkip, null, null);
+}
+
+private void doTestRewriteEx(String config, String request, String 
expectedURI, String expectedQueryString,
+String expectedAttributeValue, boolean valveSkip, Map> resHead, Map> reqHead ) throws Exception {
 
 Tomcat tomcat = getTomcatInstance();
 
@@ -770,7 +793,10 @@ public class TestRewriteValve extends TomcatBaseTest {
 tomcat.start();
 
 ByteChunk res = new ByteChunk();
-int rc = getUrl("http://localhost:"; + getPort() + request, res, null);
+int rc = methodUrl("http://localhost:"; + getPort() + request, res, 
DEFAULT_CLIENT_TIMEOUT_MS,
+reqHead,
+resHead,
+"GET", true);
 res.setCharset(StandardCharsets.UTF_8);
 
 if (expectedURI == null) {


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



Future of JNI in Tomcat

2024-09-12 Thread Rémy Maucherat
Hi,

This JEP has the potential to have a significant impact with Tomcat's
JNI use starting with Java 26.
https://openjdk.org/jeps/471

Unsafe.invokeCleaner will be removed, which will effectively prevent
using the direct ByteBuffers that are needed for tomcat-native. The
solution is to use a memory segment from FFM, then call
MemorySegment.asByteBuffer, which creates a direct ByteBuffer with a
controllable lifecycle. So using JNI would require FFM and using the
full FFM code instead should make more sense.

We will of course have to see how things turn out ...

Another, less problematic, yet still annoying change will be
https://openjdk.org/jeps/472 in Java 24+. Basically, the native access
flag use will become mandatory. This is a bit annoying since it is not
possible to add "--enable-native-access=ALL-UNNAMED" in the default
command line without breaking on older Java.

Rémy

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



Re: [PR] fix bz #69316 FastHttpDateFormat - getCurrentDate() returns inaccurate result [tomcat]

2024-09-12 Thread via GitHub


markt-asf commented on code in PR #751:
URL: https://github.com/apache/tomcat/pull/751#discussion_r1757204766


##
java/org/apache/tomcat/util/http/FastHttpDateFormat.java:
##
@@ -104,8 +104,9 @@ public final class FastHttpDateFormat {
  */
 public static String getCurrentDate() {
 long now = System.currentTimeMillis();
-// Handle case where time moves backwards (e.g. system time corrected)
-if (Math.abs(now - currentDateGenerated) > 1000) {
+// Ignore millisecond part.
+now -= now % 1000L;

Review Comment:
   That performance difference is pretty marginal but I do think division by 
1000 is simpler code.



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



[Bug 69320] ERR_HTTP2_PROTOCOL_ERROR

2024-09-12 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69320

--- Comment #4 from Mark Thomas  ---
I'll note that bugs that get reported during the release vote nearly always
result in the vote being cancelled, the bug being fixed and a new release vote.
To put it another way, test the release candidate during the vote and bugs get
fixed a lot sooner than if you only test once the release is announced.
Typically days rather than ~1 month.

The steps to recreate the issue are just make an h2 request for the Tomcat home
page.

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



Possible HTTP/2 regression in Sept releases

2024-09-12 Thread Mark Thomas
See BZ 69320. I've reproduced the issue on 10.1.x. Haven't tested other 
versions yet or started to look for a root cause. That is next.


Mark


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



Re: Future of JNI in Tomcat

2024-09-12 Thread Mark Thomas

On 12/09/2024 15:15, Rémy Maucherat wrote:

Hi,

This JEP has the potential to have a significant impact with Tomcat's
JNI use starting with Java 26.
https://openjdk.org/jeps/471

Unsafe.invokeCleaner will be removed, which will effectively prevent
using the direct ByteBuffers that are needed for tomcat-native. The
solution is to use a memory segment from FFM, then call
MemorySegment.asByteBuffer, which creates a direct ByteBuffer with a
controllable lifecycle. So using JNI would require FFM and using the
full FFM code instead should make more sense.


+1.


We will of course have to see how things turn out ...


FFM is looking more and more like the way to go.


Another, less problematic, yet still annoying change will be
https://openjdk.org/jeps/472 in Java 24+. Basically, the native access
flag use will become mandatory. This is a bit annoying since it is not
possible to add "--enable-native-access=ALL-UNNAMED" in the default
command line without breaking on older Java.


So we have issues when running older Tomcats that have to work with JREs 
that don't have FFM - hence they need JNI.


We have had issues like this before and have managed to hack around 
them. Maybe it is time for slightly more robust solution. I was thinking 
something like:


- new class in bootstrap JAR with a main method that just returns the 
current major java version as the exit code


- the startup scripts call java with that class and store exit code in a 
variable


- we use that variable to select what to include when composing the main 
command line to start Tomcat.


Mark


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



Re: [PR] Add ParameterLimitValve to enforce request parameter limits for specific URLs [tomcat]

2024-09-12 Thread via GitHub


markt-asf commented on PR #753:
URL: https://github.com/apache/tomcat/pull/753#issuecomment-2346801534

   This approach could be implemented as a Filter. If we were going to do this, 
I think something that enforces the limit at the point the parameters are 
parsed - rather than after - is the way to go. It would mean some refactoring 
of `Request.doParseParameters()` and I haven't thought it all the way through 
but it looks doable. Maybe add a maxParameterCount field to the request that is 
reset from the current connector value on recycle but the Valve could then 
change it. The added bonus is that if the app doesn't trigger parameter 
parsing, the parameters won't get parsed.


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



[Bug 69320] ERR_HTTP2_PROTOCOL_ERROR

2024-09-12 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69320

--- Comment #5 from elatl...@gmail.com ---
(In reply to Mark Thomas from comment #4)
> I'll note that bugs that get reported during the release vote nearly always
> result in the vote being cancelled, the bug being fixed and a new release
> vote. To put it another way, test the release candidate during the vote and
> bugs get fixed a lot sooner than if you only test once the release is
> announced.

Where can the RCs be found?

> Typically days rather than ~1 month.

In my experience, from the 1 person projects to the Linux kernel, bugs in a
supported branch get fixed ASAP. Why have no good version for a whole month?
(assuming the last release has a blocking bug and the 2nd last release has
publicly known security issues)

> The steps to recreate the issue are just make an h2 request for the Tomcat
> home page.

curl example?

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



[Bug 69320] ERR_HTTP2_PROTOCOL_ERROR

2024-09-12 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69320

--- Comment #6 from Mark Thomas  ---
Release votes are announced on the dev list.

It appears that this bug is harder to reproduce that it first appeared. I've
seen in - or something that might be it - with 10.1.x and 11.0.x but not 9.0.x
and I cannot reproduce it reliably. Or at all at the moment.

If you have steps that reliably recreate the issue please share them here.

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



[Bug 69320] ERR_HTTP2_PROTOCOL_ERROR

2024-09-12 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69320

--- Comment #7 from EJ Egyed  ---
Created attachment 39865
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=39865&action=edit
Catalina log file

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



[Bug 69320] ERR_HTTP2_PROTOCOL_ERROR

2024-09-12 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69320

--- Comment #8 from EJ Egyed  ---
I am experiencing an error I believe is related on 9.0.94. After reverting to
9.0.93 the error went away. I am not sure how to reproduce the error, but was
seeing errors written to the catalina log file. Attached is a stack trace of
one of what I believe to be related.

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



[Bug 69320] ERR_HTTP2_PROTOCOL_ERROR

2024-09-12 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69320

--- Comment #9 from Mark Thomas  ---
The errors I am seeing on the rare occasions I am able to reproduce what I
think is this new error suggest an issue with header processing.

The stack trace in the attachment looks like the result of the client resetting
the stream.

It isn't clear if the two are related or not. The client reset may follow the
server side error.

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



[Bug 69320] ERR_HTTP2_PROTOCOL_ERROR

2024-09-12 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69320

--- Comment #10 from elatl...@gmail.com ---
(In reply to Mark Thomas from comment #6)
> Release votes are announced on the dev list.

I'm not seeing anything relevant:

https://lists.apache.org/list?dev@tomcat.apache.org:release%20candidate:

Please be more specific.


> It appears that this bug is harder to reproduce that it first appeared. I've
> seen in - or something that might be it - with 10.1.x and 11.0.x but not
> 9.0.x and I cannot reproduce it reliably. Or at all at the moment.


I can reproduce it reliably, but only on non-trivial tests.
once it's broken further trivial tests do reproduce the issue.
I can break it with Firefox, Chromium, and curl.

> If you have steps that reliably recreate the issue please share them here.

curl -v --http2 --compressed --parallel $URLS3 > o.txt 2> e.txt ; echo $?

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



[Bug 69320] ERR_HTTP2_PROTOCOL_ERROR

2024-09-12 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69320

--- Comment #11 from elatl...@gmail.com ---
Created attachment 39866
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=39866&action=edit
curl log

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



[Bug 69320] ERR_HTTP2_PROTOCOL_ERROR

2024-09-12 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69320

--- Comment #12 from elatl...@gmail.com ---
I can trigger this issue just by reloading a page with ~40 assets.
I can not trigger it on a page with 5 assets.

Once the issue is triggered it manifests on pages with 5 assets (2 to 4 of 5
will fail).

Web browsers only do about 17 concurrent requests which may be related.

The issue is more noticeable in Chromium due to the nice red errors in the net
tab of dev tools, Firefox only shows 0B which does not stand out.

It does seem related to terminated connections and maybe concurrency related.

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



[Bug 69320] ERR_HTTP2_PROTOCOL_ERROR

2024-09-12 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69320

--- Comment #13 from Mark Thomas  ---
I'm seeing something similar. Running the h2spec test suite seems to trigger
the bad state reliably. Next step is to use git bisect to figure out where the
problem was introduced. Once we know which commit introduced the issue, we will
hopefully have a better chance of identifying the root cause.

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



[Bug 69320] ERR_HTTP2_PROTOCOL_ERROR

2024-09-12 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69320

--- Comment #14 from Konstantin Kolinko  ---
(In reply to elatllat from comment #10)
> (In reply to Mark Thomas from comment #6)
> > Release votes are announced on the dev list.
> 
> I'm not seeing anything relevant:
> 
> https://lists.apache.org/list?dev@tomcat.apache.org:release%20candidate:
> 
> Please be more specific.

Search for "[VOTE]"

https://lists.apache.org/list?dev@tomcat.apache.org:lte=1y:vote

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



Re: [PR] fix bz #69316 FastHttpDateFormat - getCurrentDate() returns inaccurate result [tomcat]

2024-09-12 Thread via GitHub


Chenjp commented on code in PR #751:
URL: https://github.com/apache/tomcat/pull/751#discussion_r1758003371


##
java/org/apache/tomcat/util/http/FastHttpDateFormat.java:
##
@@ -104,8 +104,9 @@ public final class FastHttpDateFormat {
  */
 public static String getCurrentDate() {
 long now = System.currentTimeMillis();
-// Handle case where time moves backwards (e.g. system time corrected)
-if (Math.abs(now - currentDateGenerated) > 1000) {
+// Ignore millisecond part.
+now -= now % 1000L;

Review Comment:
   @markt-asf Updated, PTAL



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