Re: [PR] Allow applications to trigger sending of 103 early hints [tomcat]

2024-11-20 Thread via GitHub


Chenjp commented on PR #764:
URL: https://github.com/apache/tomcat/pull/764#issuecomment-2489895080

   @markt-asf  @ChristopherSchultz Per HttpServletResponse#sendEarlyHints(), 
where can I find "Servlet 6.2" spec?
   
   ```java
   /**
* Sends a 103 response to the client using the current response 
headers. This method does not commit the response
* and may be called multiple times before the response is committed. 
The current response headers may include some
* headers that have been added automatically by the container.
* 
* This method has no effect if called after the response has been 
committed.
*
* @since Servlet 6.2
*/
   void sendEarlyHints();
   ```


-- 
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] Partial put - enhance content range verification [tomcat]

2024-11-20 Thread via GitHub


Chenjp commented on PR #778:
URL: https://github.com/apache/tomcat/pull/778#issuecomment-2489897959

   > Ok, that's correct, the end is also inclusive.
   
   @rmaucher any further comments?


-- 
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 (5b9d92c721 -> 1ef2b68a58)

2024-11-20 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 5b9d92c721 Add missing quotes for etag
 new 614a05290e Avoid throw - catch - re-throw for CNFE
 new 1ef2b68a58 Fix BZ 69447 notFoundClassResources should allow for 
external resources

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


Summary of changes:
 .../catalina/loader/WebappClassLoaderBase.java | 63 --
 webapps/docs/changelog.xml |  6 +++
 2 files changed, 41 insertions(+), 28 deletions(-)


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



(tomcat) 01/02: Avoid throw - catch - re-throw for CNFE

2024-11-20 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 614a05290ef4672755029288aa9151bbdaee6f30
Author: Mark Thomas 
AuthorDate: Wed Nov 20 20:15:44 2024 +

Avoid throw - catch - re-throw for CNFE
---
 java/org/apache/catalina/loader/WebappClassLoaderBase.java | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/catalina/loader/WebappClassLoaderBase.java 
b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
index d224e473f8..86f705fd9a 100644
--- a/java/org/apache/catalina/loader/WebappClassLoaderBase.java
+++ b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
@@ -657,18 +657,18 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
 throw e;
 }
 }
-if (clazz == null) {
-if (log.isTraceEnabled()) {
-log.trace("--> Returning ClassNotFoundException");
-}
-throw new ClassNotFoundException(name);
-}
 } catch (ClassNotFoundException e) {
 if (log.isTraceEnabled()) {
 log.trace("--> Passing on ClassNotFoundException");
 }
 throw e;
 }
+if (clazz == null) {
+if (log.isTraceEnabled()) {
+log.trace("--> Returning ClassNotFoundException");
+}
+throw new ClassNotFoundException(name);
+}
 
 // Return the class we have located
 if (log.isTraceEnabled()) {


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



(tomcat) 02/02: Fix BZ 69447 notFoundClassResources should allow for external resources

2024-11-20 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 1ef2b68a582084e645ec3c9a6cc1366cfedef45e
Author: Mark Thomas 
AuthorDate: Wed Nov 20 20:20:59 2024 +

Fix BZ 69447 notFoundClassResources should allow for external resources
---
 .../catalina/loader/WebappClassLoaderBase.java | 53 --
 webapps/docs/changelog.xml |  6 +++
 2 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/java/org/apache/catalina/loader/WebappClassLoaderBase.java 
b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
index 86f705fd9a..a34223a0b7 100644
--- a/java/org/apache/catalina/loader/WebappClassLoaderBase.java
+++ b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
@@ -632,6 +632,12 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
 
 checkStateForClassLoading(name);
 
+if (name == null) {
+throw new ClassNotFoundException("null");
+}
+
+String path = binaryNameToPath(name, true);
+
 // Ask our superclass to locate this class, if possible
 // (throws ClassNotFoundException if it is not found)
 Class clazz = null;
@@ -639,34 +645,38 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
 if (log.isTraceEnabled()) {
 log.trace("  findClassInternal(" + name + ")");
 }
-try {
-clazz = findClassInternal(name);
-} catch (RuntimeException e) {
-if (log.isTraceEnabled()) {
-log.trace("  -->RuntimeException Rethrown", e);
-}
-throw e;
-}
-if (clazz == null && hasExternalRepositories) {
+if (!notFoundClassResources.contains(path)) {
 try {
-clazz = super.findClass(name);
+clazz = findClassInternal(name, path);
 } catch (RuntimeException e) {
 if (log.isTraceEnabled()) {
 log.trace("  -->RuntimeException Rethrown", e);
 }
 throw e;
 }
+if (clazz == null && hasExternalRepositories) {
+try {
+clazz = super.findClass(name);
+} catch (RuntimeException e) {
+if (log.isTraceEnabled()) {
+log.trace("  -->RuntimeException Rethrown", e);
+}
+throw e;
+}
+}
 }
 } catch (ClassNotFoundException e) {
 if (log.isTraceEnabled()) {
 log.trace("--> Passing on ClassNotFoundException");
 }
+notFoundClassResources.add(path);
 throw e;
 }
 if (clazz == null) {
 if (log.isTraceEnabled()) {
 log.trace("--> Returning ClassNotFoundException");
 }
+notFoundClassResources.add(path);
 throw new ClassNotFoundException(name);
 }
 
@@ -1979,11 +1989,6 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
  *
  * @return the loaded class, or null if the class isn't found
  */
-/*
- * The use of getPackage() is appropriate given that the code is checking 
if the package is sealed. Therefore,
- * parent class loaders need to be checked.
- */
-@SuppressWarnings("deprecation")
 protected Class findClassInternal(String name) {
 
 checkStateForResourceLoading(name);
@@ -1993,17 +1998,23 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
 }
 String path = binaryNameToPath(name, true);
 
+return findClassInternal(name, path);
+}
+
+
+/*
+ * The use of getPackage() is appropriate given that the code is checking 
if the package is sealed. Therefore,
+ * parent class loaders need to be checked.
+ */
+@SuppressWarnings("deprecation")
+private Class findClassInternal(String name, String path) {
 ResourceEntry entry = resourceEntries.get(path);
 WebResource resource = null;
 
 if (entry == null) {
-if (notFoundClassResources.contains(path)) {
-return null;
-}
 resource = resources.getClassLoaderResource(path);
 
 if (!resource.exists()) {
-notFoundClassResources.add(path);
 return null;
 }
 
@@ -2036,14 +2047,10 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
 }
 
 if (resource == null) {
-if (notFoundClassResources.contains(path)) {
-return null;
-}
 reso

(tomcat) 02/02: Fix BZ 69447 notFoundClassResources should allow for external resources

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

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

commit 80c37be7bb3691486b549ec832bd6da49d821dbc
Author: Mark Thomas 
AuthorDate: Wed Nov 20 20:20:59 2024 +

Fix BZ 69447 notFoundClassResources should allow for external resources
---
 .../catalina/loader/WebappClassLoaderBase.java | 53 --
 webapps/docs/changelog.xml |  6 +++
 2 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/java/org/apache/catalina/loader/WebappClassLoaderBase.java 
b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
index e954562c17..1218a1c2f8 100644
--- a/java/org/apache/catalina/loader/WebappClassLoaderBase.java
+++ b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
@@ -677,6 +677,12 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
 
 checkStateForClassLoading(name);
 
+if (name == null) {
+throw new ClassNotFoundException("null");
+}
+
+String path = binaryNameToPath(name, true);
+
 // Ask our superclass to locate this class, if possible
 // (throws ClassNotFoundException if it is not found)
 Class clazz = null;
@@ -684,34 +690,38 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
 if (log.isTraceEnabled()) {
 log.trace("  findClassInternal(" + name + ")");
 }
-try {
-clazz = findClassInternal(name);
-} catch (RuntimeException e) {
-if (log.isTraceEnabled()) {
-log.trace("  -->RuntimeException Rethrown", e);
-}
-throw e;
-}
-if (clazz == null && hasExternalRepositories) {
+if (!notFoundClassResources.contains(path)) {
 try {
-clazz = super.findClass(name);
+clazz = findClassInternal(name, path);
 } catch (RuntimeException e) {
 if (log.isTraceEnabled()) {
 log.trace("  -->RuntimeException Rethrown", e);
 }
 throw e;
 }
+if (clazz == null && hasExternalRepositories) {
+try {
+clazz = super.findClass(name);
+} catch (RuntimeException e) {
+if (log.isTraceEnabled()) {
+log.trace("  -->RuntimeException Rethrown", e);
+}
+throw e;
+}
+}
 }
 } catch (ClassNotFoundException e) {
 if (log.isTraceEnabled()) {
 log.trace("--> Passing on ClassNotFoundException");
 }
+notFoundClassResources.add(path);
 throw e;
 }
 if (clazz == null) {
 if (log.isTraceEnabled()) {
 log.trace("--> Returning ClassNotFoundException");
 }
+notFoundClassResources.add(path);
 throw new ClassNotFoundException(name);
 }
 
@@ -2024,11 +2034,6 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
  *
  * @return the loaded class, or null if the class isn't found
  */
-/*
- * The use of getPackage() is appropriate given that the code is checking 
if the package is sealed. Therefore,
- * parent class loaders need to be checked.
- */
-@SuppressWarnings("deprecation")
 protected Class findClassInternal(String name) {
 
 checkStateForResourceLoading(name);
@@ -2038,17 +2043,23 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
 }
 String path = binaryNameToPath(name, true);
 
+return findClassInternal(name, path);
+}
+
+
+/*
+ * The use of getPackage() is appropriate given that the code is checking 
if the package is sealed. Therefore,
+ * parent class loaders need to be checked.
+ */
+@SuppressWarnings("deprecation")
+private Class findClassInternal(String name, String path) {
 ResourceEntry entry = resourceEntries.get(path);
 WebResource resource = null;
 
 if (entry == null) {
-if (notFoundClassResources.contains(path)) {
-return null;
-}
 resource = resources.getClassLoaderResource(path);
 
 if (!resource.exists()) {
-notFoundClassResources.add(path);
 return null;
 }
 
@@ -2081,14 +2092,10 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
 }
 
 if (resource == null) {
-if (notFoundClassResources.contains(path)) {
-return null;
-}
 re

(tomcat) 01/02: Avoid throw - catch - re-throw for CNFE

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

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

commit 3ea629d11258f02203868b541a52c973c0090477
Author: Mark Thomas 
AuthorDate: Wed Nov 20 20:15:44 2024 +

Avoid throw - catch - re-throw for CNFE
---
 java/org/apache/catalina/loader/WebappClassLoaderBase.java | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/catalina/loader/WebappClassLoaderBase.java 
b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
index dde900f9bb..e954562c17 100644
--- a/java/org/apache/catalina/loader/WebappClassLoaderBase.java
+++ b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
@@ -702,18 +702,18 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
 throw e;
 }
 }
-if (clazz == null) {
-if (log.isTraceEnabled()) {
-log.trace("--> Returning ClassNotFoundException");
-}
-throw new ClassNotFoundException(name);
-}
 } catch (ClassNotFoundException e) {
 if (log.isTraceEnabled()) {
 log.trace("--> Passing on ClassNotFoundException");
 }
 throw e;
 }
+if (clazz == null) {
+if (log.isTraceEnabled()) {
+log.trace("--> Returning ClassNotFoundException");
+}
+throw new ClassNotFoundException(name);
+}
 
 // Return the class we have located
 if (log.isTraceEnabled()) {


-
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 (3100526319 -> 80c37be7bb)

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

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


from 3100526319 Add missing quotes for etag
 new 3ea629d112 Avoid throw - catch - re-throw for CNFE
 new 80c37be7bb Fix BZ 69447 notFoundClassResources should allow for 
external resources

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


Summary of changes:
 .../catalina/loader/WebappClassLoaderBase.java | 63 --
 webapps/docs/changelog.xml |  6 +++
 2 files changed, 41 insertions(+), 28 deletions(-)


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



(tomcat) branch main updated: Use the real strong etag support in if header test

2024-11-20 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 e9ebb248ac Use the real strong etag support in if header test
e9ebb248ac is described below

commit e9ebb248ac0127acf045e1986b44368c8b02af4a
Author: remm 
AuthorDate: Wed Nov 20 21:27:47 2024 +0100

Use the real strong etag support in if header test
---
 .../TestDefaultServletIfMatchRequests.java | 61 --
 1 file changed, 33 insertions(+), 28 deletions(-)

diff --git 
a/test/org/apache/catalina/servlets/TestDefaultServletIfMatchRequests.java 
b/test/org/apache/catalina/servlets/TestDefaultServletIfMatchRequests.java
index 0e6665e125..1df310e6b0 100644
--- a/test/org/apache/catalina/servlets/TestDefaultServletIfMatchRequests.java
+++ b/test/org/apache/catalina/servlets/TestDefaultServletIfMatchRequests.java
@@ -16,7 +16,10 @@
  */
 package org.apache.catalina.servlets;
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.FileInputStream;
+import java.security.MessageDigest;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -31,10 +34,12 @@ import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameter;
 
 import org.apache.catalina.Context;
-import org.apache.catalina.WebResource;
+import org.apache.catalina.Wrapper;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.catalina.util.IOTools;
 import org.apache.tomcat.util.buf.ByteChunk;
+import org.apache.tomcat.util.buf.HexUtils;
 
 @RunWith(Parameterized.class)
 public class TestDefaultServletIfMatchRequests extends TomcatBaseTest {
@@ -54,8 +59,13 @@ public class TestDefaultServletIfMatchRequests extends 
TomcatBaseTest {
 // Get the length of the file used for this test
 // It varies by platform due to line-endings
 File index = new File("test/webapp/index.html");
-resourceETagStrong = "\"" + index.length() + "-" + 
index.lastModified() + "\"";
-resourceETagWeak = "W/" + resourceETagStrong;
+try (FileInputStream is = new FileInputStream(index)) {
+ByteArrayOutputStream os = new ByteArrayOutputStream();
+IOTools.flow(is, os);
+resourceETagStrong = "\"" + 
HexUtils.toHexString(MessageDigest.getInstance("SHA-1").digest(os.toByteArray()))
 + "\"";
+} catch (Exception e) {
+}
+resourceETagWeak = "W/" + "\"" + index.length() + "-" + 
index.lastModified() + "\"";
 
 String otherETagStrong = "\"123456789\"";
 String otherETagWeak = "W/\"123456789\"";
@@ -90,15 +100,21 @@ public class TestDefaultServletIfMatchRequests extends 
TomcatBaseTest {
 parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagWeak, RC_412, RC_200 });
 
 // match header includes weak tag
-parameterSets.add(new Object[] { resourceWithStrongETag, 
resourceETagWeak, RC_412, RC_304 });
+String etag;
+if (resourceWithStrongETag.booleanValue()) {
+etag = "W/" + resourceETagStrong;
+} else {
+etag = resourceETagWeak;
+}
+parameterSets.add(new Object[] { resourceWithStrongETag, etag, 
RC_412, RC_304 });
 for (String concat : CONCAT) {
-parameterSets.add(new Object[] { resourceWithStrongETag, 
resourceETagWeak + concat + otherETagWeak,
+parameterSets.add(new Object[] { resourceWithStrongETag, etag 
+ concat + otherETagWeak,
 RC_412, RC_304 });
-parameterSets.add(new Object[] { resourceWithStrongETag, 
resourceETagWeak + concat + otherETagStrong,
+parameterSets.add(new Object[] { resourceWithStrongETag, etag 
+ concat + otherETagStrong,
 RC_412, RC_304 });
-parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagWeak + concat + resourceETagWeak,
+parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagWeak + concat + etag,
 RC_412, RC_304 });
-parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagStrong + concat + resourceETagWeak,
+parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagStrong + concat + etag,
 RC_412, RC_304 });
 }
 
@@ -107,18 +123,20 @@ public class TestDefaultServletIfMatchRequests extends 
TomcatBaseTest {
 Integer rcIfMatch;
 if (resourceWithStrongETag.booleanValue()) {
 rcIfMatch = RC_200;
+etag = resourceETagStrong;
 } else {
 rcIfMatch = RC_412;
+etag = resourceETagWeak.substring(2);
 }
-   

(tomcat) 01/02: Avoid throw - catch - re-throw for CNFE

2024-11-20 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 ae8381c311543098148babf20fb4c4b7cf92b433
Author: Mark Thomas 
AuthorDate: Wed Nov 20 20:15:44 2024 +

Avoid throw - catch - re-throw for CNFE
---
 java/org/apache/catalina/loader/WebappClassLoaderBase.java | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/catalina/loader/WebappClassLoaderBase.java 
b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
index fcab37c9b6..488e3c037f 100644
--- a/java/org/apache/catalina/loader/WebappClassLoaderBase.java
+++ b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
@@ -827,18 +827,18 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
 throw e;
 }
 }
-if (clazz == null) {
-if (log.isTraceEnabled()) {
-log.trace("--> Returning ClassNotFoundException");
-}
-throw new ClassNotFoundException(name);
-}
 } catch (ClassNotFoundException e) {
 if (log.isTraceEnabled()) {
 log.trace("--> Passing on ClassNotFoundException");
 }
 throw e;
 }
+if (clazz == null) {
+if (log.isTraceEnabled()) {
+log.trace("--> Returning ClassNotFoundException");
+}
+throw new ClassNotFoundException(name);
+}
 
 // Return the class we have located
 if (log.isTraceEnabled()) {


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



(tomcat) 01/02: Avoid throw - catch - re-throw for CNFE

2024-11-20 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 af77259c0acb3163cecb38afa07d99e90b1a5832
Author: Mark Thomas 
AuthorDate: Wed Nov 20 20:15:44 2024 +

Avoid throw - catch - re-throw for CNFE
---
 java/org/apache/catalina/loader/WebappClassLoaderBase.java | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/catalina/loader/WebappClassLoaderBase.java 
b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
index 8d3123dbab..3da0ab4898 100644
--- a/java/org/apache/catalina/loader/WebappClassLoaderBase.java
+++ b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
@@ -837,18 +837,18 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
 throw e;
 }
 }
-if (clazz == null) {
-if (log.isTraceEnabled()) {
-log.trace("--> Returning ClassNotFoundException");
-}
-throw new ClassNotFoundException(name);
-}
 } catch (ClassNotFoundException e) {
 if (log.isTraceEnabled()) {
 log.trace("--> Passing on ClassNotFoundException");
 }
 throw e;
 }
+if (clazz == null) {
+if (log.isTraceEnabled()) {
+log.trace("--> Returning ClassNotFoundException");
+}
+throw new ClassNotFoundException(name);
+}
 
 // Return the class we have located
 if (log.isTraceEnabled()) {


-
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 (7dcb261c80 -> 90daec2efe)

2024-11-20 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 7dcb261c80 Add missing quotes for etag
 new ae8381c311 Avoid throw - catch - re-throw for CNFE
 new 90daec2efe Fix BZ 69447 notFoundClassResources should allow for 
external resources

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


Summary of changes:
 .../catalina/loader/WebappClassLoaderBase.java | 79 --
 webapps/docs/changelog.xml |  6 ++
 2 files changed, 49 insertions(+), 36 deletions(-)


-
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: Use the real strong etag support in if header test

2024-11-20 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 62c90e9c8a Use the real strong etag support in if header test
62c90e9c8a is described below

commit 62c90e9c8a6820354e30c90a4b6e784b02569a29
Author: remm 
AuthorDate: Wed Nov 20 21:27:47 2024 +0100

Use the real strong etag support in if header test
---
 .../TestDefaultServletIfMatchRequests.java | 61 --
 1 file changed, 33 insertions(+), 28 deletions(-)

diff --git 
a/test/org/apache/catalina/servlets/TestDefaultServletIfMatchRequests.java 
b/test/org/apache/catalina/servlets/TestDefaultServletIfMatchRequests.java
index 0e6665e125..1df310e6b0 100644
--- a/test/org/apache/catalina/servlets/TestDefaultServletIfMatchRequests.java
+++ b/test/org/apache/catalina/servlets/TestDefaultServletIfMatchRequests.java
@@ -16,7 +16,10 @@
  */
 package org.apache.catalina.servlets;
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.FileInputStream;
+import java.security.MessageDigest;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -31,10 +34,12 @@ import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameter;
 
 import org.apache.catalina.Context;
-import org.apache.catalina.WebResource;
+import org.apache.catalina.Wrapper;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.catalina.util.IOTools;
 import org.apache.tomcat.util.buf.ByteChunk;
+import org.apache.tomcat.util.buf.HexUtils;
 
 @RunWith(Parameterized.class)
 public class TestDefaultServletIfMatchRequests extends TomcatBaseTest {
@@ -54,8 +59,13 @@ public class TestDefaultServletIfMatchRequests extends 
TomcatBaseTest {
 // Get the length of the file used for this test
 // It varies by platform due to line-endings
 File index = new File("test/webapp/index.html");
-resourceETagStrong = "\"" + index.length() + "-" + 
index.lastModified() + "\"";
-resourceETagWeak = "W/" + resourceETagStrong;
+try (FileInputStream is = new FileInputStream(index)) {
+ByteArrayOutputStream os = new ByteArrayOutputStream();
+IOTools.flow(is, os);
+resourceETagStrong = "\"" + 
HexUtils.toHexString(MessageDigest.getInstance("SHA-1").digest(os.toByteArray()))
 + "\"";
+} catch (Exception e) {
+}
+resourceETagWeak = "W/" + "\"" + index.length() + "-" + 
index.lastModified() + "\"";
 
 String otherETagStrong = "\"123456789\"";
 String otherETagWeak = "W/\"123456789\"";
@@ -90,15 +100,21 @@ public class TestDefaultServletIfMatchRequests extends 
TomcatBaseTest {
 parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagWeak, RC_412, RC_200 });
 
 // match header includes weak tag
-parameterSets.add(new Object[] { resourceWithStrongETag, 
resourceETagWeak, RC_412, RC_304 });
+String etag;
+if (resourceWithStrongETag.booleanValue()) {
+etag = "W/" + resourceETagStrong;
+} else {
+etag = resourceETagWeak;
+}
+parameterSets.add(new Object[] { resourceWithStrongETag, etag, 
RC_412, RC_304 });
 for (String concat : CONCAT) {
-parameterSets.add(new Object[] { resourceWithStrongETag, 
resourceETagWeak + concat + otherETagWeak,
+parameterSets.add(new Object[] { resourceWithStrongETag, etag 
+ concat + otherETagWeak,
 RC_412, RC_304 });
-parameterSets.add(new Object[] { resourceWithStrongETag, 
resourceETagWeak + concat + otherETagStrong,
+parameterSets.add(new Object[] { resourceWithStrongETag, etag 
+ concat + otherETagStrong,
 RC_412, RC_304 });
-parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagWeak + concat + resourceETagWeak,
+parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagWeak + concat + etag,
 RC_412, RC_304 });
-parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagStrong + concat + resourceETagWeak,
+parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagStrong + concat + etag,
 RC_412, RC_304 });
 }
 
@@ -107,18 +123,20 @@ public class TestDefaultServletIfMatchRequests extends 
TomcatBaseTest {
 Integer rcIfMatch;
 if (resourceWithStrongETag.booleanValue()) {
 rcIfMatch = RC_200;
+etag = resourceETagStrong;
 } else {
 rcIfMatch = RC_412;
+etag = resourceETagWeak.substring(2);
 }

(tomcat) branch 9.0.x updated (4cd94b70b3 -> fc63185a77)

2024-11-20 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 4cd94b70b3 Add missing quotes for etag
 new af77259c0a Avoid throw - catch - re-throw for CNFE
 new fc63185a77 Fix BZ 69447 notFoundClassResources should allow for 
external resources

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


Summary of changes:
 .../catalina/loader/WebappClassLoaderBase.java | 74 +-
 webapps/docs/changelog.xml |  6 ++
 2 files changed, 49 insertions(+), 31 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: Use the real strong etag support in if header test

2024-11-20 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 e48488e2e0 Use the real strong etag support in if header test
e48488e2e0 is described below

commit e48488e2e07e0a85677f76f7fc245715df0fa00b
Author: remm 
AuthorDate: Wed Nov 20 21:27:47 2024 +0100

Use the real strong etag support in if header test
---
 .../TestDefaultServletIfMatchRequests.java | 61 --
 1 file changed, 33 insertions(+), 28 deletions(-)

diff --git 
a/test/org/apache/catalina/servlets/TestDefaultServletIfMatchRequests.java 
b/test/org/apache/catalina/servlets/TestDefaultServletIfMatchRequests.java
index 0e6665e125..1df310e6b0 100644
--- a/test/org/apache/catalina/servlets/TestDefaultServletIfMatchRequests.java
+++ b/test/org/apache/catalina/servlets/TestDefaultServletIfMatchRequests.java
@@ -16,7 +16,10 @@
  */
 package org.apache.catalina.servlets;
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.FileInputStream;
+import java.security.MessageDigest;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -31,10 +34,12 @@ import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameter;
 
 import org.apache.catalina.Context;
-import org.apache.catalina.WebResource;
+import org.apache.catalina.Wrapper;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.catalina.util.IOTools;
 import org.apache.tomcat.util.buf.ByteChunk;
+import org.apache.tomcat.util.buf.HexUtils;
 
 @RunWith(Parameterized.class)
 public class TestDefaultServletIfMatchRequests extends TomcatBaseTest {
@@ -54,8 +59,13 @@ public class TestDefaultServletIfMatchRequests extends 
TomcatBaseTest {
 // Get the length of the file used for this test
 // It varies by platform due to line-endings
 File index = new File("test/webapp/index.html");
-resourceETagStrong = "\"" + index.length() + "-" + 
index.lastModified() + "\"";
-resourceETagWeak = "W/" + resourceETagStrong;
+try (FileInputStream is = new FileInputStream(index)) {
+ByteArrayOutputStream os = new ByteArrayOutputStream();
+IOTools.flow(is, os);
+resourceETagStrong = "\"" + 
HexUtils.toHexString(MessageDigest.getInstance("SHA-1").digest(os.toByteArray()))
 + "\"";
+} catch (Exception e) {
+}
+resourceETagWeak = "W/" + "\"" + index.length() + "-" + 
index.lastModified() + "\"";
 
 String otherETagStrong = "\"123456789\"";
 String otherETagWeak = "W/\"123456789\"";
@@ -90,15 +100,21 @@ public class TestDefaultServletIfMatchRequests extends 
TomcatBaseTest {
 parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagWeak, RC_412, RC_200 });
 
 // match header includes weak tag
-parameterSets.add(new Object[] { resourceWithStrongETag, 
resourceETagWeak, RC_412, RC_304 });
+String etag;
+if (resourceWithStrongETag.booleanValue()) {
+etag = "W/" + resourceETagStrong;
+} else {
+etag = resourceETagWeak;
+}
+parameterSets.add(new Object[] { resourceWithStrongETag, etag, 
RC_412, RC_304 });
 for (String concat : CONCAT) {
-parameterSets.add(new Object[] { resourceWithStrongETag, 
resourceETagWeak + concat + otherETagWeak,
+parameterSets.add(new Object[] { resourceWithStrongETag, etag 
+ concat + otherETagWeak,
 RC_412, RC_304 });
-parameterSets.add(new Object[] { resourceWithStrongETag, 
resourceETagWeak + concat + otherETagStrong,
+parameterSets.add(new Object[] { resourceWithStrongETag, etag 
+ concat + otherETagStrong,
 RC_412, RC_304 });
-parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagWeak + concat + resourceETagWeak,
+parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagWeak + concat + etag,
 RC_412, RC_304 });
-parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagStrong + concat + resourceETagWeak,
+parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagStrong + concat + etag,
 RC_412, RC_304 });
 }
 
@@ -107,18 +123,20 @@ public class TestDefaultServletIfMatchRequests extends 
TomcatBaseTest {
 Integer rcIfMatch;
 if (resourceWithStrongETag.booleanValue()) {
 rcIfMatch = RC_200;
+etag = resourceETagStrong;
 } else {
 rcIfMatch = RC_412;
+etag = resourceETagWeak.substring(2);
 }

(tomcat) 02/02: Fix BZ 69447 notFoundClassResources should allow for external resources

2024-11-20 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 fc63185a77c678b4adbb106e1302a808cc980bd3
Author: Mark Thomas 
AuthorDate: Wed Nov 20 20:20:59 2024 +

Fix BZ 69447 notFoundClassResources should allow for external resources
---
 .../catalina/loader/WebappClassLoaderBase.java | 64 +-
 webapps/docs/changelog.xml |  6 ++
 2 files changed, 44 insertions(+), 26 deletions(-)

diff --git a/java/org/apache/catalina/loader/WebappClassLoaderBase.java 
b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
index 3da0ab4898..b06fefa61b 100644
--- a/java/org/apache/catalina/loader/WebappClassLoaderBase.java
+++ b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
@@ -783,6 +783,12 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
 
 checkStateForClassLoading(name);
 
+if (name == null) {
+throw new ClassNotFoundException("null");
+}
+
+String path = binaryNameToPath(name, true);
+
 // (1) Permission to define this class when using a SecurityManager
 if (securityManager != null) {
 int i = name.lastIndexOf('.');
@@ -808,25 +814,14 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
 if (log.isTraceEnabled()) {
 log.trace("  findClassInternal(" + name + ")");
 }
-try {
-if (securityManager != null) {
-PrivilegedAction> dp = new 
PrivilegedFindClassByName(name);
-clazz = AccessController.doPrivileged(dp);
-} else {
-clazz = findClassInternal(name);
-}
-} catch (AccessControlException ace) {
-log.warn(sm.getString("webappClassLoader.securityException", 
name, ace.getMessage()), ace);
-throw new ClassNotFoundException(name, ace);
-} catch (RuntimeException e) {
-if (log.isTraceEnabled()) {
-log.trace("  -->RuntimeException Rethrown", e);
-}
-throw e;
-}
-if (clazz == null && hasExternalRepositories) {
+if (!notFoundClassResources.contains(path)) {
 try {
-clazz = super.findClass(name);
+if (securityManager != null) {
+PrivilegedAction> dp = new 
PrivilegedFindClassByName(name);
+clazz = AccessController.doPrivileged(dp);
+} else {
+clazz = findClassInternal(name);
+}
 } catch (AccessControlException ace) {
 
log.warn(sm.getString("webappClassLoader.securityException", name, 
ace.getMessage()), ace);
 throw new ClassNotFoundException(name, ace);
@@ -836,17 +831,32 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
 }
 throw e;
 }
+if (clazz == null && hasExternalRepositories) {
+try {
+clazz = super.findClass(name);
+} catch (AccessControlException ace) {
+
log.warn(sm.getString("webappClassLoader.securityException", name, 
ace.getMessage()), ace);
+throw new ClassNotFoundException(name, ace);
+} catch (RuntimeException e) {
+if (log.isTraceEnabled()) {
+log.trace("  -->RuntimeException Rethrown", e);
+}
+throw e;
+}
+}
 }
 } catch (ClassNotFoundException e) {
 if (log.isTraceEnabled()) {
 log.trace("--> Passing on ClassNotFoundException");
 }
+notFoundClassResources.add(path);
 throw e;
 }
 if (clazz == null) {
 if (log.isTraceEnabled()) {
 log.trace("--> Returning ClassNotFoundException");
 }
+notFoundClassResources.add(path);
 throw new ClassNotFoundException(name);
 }
 
@@ -2195,17 +2205,23 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
 }
 String path = binaryNameToPath(name, true);
 
+return findClassInternal(name, path);
+}
+
+
+/*
+ * The use of getPackage() is appropriate given that the code is checking 
if the package is sealed. Therefore,
+ * parent class loaders need to be checked.
+ */
+@SuppressWarnings("deprecation")
+private Class findClassInternal(String name, String path) {
 ResourceEntry entry = resourceEntries.get(path);
 WebResource reso

(tomcat) 02/02: Fix BZ 69447 notFoundClassResources should allow for external resources

2024-11-20 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 90daec2efea24d6998ac615e9b86f02457532176
Author: Mark Thomas 
AuthorDate: Wed Nov 20 20:20:59 2024 +

Fix BZ 69447 notFoundClassResources should allow for external resources
---
 .../catalina/loader/WebappClassLoaderBase.java | 69 --
 webapps/docs/changelog.xml |  6 ++
 2 files changed, 44 insertions(+), 31 deletions(-)

diff --git a/java/org/apache/catalina/loader/WebappClassLoaderBase.java 
b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
index 488e3c037f..7a8946e0a3 100644
--- a/java/org/apache/catalina/loader/WebappClassLoaderBase.java
+++ b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
@@ -773,6 +773,12 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
 
 checkStateForClassLoading(name);
 
+if (name == null) {
+throw new ClassNotFoundException("null");
+}
+
+String path = binaryNameToPath(name, true);
+
 // (1) Permission to define this class when using a SecurityManager
 if (securityManager != null) {
 int i = name.lastIndexOf('.');
@@ -798,25 +804,14 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
 if (log.isTraceEnabled()) {
 log.trace("  findClassInternal(" + name + ")");
 }
-try {
-if (securityManager != null) {
-PrivilegedAction> dp = new 
PrivilegedFindClassByName(name);
-clazz = AccessController.doPrivileged(dp);
-} else {
-clazz = findClassInternal(name);
-}
-} catch (AccessControlException ace) {
-log.warn(sm.getString("webappClassLoader.securityException", 
name, ace.getMessage()), ace);
-throw new ClassNotFoundException(name, ace);
-} catch (RuntimeException e) {
-if (log.isTraceEnabled()) {
-log.trace("  -->RuntimeException Rethrown", e);
-}
-throw e;
-}
-if (clazz == null && hasExternalRepositories) {
+if (!notFoundClassResources.contains(path)) {
 try {
-clazz = super.findClass(name);
+if (securityManager != null) {
+PrivilegedAction> dp = new 
PrivilegedFindClassByName(name);
+clazz = AccessController.doPrivileged(dp);
+} else {
+clazz = findClassInternal(name);
+}
 } catch (AccessControlException ace) {
 
log.warn(sm.getString("webappClassLoader.securityException", name, 
ace.getMessage()), ace);
 throw new ClassNotFoundException(name, ace);
@@ -826,17 +821,32 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
 }
 throw e;
 }
+if (clazz == null && hasExternalRepositories) {
+try {
+clazz = super.findClass(name);
+} catch (AccessControlException ace) {
+
log.warn(sm.getString("webappClassLoader.securityException", name, 
ace.getMessage()), ace);
+throw new ClassNotFoundException(name, ace);
+} catch (RuntimeException e) {
+if (log.isTraceEnabled()) {
+log.trace("  -->RuntimeException Rethrown", e);
+}
+throw e;
+}
+}
 }
 } catch (ClassNotFoundException e) {
 if (log.isTraceEnabled()) {
 log.trace("--> Passing on ClassNotFoundException");
 }
+notFoundClassResources.add(path);
 throw e;
 }
 if (clazz == null) {
 if (log.isTraceEnabled()) {
 log.trace("--> Returning ClassNotFoundException");
 }
+notFoundClassResources.add(path);
 throw new ClassNotFoundException(name);
 }
 
@@ -2197,11 +2207,6 @@ public abstract class WebappClassLoaderBase extends 
URLClassLoader
  *
  * @return the loaded class, or null if the class isn't found
  */
-/*
- * The use of getPackage() is appropriate given that the code is checking 
if the package is sealed. Therefore,
- * parent class loaders need to be checked.
- */
-@SuppressWarnings("deprecation")
 protected Class findClassInternal(String name) {
 
 checkStateForResourceLoading(name);
@@ -2211,17 +2216,23 @@ public abstract class WebappClassLoaderBase extends 
URLClassLo

[Bug 69447] Tomcat 9.0.97 fails to load classes due to the newly added ConcurrentLruCache

2024-11-20 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69447

Mark Thomas  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #3 from Mark Thomas  ---
Fixed in:
- 11.0.x for 11.0.2 onwards
- 10.1.x for 10.1.34 onwards
-  9.0.x for  9.0.98 onwards

-- 
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 11.0.x updated: Add simple directory listing test

2024-11-20 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 d59b9d9de4 Add simple directory listing test
d59b9d9de4 is described below

commit d59b9d9de482ed5a934257a337710ae04e2985c6
Author: remm 
AuthorDate: Wed Nov 20 21:55:30 2024 +0100

Add simple directory listing test
---
 .../catalina/servlets/TestDefaultServlet.java  | 40 ++
 1 file changed, 40 insertions(+)

diff --git a/test/org/apache/catalina/servlets/TestDefaultServlet.java 
b/test/org/apache/catalina/servlets/TestDefaultServlet.java
index 9842509782..891aabb21a 100644
--- a/test/org/apache/catalina/servlets/TestDefaultServlet.java
+++ b/test/org/apache/catalina/servlets/TestDefaultServlet.java
@@ -680,4 +680,44 @@ public class TestDefaultServlet extends TomcatBaseTest {
 Assert.assertEquals(0, out.getLength());
 Assert.assertNull(resHeaders.get("Content-Length"));
 }
+
+@Test
+public void testDirectoryListing() throws Exception {
+Tomcat tomcat = getTomcatInstance();
+
+File appDir = new File("test/webapp");
+Context ctxt = tomcat.addContext("", appDir.getAbsolutePath());
+
+Wrapper defaultServlet = Tomcat.addServlet(ctxt, "default", new 
DefaultServlet());
+defaultServlet.addInitParameter("listings", "true");
+defaultServlet.addInitParameter("sortListings", "true");
+defaultServlet.addInitParameter("sortDirectoriesFirst", "true");
+
+ctxt.addServletMappingDecoded("/", "default");
+
+tomcat.start();
+
+TestCompressedClient client = new TestCompressedClient(getPort());
+
+client.setRequest(new String[] { "GET / HTTP/1.1" + 
SimpleHttpClient.CRLF +
+"Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
+"Accept-Language: fr-FR, fr, en" + SimpleHttpClient.CRLF +
+"Connection: Close" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF });
+client.connect();
+client.processRequest(true);
+Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
+Assert.assertTrue(client.getResponseBody().contains("Taille"));
+Assert.assertTrue(client.getResponseBody().contains("bug43nnn/"));
+
+client.setRequest(new String[] { "GET /bug43nnn/ HTTP/1.1" + 
SimpleHttpClient.CRLF +
+"Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
+"Accept-Language: fr-FR, fr, en" + SimpleHttpClient.CRLF +
+"Connection: Close" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF });
+client.connect();
+client.processRequest(true);
+Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
+
+}
 }


-
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: Use the real strong etag support in if header test

2024-11-20 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 d546e1bd97 Use the real strong etag support in if header test
d546e1bd97 is described below

commit d546e1bd97331ddf12fe84356266bf3f1c0901b4
Author: remm 
AuthorDate: Wed Nov 20 21:27:47 2024 +0100

Use the real strong etag support in if header test
---
 .../TestDefaultServletIfMatchRequests.java | 61 --
 1 file changed, 33 insertions(+), 28 deletions(-)

diff --git 
a/test/org/apache/catalina/servlets/TestDefaultServletIfMatchRequests.java 
b/test/org/apache/catalina/servlets/TestDefaultServletIfMatchRequests.java
index 0e6665e125..1df310e6b0 100644
--- a/test/org/apache/catalina/servlets/TestDefaultServletIfMatchRequests.java
+++ b/test/org/apache/catalina/servlets/TestDefaultServletIfMatchRequests.java
@@ -16,7 +16,10 @@
  */
 package org.apache.catalina.servlets;
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.FileInputStream;
+import java.security.MessageDigest;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -31,10 +34,12 @@ import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameter;
 
 import org.apache.catalina.Context;
-import org.apache.catalina.WebResource;
+import org.apache.catalina.Wrapper;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.catalina.util.IOTools;
 import org.apache.tomcat.util.buf.ByteChunk;
+import org.apache.tomcat.util.buf.HexUtils;
 
 @RunWith(Parameterized.class)
 public class TestDefaultServletIfMatchRequests extends TomcatBaseTest {
@@ -54,8 +59,13 @@ public class TestDefaultServletIfMatchRequests extends 
TomcatBaseTest {
 // Get the length of the file used for this test
 // It varies by platform due to line-endings
 File index = new File("test/webapp/index.html");
-resourceETagStrong = "\"" + index.length() + "-" + 
index.lastModified() + "\"";
-resourceETagWeak = "W/" + resourceETagStrong;
+try (FileInputStream is = new FileInputStream(index)) {
+ByteArrayOutputStream os = new ByteArrayOutputStream();
+IOTools.flow(is, os);
+resourceETagStrong = "\"" + 
HexUtils.toHexString(MessageDigest.getInstance("SHA-1").digest(os.toByteArray()))
 + "\"";
+} catch (Exception e) {
+}
+resourceETagWeak = "W/" + "\"" + index.length() + "-" + 
index.lastModified() + "\"";
 
 String otherETagStrong = "\"123456789\"";
 String otherETagWeak = "W/\"123456789\"";
@@ -90,15 +100,21 @@ public class TestDefaultServletIfMatchRequests extends 
TomcatBaseTest {
 parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagWeak, RC_412, RC_200 });
 
 // match header includes weak tag
-parameterSets.add(new Object[] { resourceWithStrongETag, 
resourceETagWeak, RC_412, RC_304 });
+String etag;
+if (resourceWithStrongETag.booleanValue()) {
+etag = "W/" + resourceETagStrong;
+} else {
+etag = resourceETagWeak;
+}
+parameterSets.add(new Object[] { resourceWithStrongETag, etag, 
RC_412, RC_304 });
 for (String concat : CONCAT) {
-parameterSets.add(new Object[] { resourceWithStrongETag, 
resourceETagWeak + concat + otherETagWeak,
+parameterSets.add(new Object[] { resourceWithStrongETag, etag 
+ concat + otherETagWeak,
 RC_412, RC_304 });
-parameterSets.add(new Object[] { resourceWithStrongETag, 
resourceETagWeak + concat + otherETagStrong,
+parameterSets.add(new Object[] { resourceWithStrongETag, etag 
+ concat + otherETagStrong,
 RC_412, RC_304 });
-parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagWeak + concat + resourceETagWeak,
+parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagWeak + concat + etag,
 RC_412, RC_304 });
-parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagStrong + concat + resourceETagWeak,
+parameterSets.add(new Object[] { resourceWithStrongETag, 
otherETagStrong + concat + etag,
 RC_412, RC_304 });
 }
 
@@ -107,18 +123,20 @@ public class TestDefaultServletIfMatchRequests extends 
TomcatBaseTest {
 Integer rcIfMatch;
 if (resourceWithStrongETag.booleanValue()) {
 rcIfMatch = RC_200;
+etag = resourceETagStrong;
 } else {
 rcIfMatch = RC_412;
+etag = resourceETagWeak.substring(2);
 }
- 

(tomcat) branch main updated: Add simple directory listing test

2024-11-20 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 de0cc4cf36 Add simple directory listing test
de0cc4cf36 is described below

commit de0cc4cf36fbb1b7a1a8a51aa1ca41d69642c78d
Author: remm 
AuthorDate: Wed Nov 20 21:55:30 2024 +0100

Add simple directory listing test
---
 .../catalina/servlets/TestDefaultServlet.java  | 40 ++
 1 file changed, 40 insertions(+)

diff --git a/test/org/apache/catalina/servlets/TestDefaultServlet.java 
b/test/org/apache/catalina/servlets/TestDefaultServlet.java
index 9842509782..891aabb21a 100644
--- a/test/org/apache/catalina/servlets/TestDefaultServlet.java
+++ b/test/org/apache/catalina/servlets/TestDefaultServlet.java
@@ -680,4 +680,44 @@ public class TestDefaultServlet extends TomcatBaseTest {
 Assert.assertEquals(0, out.getLength());
 Assert.assertNull(resHeaders.get("Content-Length"));
 }
+
+@Test
+public void testDirectoryListing() throws Exception {
+Tomcat tomcat = getTomcatInstance();
+
+File appDir = new File("test/webapp");
+Context ctxt = tomcat.addContext("", appDir.getAbsolutePath());
+
+Wrapper defaultServlet = Tomcat.addServlet(ctxt, "default", new 
DefaultServlet());
+defaultServlet.addInitParameter("listings", "true");
+defaultServlet.addInitParameter("sortListings", "true");
+defaultServlet.addInitParameter("sortDirectoriesFirst", "true");
+
+ctxt.addServletMappingDecoded("/", "default");
+
+tomcat.start();
+
+TestCompressedClient client = new TestCompressedClient(getPort());
+
+client.setRequest(new String[] { "GET / HTTP/1.1" + 
SimpleHttpClient.CRLF +
+"Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
+"Accept-Language: fr-FR, fr, en" + SimpleHttpClient.CRLF +
+"Connection: Close" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF });
+client.connect();
+client.processRequest(true);
+Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
+Assert.assertTrue(client.getResponseBody().contains("Taille"));
+Assert.assertTrue(client.getResponseBody().contains("bug43nnn/"));
+
+client.setRequest(new String[] { "GET /bug43nnn/ HTTP/1.1" + 
SimpleHttpClient.CRLF +
+"Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
+"Accept-Language: fr-FR, fr, en" + SimpleHttpClient.CRLF +
+"Connection: Close" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF });
+client.connect();
+client.processRequest(true);
+Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
+
+}
 }


-
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: Add simple directory listing test

2024-11-20 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 93aa57809f Add simple directory listing test
93aa57809f is described below

commit 93aa57809f601400a7b8620e224e8e435ae94a6b
Author: remm 
AuthorDate: Wed Nov 20 21:55:30 2024 +0100

Add simple directory listing test
---
 .../catalina/servlets/TestDefaultServlet.java  | 40 ++
 1 file changed, 40 insertions(+)

diff --git a/test/org/apache/catalina/servlets/TestDefaultServlet.java 
b/test/org/apache/catalina/servlets/TestDefaultServlet.java
index 889f7909c6..ca64ab1d62 100644
--- a/test/org/apache/catalina/servlets/TestDefaultServlet.java
+++ b/test/org/apache/catalina/servlets/TestDefaultServlet.java
@@ -679,4 +679,44 @@ public class TestDefaultServlet extends TomcatBaseTest {
 Assert.assertEquals(0, out.getLength());
 Assert.assertEquals(length, resHeaders.get("Content-Length").get(0));
 }
+
+@Test
+public void testDirectoryListing() throws Exception {
+Tomcat tomcat = getTomcatInstance();
+
+File appDir = new File("test/webapp");
+Context ctxt = tomcat.addContext("", appDir.getAbsolutePath());
+
+Wrapper defaultServlet = Tomcat.addServlet(ctxt, "default", new 
DefaultServlet());
+defaultServlet.addInitParameter("listings", "true");
+defaultServlet.addInitParameter("sortListings", "true");
+defaultServlet.addInitParameter("sortDirectoriesFirst", "true");
+
+ctxt.addServletMappingDecoded("/", "default");
+
+tomcat.start();
+
+TestCompressedClient client = new TestCompressedClient(getPort());
+
+client.setRequest(new String[] { "GET / HTTP/1.1" + 
SimpleHttpClient.CRLF +
+"Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
+"Accept-Language: fr-FR, fr, en" + SimpleHttpClient.CRLF +
+"Connection: Close" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF });
+client.connect();
+client.processRequest(true);
+Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
+Assert.assertTrue(client.getResponseBody().contains("Taille"));
+Assert.assertTrue(client.getResponseBody().contains("bug43nnn/"));
+
+client.setRequest(new String[] { "GET /bug43nnn/ HTTP/1.1" + 
SimpleHttpClient.CRLF +
+"Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
+"Accept-Language: fr-FR, fr, en" + SimpleHttpClient.CRLF +
+"Connection: Close" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF });
+client.connect();
+client.processRequest(true);
+Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
+
+}
 }


-
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 simple directory listing test

2024-11-20 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 6874c9fbd0 Add simple directory listing test
6874c9fbd0 is described below

commit 6874c9fbd048cb6fa2c3bcdd36b83b38cb0d6e72
Author: remm 
AuthorDate: Wed Nov 20 21:55:30 2024 +0100

Add simple directory listing test
---
 .../catalina/servlets/TestDefaultServlet.java  | 40 ++
 1 file changed, 40 insertions(+)

diff --git a/test/org/apache/catalina/servlets/TestDefaultServlet.java 
b/test/org/apache/catalina/servlets/TestDefaultServlet.java
index c8321cee25..4bde3703ce 100644
--- a/test/org/apache/catalina/servlets/TestDefaultServlet.java
+++ b/test/org/apache/catalina/servlets/TestDefaultServlet.java
@@ -671,4 +671,44 @@ public class TestDefaultServlet extends TomcatBaseTest {
 int rc = getUrl(path, out, resHeaders);
 Assert.assertEquals(HttpServletResponse.SC_OK, rc);
 }
+
+@Test
+public void testDirectoryListing() throws Exception {
+Tomcat tomcat = getTomcatInstance();
+
+File appDir = new File("test/webapp");
+Context ctxt = tomcat.addContext("", appDir.getAbsolutePath());
+
+Wrapper defaultServlet = Tomcat.addServlet(ctxt, "default", new 
DefaultServlet());
+defaultServlet.addInitParameter("listings", "true");
+defaultServlet.addInitParameter("sortListings", "true");
+defaultServlet.addInitParameter("sortDirectoriesFirst", "true");
+
+ctxt.addServletMappingDecoded("/", "default");
+
+tomcat.start();
+
+TestCompressedClient client = new TestCompressedClient(getPort());
+
+client.setRequest(new String[] { "GET / HTTP/1.1" + 
SimpleHttpClient.CRLF +
+"Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
+"Accept-Language: fr-FR, fr, en" + SimpleHttpClient.CRLF +
+"Connection: Close" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF });
+client.connect();
+client.processRequest(true);
+Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
+Assert.assertTrue(client.getResponseBody().contains("Taille"));
+Assert.assertTrue(client.getResponseBody().contains("bug43nnn/"));
+
+client.setRequest(new String[] { "GET /bug43nnn/ HTTP/1.1" + 
SimpleHttpClient.CRLF +
+"Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
+"Accept-Language: fr-FR, fr, en" + SimpleHttpClient.CRLF +
+"Connection: Close" + SimpleHttpClient.CRLF +
+SimpleHttpClient.CRLF });
+client.connect();
+client.processRequest(true);
+Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
+
+}
 }


-
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: Use client locale for directory listings

2024-11-20 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 c600f62e1d Use client locale for directory listings
c600f62e1d is described below

commit c600f62e1d0202ca2313b9605e92d08620a38e8e
Author: remm 
AuthorDate: Wed Nov 20 16:20:14 2024 +0100

Use client locale for directory listings
---
 java/org/apache/catalina/servlets/DefaultServlet.java | 9 -
 webapps/docs/changelog.xml| 3 +++
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/catalina/servlets/DefaultServlet.java 
b/java/org/apache/catalina/servlets/DefaultServlet.java
index 1620da8104..2b9c6619cc 100644
--- a/java/org/apache/catalina/servlets/DefaultServlet.java
+++ b/java/org/apache/catalina/servlets/DefaultServlet.java
@@ -1687,6 +1687,9 @@ public class DefaultServlet extends HttpServlet {
 
 StringBuilder sb = new StringBuilder();
 
+// Get the right strings
+StringManager sm = 
StringManager.getManager(DefaultServlet.class.getPackageName(), 
request.getLocales());
+
 String directoryWebappPath = resource.getWebappPath();
 WebResource[] entries = resources.listResources(directoryWebappPath);
 
@@ -1695,11 +1698,7 @@ public class DefaultServlet extends HttpServlet {
 
 // Render the page header
 sb.append("\r\n");
-sb.append("\r\n");
-/*
- * TODO Activate this as soon as we use smClient with the request 
locales
- * sb.append("\r\n");
- */
+sb.append("\r\n");
 sb.append("\r\n");
 sb.append("");
 sb.append(sm.getString("defaultServlet.directory.title", 
directoryWebappPath));
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 1cfcfb6cd8..30124ef5b3 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -151,6 +151,9 @@
 a value set to true. The ETag generated will be a SHA-1
 checksum of the resource content. (remm)
   
+  
+Use client locale for directory listings. (remm)
+  
 
   
   


-
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: Use client locale for directory listings

2024-11-20 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 d95562f482 Use client locale for directory listings
d95562f482 is described below

commit d95562f482bcbb1d8c5d332f9aad8198b20ffe64
Author: remm 
AuthorDate: Wed Nov 20 16:20:14 2024 +0100

Use client locale for directory listings
---
 java/org/apache/catalina/servlets/DefaultServlet.java | 9 -
 webapps/docs/changelog.xml| 3 +++
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/catalina/servlets/DefaultServlet.java 
b/java/org/apache/catalina/servlets/DefaultServlet.java
index cd2a93b7e0..8b65544c90 100644
--- a/java/org/apache/catalina/servlets/DefaultServlet.java
+++ b/java/org/apache/catalina/servlets/DefaultServlet.java
@@ -1747,6 +1747,9 @@ public class DefaultServlet extends HttpServlet {
 
 StringBuilder sb = new StringBuilder();
 
+// Get the right strings
+StringManager sm = 
StringManager.getManager(DefaultServlet.class.getPackageName(), 
request.getLocales());
+
 String directoryWebappPath = resource.getWebappPath();
 WebResource[] entries = resources.listResources(directoryWebappPath);
 
@@ -1755,11 +1758,7 @@ public class DefaultServlet extends HttpServlet {
 
 // Render the page header
 sb.append("\r\n");
-sb.append("\r\n");
-/*
- * TODO Activate this as soon as we use smClient with the request 
locales
- * sb.append("\r\n");
- */
+sb.append("\r\n");
 sb.append("\r\n");
 sb.append("");
 sb.append(sm.getString("defaultServlet.directory.title", 
directoryWebappPath));
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 9a0783b2b7..407315bce8 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -147,6 +147,9 @@
 a value set to true. The ETag generated will be a SHA-1
 checksum of the resource content. (remm)
   
+  
+Use client locale for directory listings. (remm)
+  
 
   
   


-
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: Use client locale for directory listings

2024-11-20 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 7096cbc6a6 Use client locale for directory listings
7096cbc6a6 is described below

commit 7096cbc6a69c774611797d5895be844af18d9d85
Author: remm 
AuthorDate: Wed Nov 20 16:20:14 2024 +0100

Use client locale for directory listings
---
 java/org/apache/catalina/servlets/DefaultServlet.java | 9 -
 webapps/docs/changelog.xml| 3 +++
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/catalina/servlets/DefaultServlet.java 
b/java/org/apache/catalina/servlets/DefaultServlet.java
index c5e4c5a2c8..6a4826e7e5 100644
--- a/java/org/apache/catalina/servlets/DefaultServlet.java
+++ b/java/org/apache/catalina/servlets/DefaultServlet.java
@@ -1661,6 +1661,9 @@ public class DefaultServlet extends HttpServlet {
 
 StringBuilder sb = new StringBuilder();
 
+// Get the right strings
+StringManager sm = 
StringManager.getManager(DefaultServlet.class.getPackageName(), 
request.getLocales());
+
 String directoryWebappPath = resource.getWebappPath();
 WebResource[] entries = resources.listResources(directoryWebappPath);
 
@@ -1669,11 +1672,7 @@ public class DefaultServlet extends HttpServlet {
 
 // Render the page header
 sb.append("\r\n");
-sb.append("\r\n");
-/*
- * TODO Activate this as soon as we use smClient with the request 
locales
- * sb.append("\r\n");
- */
+sb.append("\r\n");
 sb.append("\r\n");
 sb.append("");
 sb.append(sm.getString("defaultServlet.directory.title", 
directoryWebappPath));
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 0a45429dc1..4cfede5059 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -151,6 +151,9 @@
 a value set to true. The ETag generated will be a SHA-1
 checksum of the resource content. (remm)
   
+  
+Use client locale for directory listings. (remm)
+  
 
   
   


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



(tomcat) branch main updated: Use client locale for directory listings

2024-11-20 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 dad524b041 Use client locale for directory listings
dad524b041 is described below

commit dad524b04140693eff0bdb585794a8002790ad82
Author: remm 
AuthorDate: Wed Nov 20 16:20:14 2024 +0100

Use client locale for directory listings
---
 java/org/apache/catalina/servlets/DefaultServlet.java | 9 -
 webapps/docs/changelog.xml| 3 +++
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/catalina/servlets/DefaultServlet.java 
b/java/org/apache/catalina/servlets/DefaultServlet.java
index c5e4c5a2c8..6a4826e7e5 100644
--- a/java/org/apache/catalina/servlets/DefaultServlet.java
+++ b/java/org/apache/catalina/servlets/DefaultServlet.java
@@ -1661,6 +1661,9 @@ public class DefaultServlet extends HttpServlet {
 
 StringBuilder sb = new StringBuilder();
 
+// Get the right strings
+StringManager sm = 
StringManager.getManager(DefaultServlet.class.getPackageName(), 
request.getLocales());
+
 String directoryWebappPath = resource.getWebappPath();
 WebResource[] entries = resources.listResources(directoryWebappPath);
 
@@ -1669,11 +1672,7 @@ public class DefaultServlet extends HttpServlet {
 
 // Render the page header
 sb.append("\r\n");
-sb.append("\r\n");
-/*
- * TODO Activate this as soon as we use smClient with the request 
locales
- * sb.append("\r\n");
- */
+sb.append("\r\n");
 sb.append("\r\n");
 sb.append("");
 sb.append(sm.getString("defaultServlet.directory.title", 
directoryWebappPath));
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index ebdf0f6a2d..b038d790b9 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -159,6 +159,9 @@
 a value set to true. The ETag generated will be a SHA-1
 checksum of the resource content. (remm)
   
+  
+Use client locale for directory listings. (remm)
+  
 
   
   


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



(tomcat) branch 9.0.x updated: Fix IDE warning

2024-11-20 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 5109a6daa7 Fix IDE warning
5109a6daa7 is described below

commit 5109a6daa714420747cfc2bb4ad30325c03cc449
Author: Mark Thomas 
AuthorDate: Wed Nov 20 17:27:37 2024 +

Fix IDE warning
---
 java/org/apache/catalina/manager/StatusTransformer.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/manager/StatusTransformer.java 
b/java/org/apache/catalina/manager/StatusTransformer.java
index 6dbae88453..0d759f0d6d 100644
--- a/java/org/apache/catalina/manager/StatusTransformer.java
+++ b/java/org/apache/catalina/manager/StatusTransformer.java
@@ -902,7 +902,7 @@ public class StatusTransformer {
 indent(writer, 2).append('{').println();
 appendJSonValue(indent(writer, 3), "name", 
JSONFilter.escape(JSONFilter.escape(name))).append(',');
 appendJSonValue(writer, "startTime",
-new Date(((Long) mBeanServer.getAttribute(objectName, 
"startTime"))).toString())
+new Date(((Long) mBeanServer.getAttribute(objectName, 
"startTime")).longValue()).toString())
 .append(',');
 appendJSonValue(writer, "startupTime", 
mBeanServer.getAttribute(objectName, "startupTime"))
 .append(',');


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



(tomcat) branch 9.0.x updated: Fix potential NPE

2024-11-20 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 2297c68d46 Fix potential NPE
2297c68d46 is described below

commit 2297c68d46ec907b3d74ca023ee6dffa4ee52406
Author: Mark Thomas 
AuthorDate: Wed Nov 20 17:38:54 2024 +

Fix potential NPE
---
 java/org/apache/catalina/servlets/DefaultServlet.java | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/servlets/DefaultServlet.java 
b/java/org/apache/catalina/servlets/DefaultServlet.java
index 28d54bab07..7d90a48ca7 100644
--- a/java/org/apache/catalina/servlets/DefaultServlet.java
+++ b/java/org/apache/catalina/servlets/DefaultServlet.java
@@ -1747,8 +1747,13 @@ public class DefaultServlet extends HttpServlet {
 
 StringBuilder sb = new StringBuilder();
 
-// Get the right strings
-StringManager sm = 
StringManager.getManager(DefaultServlet.class.getPackage().getName(), 
request.getLocales());
+// Get the right strings if request is available
+StringManager sm;
+if (request == null) {
+sm = DefaultServlet.sm;
+} else {
+sm = 
StringManager.getManager(DefaultServlet.class.getPackage().getName(), 
request.getLocales());
+}
 
 String directoryWebappPath = resource.getWebappPath();
 WebResource[] entries = resources.listResources(directoryWebappPath);


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



(tomcat) 02/02: Remove unnecessary code

2024-11-20 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 ce525420efec01e6df2358d215617aa674cd2d52
Author: Mark Thomas 
AuthorDate: Wed Nov 20 17:31:19 2024 +

Remove unnecessary code
---
 java/org/apache/catalina/servlets/DefaultServlet.java | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/catalina/servlets/DefaultServlet.java 
b/java/org/apache/catalina/servlets/DefaultServlet.java
index 2b9c6619cc..dba91ad1b4 100644
--- a/java/org/apache/catalina/servlets/DefaultServlet.java
+++ b/java/org/apache/catalina/servlets/DefaultServlet.java
@@ -1741,7 +1741,7 @@ public class DefaultServlet extends HttpServlet {
 sb.append("\r\n");
 
 SortManager.Order order;
-if (sortListings && null != request) {
+if (sortListings) {
 order = sortManager.getOrder(request.getQueryString());
 } else {
 order = null;
@@ -1750,7 +1750,7 @@ public class DefaultServlet extends HttpServlet {
 sb.append("\r\n");
 sb.append("\r\n");
 sb.append("");
-if (sortListings && null != request) {
+if (sortListings) {
 sb.append("");
@@ -1761,7 +1761,7 @@ public class DefaultServlet extends HttpServlet {
 }
 sb.append("\r\n");
 sb.append("");
-if (sortListings && null != request) {
+if (sortListings) {
 sb.append("");
@@ -1772,7 +1772,7 @@ public class DefaultServlet extends HttpServlet {
 }
 sb.append("\r\n");
 sb.append("");
-if (sortListings && null != request) {
+if (sortListings) {
 sb.append("");
@@ -1785,7 +1785,7 @@ public class DefaultServlet extends HttpServlet {
 sb.append("\r\n");
 sb.append("\r\n");
 
-if (null != sortManager && null != request) {
+if (null != sortManager) {
 sortManager.sort(entries, request.getQueryString());
 }
 


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



(tomcat) 01/02: Fix IDE warning

2024-11-20 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 0616196b201fc08869aebcbb6cbe6840d3973764
Author: Mark Thomas 
AuthorDate: Wed Nov 20 17:27:37 2024 +

Fix IDE warning
---
 java/org/apache/catalina/manager/StatusTransformer.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/manager/StatusTransformer.java 
b/java/org/apache/catalina/manager/StatusTransformer.java
index b5a1d2963f..903d880347 100644
--- a/java/org/apache/catalina/manager/StatusTransformer.java
+++ b/java/org/apache/catalina/manager/StatusTransformer.java
@@ -836,7 +836,7 @@ public class StatusTransformer {
 indent(writer, 2).append('{').println();
 appendJSonValue(indent(writer, 3), "name", 
JSONFilter.escape(JSONFilter.escape(name))).append(',');
 appendJSonValue(writer, "startTime",
-new Date(((Long) mBeanServer.getAttribute(objectName, 
"startTime"))).toString())
+new Date(((Long) mBeanServer.getAttribute(objectName, 
"startTime")).longValue()).toString())
 .append(',');
 appendJSonValue(writer, "startupTime", 
mBeanServer.getAttribute(objectName, "startupTime"))
 .append(',');


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



(tomcat) branch main updated: Add missing quotes for etag

2024-11-20 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 5b9d92c721 Add missing quotes for etag
5b9d92c721 is described below

commit 5b9d92c7213f215a7da8a85b181998684624d07b
Author: remm 
AuthorDate: Wed Nov 20 20:51:12 2024 +0100

Add missing quotes for etag
---
 java/org/apache/catalina/webresources/AbstractResource.java | 4 ++--
 java/org/apache/catalina/webresources/CachedResource.java   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/webresources/AbstractResource.java 
b/java/org/apache/catalina/webresources/AbstractResource.java
index fccc3fb2e2..a606ca64b1 100644
--- a/java/org/apache/catalina/webresources/AbstractResource.java
+++ b/java/org/apache/catalina/webresources/AbstractResource.java
@@ -91,7 +91,7 @@ public abstract class AbstractResource implements WebResource 
{
 byte[] buf = getContent();
 if (buf != null) {
 buf = ConcurrentMessageDigest.digest("SHA-1", 
buf);
-strongETag = HexUtils.toHexString(buf);
+strongETag = "\"" + HexUtils.toHexString(buf) 
+ "\"";
 } else {
 strongETag = getETag();
 }
@@ -106,7 +106,7 @@ public abstract class AbstractResource implements 
WebResource {
 }
 digest.update(buf, 0, n);
 }
-strongETag = 
HexUtils.toHexString(digest.digest());
+strongETag = "\"" + 
HexUtils.toHexString(digest.digest()) + "\"";
 } catch (Exception e) {
 strongETag = getETag();
 }
diff --git a/java/org/apache/catalina/webresources/CachedResource.java 
b/java/org/apache/catalina/webresources/CachedResource.java
index 5c25c1fb81..31c13ba7a1 100644
--- a/java/org/apache/catalina/webresources/CachedResource.java
+++ b/java/org/apache/catalina/webresources/CachedResource.java
@@ -300,7 +300,7 @@ public class CachedResource implements WebResource {
 byte[] buf = getContent();
 if (buf != null) {
 buf = ConcurrentMessageDigest.digest("SHA-1", buf);
-cachedStrongETag = HexUtils.toHexString(buf);
+cachedStrongETag = "\"" + HexUtils.toHexString(buf) + "\"";
 } else {
 cachedStrongETag = webResource.getStrongETag();
 }


-
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: Add missing quotes for etag

2024-11-20 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 3100526319 Add missing quotes for etag
3100526319 is described below

commit 3100526319976d2ddaece61a8dd1f2855c792a53
Author: remm 
AuthorDate: Wed Nov 20 20:51:12 2024 +0100

Add missing quotes for etag
---
 java/org/apache/catalina/webresources/AbstractResource.java | 4 ++--
 java/org/apache/catalina/webresources/CachedResource.java   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/webresources/AbstractResource.java 
b/java/org/apache/catalina/webresources/AbstractResource.java
index fccc3fb2e2..a606ca64b1 100644
--- a/java/org/apache/catalina/webresources/AbstractResource.java
+++ b/java/org/apache/catalina/webresources/AbstractResource.java
@@ -91,7 +91,7 @@ public abstract class AbstractResource implements WebResource 
{
 byte[] buf = getContent();
 if (buf != null) {
 buf = ConcurrentMessageDigest.digest("SHA-1", 
buf);
-strongETag = HexUtils.toHexString(buf);
+strongETag = "\"" + HexUtils.toHexString(buf) 
+ "\"";
 } else {
 strongETag = getETag();
 }
@@ -106,7 +106,7 @@ public abstract class AbstractResource implements 
WebResource {
 }
 digest.update(buf, 0, n);
 }
-strongETag = 
HexUtils.toHexString(digest.digest());
+strongETag = "\"" + 
HexUtils.toHexString(digest.digest()) + "\"";
 } catch (Exception e) {
 strongETag = getETag();
 }
diff --git a/java/org/apache/catalina/webresources/CachedResource.java 
b/java/org/apache/catalina/webresources/CachedResource.java
index 5c25c1fb81..31c13ba7a1 100644
--- a/java/org/apache/catalina/webresources/CachedResource.java
+++ b/java/org/apache/catalina/webresources/CachedResource.java
@@ -300,7 +300,7 @@ public class CachedResource implements WebResource {
 byte[] buf = getContent();
 if (buf != null) {
 buf = ConcurrentMessageDigest.digest("SHA-1", buf);
-cachedStrongETag = HexUtils.toHexString(buf);
+cachedStrongETag = "\"" + HexUtils.toHexString(buf) + "\"";
 } else {
 cachedStrongETag = webResource.getStrongETag();
 }


-
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 missing quotes for etag

2024-11-20 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 7dcb261c80 Add missing quotes for etag
7dcb261c80 is described below

commit 7dcb261c800a6cdb072d4030c9bd0ea47d3aba50
Author: remm 
AuthorDate: Wed Nov 20 20:51:12 2024 +0100

Add missing quotes for etag
---
 java/org/apache/catalina/webresources/AbstractResource.java | 4 ++--
 java/org/apache/catalina/webresources/CachedResource.java   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/webresources/AbstractResource.java 
b/java/org/apache/catalina/webresources/AbstractResource.java
index fccc3fb2e2..a606ca64b1 100644
--- a/java/org/apache/catalina/webresources/AbstractResource.java
+++ b/java/org/apache/catalina/webresources/AbstractResource.java
@@ -91,7 +91,7 @@ public abstract class AbstractResource implements WebResource 
{
 byte[] buf = getContent();
 if (buf != null) {
 buf = ConcurrentMessageDigest.digest("SHA-1", 
buf);
-strongETag = HexUtils.toHexString(buf);
+strongETag = "\"" + HexUtils.toHexString(buf) 
+ "\"";
 } else {
 strongETag = getETag();
 }
@@ -106,7 +106,7 @@ public abstract class AbstractResource implements 
WebResource {
 }
 digest.update(buf, 0, n);
 }
-strongETag = 
HexUtils.toHexString(digest.digest());
+strongETag = "\"" + 
HexUtils.toHexString(digest.digest()) + "\"";
 } catch (Exception e) {
 strongETag = getETag();
 }
diff --git a/java/org/apache/catalina/webresources/CachedResource.java 
b/java/org/apache/catalina/webresources/CachedResource.java
index 83510f9d98..40fb323224 100644
--- a/java/org/apache/catalina/webresources/CachedResource.java
+++ b/java/org/apache/catalina/webresources/CachedResource.java
@@ -300,7 +300,7 @@ public class CachedResource implements WebResource {
 byte[] buf = getContent();
 if (buf != null) {
 buf = ConcurrentMessageDigest.digest("SHA-1", buf);
-cachedStrongETag = HexUtils.toHexString(buf);
+cachedStrongETag = "\"" + HexUtils.toHexString(buf) + "\"";
 } else {
 cachedStrongETag = webResource.getStrongETag();
 }


-
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: Add missing quotes for etag

2024-11-20 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 4cd94b70b3 Add missing quotes for etag
4cd94b70b3 is described below

commit 4cd94b70b30044d6d49ee18442db62fdd032455e
Author: remm 
AuthorDate: Wed Nov 20 20:51:12 2024 +0100

Add missing quotes for etag
---
 java/org/apache/catalina/webresources/AbstractResource.java | 4 ++--
 java/org/apache/catalina/webresources/CachedResource.java   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/webresources/AbstractResource.java 
b/java/org/apache/catalina/webresources/AbstractResource.java
index fccc3fb2e2..a606ca64b1 100644
--- a/java/org/apache/catalina/webresources/AbstractResource.java
+++ b/java/org/apache/catalina/webresources/AbstractResource.java
@@ -91,7 +91,7 @@ public abstract class AbstractResource implements WebResource 
{
 byte[] buf = getContent();
 if (buf != null) {
 buf = ConcurrentMessageDigest.digest("SHA-1", 
buf);
-strongETag = HexUtils.toHexString(buf);
+strongETag = "\"" + HexUtils.toHexString(buf) 
+ "\"";
 } else {
 strongETag = getETag();
 }
@@ -106,7 +106,7 @@ public abstract class AbstractResource implements 
WebResource {
 }
 digest.update(buf, 0, n);
 }
-strongETag = 
HexUtils.toHexString(digest.digest());
+strongETag = "\"" + 
HexUtils.toHexString(digest.digest()) + "\"";
 } catch (Exception e) {
 strongETag = getETag();
 }
diff --git a/java/org/apache/catalina/webresources/CachedResource.java 
b/java/org/apache/catalina/webresources/CachedResource.java
index 83510f9d98..40fb323224 100644
--- a/java/org/apache/catalina/webresources/CachedResource.java
+++ b/java/org/apache/catalina/webresources/CachedResource.java
@@ -300,7 +300,7 @@ public class CachedResource implements WebResource {
 byte[] buf = getContent();
 if (buf != null) {
 buf = ConcurrentMessageDigest.digest("SHA-1", buf);
-cachedStrongETag = HexUtils.toHexString(buf);
+cachedStrongETag = "\"" + HexUtils.toHexString(buf) + "\"";
 } else {
 cachedStrongETag = webResource.getStrongETag();
 }


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



[Bug 69447] Tomcat 9.0.97 fails to load classes due to the newly added ConcurrentLruCache

2024-11-20 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69447

--- Comment #2 from Mark Thomas  ---
You can work around this by setting notFoundClassResourceCacheSize="0" on the
Context.

-- 
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: Fix BZ 69439 - Improve handling of multiple Cache-Control headers

2024-11-20 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 3963ff12f3 Fix BZ 69439 - Improve handling of multiple Cache-Control 
headers
3963ff12f3 is described below

commit 3963ff12f31e4beb03d51f76718a0c0bc77b0dc1
Author: Mark Thomas 
AuthorDate: Wed Nov 20 19:17:10 2024 +

Fix BZ 69439 - Improve handling of multiple Cache-Control headers

Based on #777 by Chenjp
---
 .../org/apache/catalina/filters/ExpiresFilter.java |  20 ++--
 .../apache/catalina/filters/TestExpiresFilter.java | 127 +
 webapps/docs/changelog.xml |   5 +
 3 files changed, 122 insertions(+), 30 deletions(-)

diff --git a/java/org/apache/catalina/filters/ExpiresFilter.java 
b/java/org/apache/catalina/filters/ExpiresFilter.java
index f3bde19d0e..be38e58dd7 100644
--- a/java/org/apache/catalina/filters/ExpiresFilter.java
+++ b/java/org/apache/catalina/filters/ExpiresFilter.java
@@ -165,10 +165,10 @@ import org.apache.tomcat.util.buf.StringUtils;
  * 
  * {@code ExpiresExcludedResponseStatusCodes}
  * 
- * This directive defines the http response status codes for which the
+ * This directive defines the HTTP response status codes for which the
  * {@code ExpiresFilter} will not generate expiration headers. By default, the
  * {@code 304} status code ("{@code Not modified}") is skipped. The
- * value is a comma separated list of http status codes.
+ * value is a comma separated list of HTTP status codes.
  * 
  * 
  * This directive is useful to ease usage of {@code ExpiresDefault} directive.
@@ -332,7 +332,7 @@ import org.apache.tomcat.util.buf.StringUtils;
  * 
  * 
  * To trap the 'before write response body' event, the
- * {@code ExpiresFilter} wraps the http servlet response's writer and
+ * {@code ExpiresFilter} wraps the HTTP servlet response's writer and
  * outputStream to intercept calls to the methods {@code write()},
  * {@code print()}, {@code close()} and {@code flush()}. For empty response
  * body (e.g. empty files), the {@code write()}, {@code print()},
@@ -517,7 +517,7 @@ public class ExpiresFilter extends FilterBase {
 
 /**
  * 
- * Wrapping extension of the {@link HttpServletResponse} to yrap the 
"Start Write Response Body" event.
+ * Wrapping extension of the {@link HttpServletResponse} to wrap the 
"Start Write Response Body" event.
  * 
  * 
  * For performance optimization : this extended response holds the {@link 
#lastModifiedHeader} and
@@ -528,12 +528,12 @@ public class ExpiresFilter extends FilterBase {
 public class XHttpServletResponse extends HttpServletResponseWrapper {
 
 /**
- * Value of the {@code Cache-Control} http response header if it has 
been set.
+ * Value of the {@code Cache-Control} HTTP response header if it has 
been set.
  */
 private String cacheControlHeader;
 
 /**
- * Value of the {@code Last-Modified} http response header if it has 
been set.
+ * Value of the {@code Last-Modified} HTTP response header if it has 
been set.
  */
 private long lastModifiedHeader;
 
@@ -568,8 +568,12 @@ public class ExpiresFilter extends FilterBase {
 @Override
 public void addHeader(String name, String value) {
 super.addHeader(name, value);
-if (HEADER_CACHE_CONTROL.equalsIgnoreCase(name) && 
cacheControlHeader == null) {
-cacheControlHeader = value;
+if (HEADER_CACHE_CONTROL.equalsIgnoreCase(name)) {
+if (cacheControlHeader == null) {
+cacheControlHeader = value;
+} else {
+cacheControlHeader = StringUtils.join(cacheControlHeader, 
value);
+}
 }
 }
 
diff --git a/test/org/apache/catalina/filters/TestExpiresFilter.java 
b/test/org/apache/catalina/filters/TestExpiresFilter.java
index 83a82d3a6e..edb15813dc 100644
--- a/test/org/apache/catalina/filters/TestExpiresFilter.java
+++ b/test/org/apache/catalina/filters/TestExpiresFilter.java
@@ -42,6 +42,7 @@ import 
org.apache.catalina.filters.ExpiresFilter.StartingPoint;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
 import org.apache.tomcat.util.buf.ByteChunk;
+import org.apache.tomcat.util.buf.StringUtils;
 import org.apache.tomcat.util.collections.CaseInsensitiveKeyMap;
 import org.apache.tomcat.util.descriptor.web.FilterDef;
 import org.apache.tomcat.util.descriptor.web.FilterMap;
@@ -92,8 +93,8 @@ public class TestExpiresFilter extends TomcatBaseTest {
 Assert.assertEquals(1, 
expiresConfigurationDefault.getDurations().get(0).getAmount());
 
 // VERIFY TEXT/HTML
-ExpiresConfiguration expiresConfigurationTextHtml = 
expiresFilter.getExpiresConfigura

Re: [PR] bz69439 - fix: improper handling of conflicting cache-control directives [tomcat]

2024-11-20 Thread via GitHub


markt-asf closed pull request #777: bz69439 - fix: improper handling of 
conflicting cache-control directives
URL: https://github.com/apache/tomcat/pull/777


-- 
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 11.0.x updated: Fix BZ 69439 - Improve handling of multiple Cache-Control headers

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

markt 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 d70e4a396c Fix BZ 69439 - Improve handling of multiple Cache-Control 
headers
d70e4a396c is described below

commit d70e4a396c59f731bc587edd389288d63d7f54ca
Author: Mark Thomas 
AuthorDate: Wed Nov 20 19:17:10 2024 +

Fix BZ 69439 - Improve handling of multiple Cache-Control headers

Based on #777 by Chenjp
---
 .../org/apache/catalina/filters/ExpiresFilter.java |  20 ++--
 .../apache/catalina/filters/TestExpiresFilter.java | 127 +
 webapps/docs/changelog.xml |   5 +
 3 files changed, 122 insertions(+), 30 deletions(-)

diff --git a/java/org/apache/catalina/filters/ExpiresFilter.java 
b/java/org/apache/catalina/filters/ExpiresFilter.java
index f3bde19d0e..be38e58dd7 100644
--- a/java/org/apache/catalina/filters/ExpiresFilter.java
+++ b/java/org/apache/catalina/filters/ExpiresFilter.java
@@ -165,10 +165,10 @@ import org.apache.tomcat.util.buf.StringUtils;
  * 
  * {@code ExpiresExcludedResponseStatusCodes}
  * 
- * This directive defines the http response status codes for which the
+ * This directive defines the HTTP response status codes for which the
  * {@code ExpiresFilter} will not generate expiration headers. By default, the
  * {@code 304} status code ("{@code Not modified}") is skipped. The
- * value is a comma separated list of http status codes.
+ * value is a comma separated list of HTTP status codes.
  * 
  * 
  * This directive is useful to ease usage of {@code ExpiresDefault} directive.
@@ -332,7 +332,7 @@ import org.apache.tomcat.util.buf.StringUtils;
  * 
  * 
  * To trap the 'before write response body' event, the
- * {@code ExpiresFilter} wraps the http servlet response's writer and
+ * {@code ExpiresFilter} wraps the HTTP servlet response's writer and
  * outputStream to intercept calls to the methods {@code write()},
  * {@code print()}, {@code close()} and {@code flush()}. For empty response
  * body (e.g. empty files), the {@code write()}, {@code print()},
@@ -517,7 +517,7 @@ public class ExpiresFilter extends FilterBase {
 
 /**
  * 
- * Wrapping extension of the {@link HttpServletResponse} to yrap the 
"Start Write Response Body" event.
+ * Wrapping extension of the {@link HttpServletResponse} to wrap the 
"Start Write Response Body" event.
  * 
  * 
  * For performance optimization : this extended response holds the {@link 
#lastModifiedHeader} and
@@ -528,12 +528,12 @@ public class ExpiresFilter extends FilterBase {
 public class XHttpServletResponse extends HttpServletResponseWrapper {
 
 /**
- * Value of the {@code Cache-Control} http response header if it has 
been set.
+ * Value of the {@code Cache-Control} HTTP response header if it has 
been set.
  */
 private String cacheControlHeader;
 
 /**
- * Value of the {@code Last-Modified} http response header if it has 
been set.
+ * Value of the {@code Last-Modified} HTTP response header if it has 
been set.
  */
 private long lastModifiedHeader;
 
@@ -568,8 +568,12 @@ public class ExpiresFilter extends FilterBase {
 @Override
 public void addHeader(String name, String value) {
 super.addHeader(name, value);
-if (HEADER_CACHE_CONTROL.equalsIgnoreCase(name) && 
cacheControlHeader == null) {
-cacheControlHeader = value;
+if (HEADER_CACHE_CONTROL.equalsIgnoreCase(name)) {
+if (cacheControlHeader == null) {
+cacheControlHeader = value;
+} else {
+cacheControlHeader = StringUtils.join(cacheControlHeader, 
value);
+}
 }
 }
 
diff --git a/test/org/apache/catalina/filters/TestExpiresFilter.java 
b/test/org/apache/catalina/filters/TestExpiresFilter.java
index 83a82d3a6e..edb15813dc 100644
--- a/test/org/apache/catalina/filters/TestExpiresFilter.java
+++ b/test/org/apache/catalina/filters/TestExpiresFilter.java
@@ -42,6 +42,7 @@ import 
org.apache.catalina.filters.ExpiresFilter.StartingPoint;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
 import org.apache.tomcat.util.buf.ByteChunk;
+import org.apache.tomcat.util.buf.StringUtils;
 import org.apache.tomcat.util.collections.CaseInsensitiveKeyMap;
 import org.apache.tomcat.util.descriptor.web.FilterDef;
 import org.apache.tomcat.util.descriptor.web.FilterMap;
@@ -92,8 +93,8 @@ public class TestExpiresFilter extends TomcatBaseTest {
 Assert.assertEquals(1, 
expiresConfigurationDefault.getDurations().get(0).getAmount());
 
 // VERIFY TEXT/HTML
-ExpiresConfiguration expiresConfigurationTextHtml = 
expiresFilter.getExpiresConfi

(tomcat) branch 9.0.x updated: Fix BZ 69439 - Improve handling of multiple Cache-Control headers

2024-11-20 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 71ed0ddd38 Fix BZ 69439 - Improve handling of multiple Cache-Control 
headers
71ed0ddd38 is described below

commit 71ed0ddd384cff61a5029bc2fbe96d06636ddbb6
Author: Mark Thomas 
AuthorDate: Wed Nov 20 19:17:10 2024 +

Fix BZ 69439 - Improve handling of multiple Cache-Control headers

Based on #777 by Chenjp
---
 .../org/apache/catalina/filters/ExpiresFilter.java |  20 ++--
 .../apache/catalina/filters/TestExpiresFilter.java | 127 +
 webapps/docs/changelog.xml |   5 +
 3 files changed, 122 insertions(+), 30 deletions(-)

diff --git a/java/org/apache/catalina/filters/ExpiresFilter.java 
b/java/org/apache/catalina/filters/ExpiresFilter.java
index cd7b084575..ef54a3ad73 100644
--- a/java/org/apache/catalina/filters/ExpiresFilter.java
+++ b/java/org/apache/catalina/filters/ExpiresFilter.java
@@ -165,10 +165,10 @@ import org.apache.tomcat.util.buf.StringUtils;
  * 
  * {@code ExpiresExcludedResponseStatusCodes}
  * 
- * This directive defines the http response status codes for which the
+ * This directive defines the HTTP response status codes for which the
  * {@code ExpiresFilter} will not generate expiration headers. By default, the
  * {@code 304} status code ("{@code Not modified}") is skipped. The
- * value is a comma separated list of http status codes.
+ * value is a comma separated list of HTTP status codes.
  * 
  * 
  * This directive is useful to ease usage of {@code ExpiresDefault} directive.
@@ -332,7 +332,7 @@ import org.apache.tomcat.util.buf.StringUtils;
  * 
  * 
  * To trap the 'before write response body' event, the
- * {@code ExpiresFilter} wraps the http servlet response's writer and
+ * {@code ExpiresFilter} wraps the HTTP servlet response's writer and
  * outputStream to intercept calls to the methods {@code write()},
  * {@code print()}, {@code close()} and {@code flush()}. For empty response
  * body (e.g. empty files), the {@code write()}, {@code print()},
@@ -517,7 +517,7 @@ public class ExpiresFilter extends FilterBase {
 
 /**
  * 
- * Wrapping extension of the {@link HttpServletResponse} to yrap the 
"Start Write Response Body" event.
+ * Wrapping extension of the {@link HttpServletResponse} to wrap the 
"Start Write Response Body" event.
  * 
  * 
  * For performance optimization : this extended response holds the {@link 
#lastModifiedHeader} and
@@ -528,12 +528,12 @@ public class ExpiresFilter extends FilterBase {
 public class XHttpServletResponse extends HttpServletResponseWrapper {
 
 /**
- * Value of the {@code Cache-Control} http response header if it has 
been set.
+ * Value of the {@code Cache-Control} HTTP response header if it has 
been set.
  */
 private String cacheControlHeader;
 
 /**
- * Value of the {@code Last-Modified} http response header if it has 
been set.
+ * Value of the {@code Last-Modified} HTTP response header if it has 
been set.
  */
 private long lastModifiedHeader;
 
@@ -568,8 +568,12 @@ public class ExpiresFilter extends FilterBase {
 @Override
 public void addHeader(String name, String value) {
 super.addHeader(name, value);
-if (HEADER_CACHE_CONTROL.equalsIgnoreCase(name) && 
cacheControlHeader == null) {
-cacheControlHeader = value;
+if (HEADER_CACHE_CONTROL.equalsIgnoreCase(name)) {
+if (cacheControlHeader == null) {
+cacheControlHeader = value;
+} else {
+cacheControlHeader = StringUtils.join(cacheControlHeader, 
value);
+}
 }
 }
 
diff --git a/test/org/apache/catalina/filters/TestExpiresFilter.java 
b/test/org/apache/catalina/filters/TestExpiresFilter.java
index a3778af9b2..1d5fa60811 100644
--- a/test/org/apache/catalina/filters/TestExpiresFilter.java
+++ b/test/org/apache/catalina/filters/TestExpiresFilter.java
@@ -42,6 +42,7 @@ import 
org.apache.catalina.filters.ExpiresFilter.StartingPoint;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
 import org.apache.tomcat.util.buf.ByteChunk;
+import org.apache.tomcat.util.buf.StringUtils;
 import org.apache.tomcat.util.collections.CaseInsensitiveKeyMap;
 import org.apache.tomcat.util.descriptor.web.FilterDef;
 import org.apache.tomcat.util.descriptor.web.FilterMap;
@@ -92,8 +93,8 @@ public class TestExpiresFilter extends TomcatBaseTest {
 Assert.assertEquals(1, 
expiresConfigurationDefault.getDurations().get(0).getAmount());
 
 // VERIFY TEXT/HTML
-ExpiresConfiguration expiresConfigurationTextHtml = 
expiresFilter.getExpiresConfigu

Re: [PR] bz69439 - fix: improper handling of conflicting cache-control directives [tomcat]

2024-11-20 Thread via GitHub


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

   Thanks for the PR. I have applied a fix based on this PR.
   
   Removing the cache-control header caching removes a deliberate performance 
optimisation (and doesn't update the Javadoc to reflect that change either). I 
opted for the simpler approach of merging multiple headers into a single header 
in the cache. I also slightly changed the test cases.


-- 
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 69439] ExpiresFilter - improper handling of conflicting cache-control directives

2024-11-20 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69439

Mark Thomas  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED
 OS||All

--- Comment #1 from Mark Thomas  ---
Fixed in:
- 11.0.x for 11.0.2 onwards
- 10.1.x for 10.1.34 onwards
-  9.0.x for  9.0.98 onwards

-- 
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 10.1.x updated: Fix BZ 69439 - Improve handling of multiple Cache-Control headers

2024-11-20 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 ecf1b71f9c Fix BZ 69439 - Improve handling of multiple Cache-Control 
headers
ecf1b71f9c is described below

commit ecf1b71f9c5a0dc95a192c0443c713137efbc7b5
Author: Mark Thomas 
AuthorDate: Wed Nov 20 19:17:10 2024 +

Fix BZ 69439 - Improve handling of multiple Cache-Control headers

Based on #777 by Chenjp
---
 .../org/apache/catalina/filters/ExpiresFilter.java |  20 ++--
 .../apache/catalina/filters/TestExpiresFilter.java | 127 +
 webapps/docs/changelog.xml |   5 +
 3 files changed, 122 insertions(+), 30 deletions(-)

diff --git a/java/org/apache/catalina/filters/ExpiresFilter.java 
b/java/org/apache/catalina/filters/ExpiresFilter.java
index 1cb05f0d82..8b5291f973 100644
--- a/java/org/apache/catalina/filters/ExpiresFilter.java
+++ b/java/org/apache/catalina/filters/ExpiresFilter.java
@@ -165,10 +165,10 @@ import org.apache.tomcat.util.buf.StringUtils;
  * 
  * {@code ExpiresExcludedResponseStatusCodes}
  * 
- * This directive defines the http response status codes for which the
+ * This directive defines the HTTP response status codes for which the
  * {@code ExpiresFilter} will not generate expiration headers. By default, the
  * {@code 304} status code ("{@code Not modified}") is skipped. The
- * value is a comma separated list of http status codes.
+ * value is a comma separated list of HTTP status codes.
  * 
  * 
  * This directive is useful to ease usage of {@code ExpiresDefault} directive.
@@ -332,7 +332,7 @@ import org.apache.tomcat.util.buf.StringUtils;
  * 
  * 
  * To trap the 'before write response body' event, the
- * {@code ExpiresFilter} wraps the http servlet response's writer and
+ * {@code ExpiresFilter} wraps the HTTP servlet response's writer and
  * outputStream to intercept calls to the methods {@code write()},
  * {@code print()}, {@code close()} and {@code flush()}. For empty response
  * body (e.g. empty files), the {@code write()}, {@code print()},
@@ -517,7 +517,7 @@ public class ExpiresFilter extends FilterBase {
 
 /**
  * 
- * Wrapping extension of the {@link HttpServletResponse} to yrap the 
"Start Write Response Body" event.
+ * Wrapping extension of the {@link HttpServletResponse} to wrap the 
"Start Write Response Body" event.
  * 
  * 
  * For performance optimization : this extended response holds the {@link 
#lastModifiedHeader} and
@@ -528,12 +528,12 @@ public class ExpiresFilter extends FilterBase {
 public class XHttpServletResponse extends HttpServletResponseWrapper {
 
 /**
- * Value of the {@code Cache-Control} http response header if it has 
been set.
+ * Value of the {@code Cache-Control} HTTP response header if it has 
been set.
  */
 private String cacheControlHeader;
 
 /**
- * Value of the {@code Last-Modified} http response header if it has 
been set.
+ * Value of the {@code Last-Modified} HTTP response header if it has 
been set.
  */
 private long lastModifiedHeader;
 
@@ -568,8 +568,12 @@ public class ExpiresFilter extends FilterBase {
 @Override
 public void addHeader(String name, String value) {
 super.addHeader(name, value);
-if (HEADER_CACHE_CONTROL.equalsIgnoreCase(name) && 
cacheControlHeader == null) {
-cacheControlHeader = value;
+if (HEADER_CACHE_CONTROL.equalsIgnoreCase(name)) {
+if (cacheControlHeader == null) {
+cacheControlHeader = value;
+} else {
+cacheControlHeader = StringUtils.join(cacheControlHeader, 
value);
+}
 }
 }
 
diff --git a/test/org/apache/catalina/filters/TestExpiresFilter.java 
b/test/org/apache/catalina/filters/TestExpiresFilter.java
index 83a82d3a6e..edb15813dc 100644
--- a/test/org/apache/catalina/filters/TestExpiresFilter.java
+++ b/test/org/apache/catalina/filters/TestExpiresFilter.java
@@ -42,6 +42,7 @@ import 
org.apache.catalina.filters.ExpiresFilter.StartingPoint;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
 import org.apache.tomcat.util.buf.ByteChunk;
+import org.apache.tomcat.util.buf.StringUtils;
 import org.apache.tomcat.util.collections.CaseInsensitiveKeyMap;
 import org.apache.tomcat.util.descriptor.web.FilterDef;
 import org.apache.tomcat.util.descriptor.web.FilterMap;
@@ -92,8 +93,8 @@ public class TestExpiresFilter extends TomcatBaseTest {
 Assert.assertEquals(1, 
expiresConfigurationDefault.getDurations().get(0).getAmount());
 
 // VERIFY TEXT/HTML
-ExpiresConfiguration expiresConfigurationTextHtml = 
expiresFilter.getExpiresConfi

svn commit: r1921967 - in /tomcat/site/trunk: docs/security-9.html xdocs/security-9.xml

2024-11-20 Thread markt
Author: markt
Date: Wed Nov 20 08:53:05 2024
New Revision: 1921967

URL: http://svn.apache.org/viewvc?rev=1921967&view=rev
Log:
Fix version typo

Modified:
tomcat/site/trunk/docs/security-9.html
tomcat/site/trunk/xdocs/security-9.xml

Modified: tomcat/site/trunk/docs/security-9.html
URL: 
http://svn.apache.org/viewvc/tomcat/site/trunk/docs/security-9.html?rev=1921967&r1=1921966&r2=1921967&view=diff
==
--- tomcat/site/trunk/docs/security-9.html (original)
+++ tomcat/site/trunk/docs/security-9.html Wed Nov 20 08:53:05 2024
@@ -85,7 +85,7 @@
 This issue was identified by the Tomcat Security Team on 19 September
2024. The issue was made public on 18 November 2024.
 
-Affects: 9.0.0-M1 to 9.9.95
+Affects: 9.0.0-M1 to 9.0.95
 
   2024-06-19 Fixed in Apache Tomcat 9.0.90
 

Modified: tomcat/site/trunk/xdocs/security-9.xml
URL: 
http://svn.apache.org/viewvc/tomcat/site/trunk/xdocs/security-9.xml?rev=1921967&r1=1921966&r2=1921967&view=diff
==
--- tomcat/site/trunk/xdocs/security-9.xml (original)
+++ tomcat/site/trunk/xdocs/security-9.xml Wed Nov 20 08:53:05 2024
@@ -100,7 +100,7 @@
 This issue was identified by the Tomcat Security Team on 19 September
2024. The issue was made public on 18 November 2024.
 
-Affects: 9.0.0-M1 to 9.9.95
+Affects: 9.0.0-M1 to 9.0.95
 
   
 



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



Re: (tomcat) branch main updated: Add strong ETag support

2024-11-20 Thread Mark Thomas

On 19/11/2024 22:24, r...@apache.org wrote:

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 4810b66087 Add strong ETag support
4810b66087 is described below

commit 4810b660870d6b42bab6b076f57d444cc30b8d8c
Author: remm 
AuthorDate: Tue Nov 19 23:24:27 2024 +0100

 Add strong ETag support
 
 Using a useStrongETags init parameter on the default (and WebDAV)

 servlet.
 The ETag generated is a SHA-1 checksum of the file content.


A couple of comments / questions in-line.




diff --git a/java/org/apache/catalina/webresources/AbstractResource.java 
b/java/org/apache/catalina/webresources/AbstractResource.java
index 384c327321..2bd0bdf356 100644
--- a/java/org/apache/catalina/webresources/AbstractResource.java
+++ b/java/org/apache/catalina/webresources/AbstractResource.java





@@ -75,6 +81,52 @@ public abstract class AbstractResource implements 
WebResource {
  return weakETag;
  }
  
+@Override

+public final String getStrongETag() {
+if (strongETag == null) {
+synchronized (this) {
+if (strongETag == null) {
+long contentLength = getContentLength();


This doesn't take account of possible conversion on platforms where 
EBCDIC is the default characterset. You probably want to use 
getContentLengthInternal() here but that only exists in FileResource.



+long lastModified = getLastModified();
+if (contentLength > 0 && lastModified > 0) {
+try (InputStream is = getInputStream()) {


This will bypass the cache. Is there a way to refactor this to take 
advantage of any cached content for the resource?


Mark

-
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: Improve strong etags for caching

2024-11-20 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 57183dc9d7 Improve strong etags for caching
57183dc9d7 is described below

commit 57183dc9d734ed1b23881cbf6b6875cbeb3ff8e4
Author: remm 
AuthorDate: Wed Nov 20 12:26:34 2024 +0100

Improve strong etags for caching
---
 .../catalina/webresources/AbstractResource.java| 45 +-
 .../catalina/webresources/CachedResource.java  | 14 ++-
 .../catalina/servlets/TestWebdavServlet.java   | 24 ++--
 3 files changed, 52 insertions(+), 31 deletions(-)

diff --git a/java/org/apache/catalina/webresources/AbstractResource.java 
b/java/org/apache/catalina/webresources/AbstractResource.java
index 2bd0bdf356..fccc3fb2e2 100644
--- a/java/org/apache/catalina/webresources/AbstractResource.java
+++ b/java/org/apache/catalina/webresources/AbstractResource.java
@@ -16,13 +16,11 @@
  */
 package org.apache.catalina.webresources;
 
-import java.io.IOException;
 import java.io.InputStream;
 import java.security.MessageDigest;
 
 import org.apache.catalina.WebResource;
 import org.apache.catalina.WebResourceRoot;
-import org.apache.catalina.util.IOTools;
 import org.apache.juli.logging.Log;
 import org.apache.tomcat.util.buf.HexUtils;
 import org.apache.tomcat.util.http.FastHttpDateFormat;
@@ -89,34 +87,29 @@ public abstract class AbstractResource implements 
WebResource {
 long contentLength = getContentLength();
 long lastModified = getLastModified();
 if (contentLength > 0 && lastModified > 0) {
-try (InputStream is = getInputStream()) {
-if (contentLength <= 16 * 1024) {
-byte[] buf = new byte[(int) contentLength];
-int n = IOTools.readFully(is, buf);
-if (n > 0) {
-buf = 
ConcurrentMessageDigest.digest("SHA-1", buf);
-strongETag = HexUtils.toHexString(buf);
-} else {
-strongETag = getETag();
-}
+if (contentLength <= 16 * 1024) {
+byte[] buf = getContent();
+if (buf != null) {
+buf = ConcurrentMessageDigest.digest("SHA-1", 
buf);
+strongETag = HexUtils.toHexString(buf);
 } else {
-byte[] buf = new byte[4096];
-try {
-MessageDigest digest = 
MessageDigest.getInstance("SHA-1");
-while (true) {
-int n = is.read(buf);
-if (n <= 0) {
-break;
-}
-digest.update(buf, 0, n);
+strongETag = getETag();
+}
+} else {
+byte[] buf = new byte[4096];
+try (InputStream is = getInputStream()) {
+MessageDigest digest = 
MessageDigest.getInstance("SHA-1");
+while (true) {
+int n = is.read(buf);
+if (n <= 0) {
+break;
 }
-strongETag = 
HexUtils.toHexString(digest.digest());
-} catch (Exception e) {
-strongETag = getETag();
+digest.update(buf, 0, n);
 }
+strongETag = 
HexUtils.toHexString(digest.digest());
+} catch (Exception e) {
+strongETag = getETag();
 }
-} catch (IOException e) {
-strongETag = getETag();
 }
 } else {
 strongETag = getETag();
diff --git a/java/org/apache/catalina/webresources/CachedResource.java 
b/java/org/apache/catalina/webresources/CachedResource.java
index 74fa278d20..5c25c1fb81 100644
--- a/java/org/apache/catalina/webresources/CachedResource.java
+++ b/java/org/apache/catalina/webresources/CachedResource.java
@@ -39,7 +39,9 @@ import org.apache.catalina.WebResource;
 import org.apache.catalina.WebResourceRoot;
 i

(tomcat) branch 10.1.x updated: Improve strong etags for caching

2024-11-20 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 74ecfad2e5 Improve strong etags for caching
74ecfad2e5 is described below

commit 74ecfad2e5faa46bbdcadad0db0bba5d9bc02c0d
Author: remm 
AuthorDate: Wed Nov 20 12:26:34 2024 +0100

Improve strong etags for caching
---
 .../catalina/webresources/AbstractResource.java| 45 +-
 .../catalina/webresources/CachedResource.java  | 14 ++-
 .../catalina/servlets/TestWebdavServlet.java   | 24 ++--
 3 files changed, 52 insertions(+), 31 deletions(-)

diff --git a/java/org/apache/catalina/webresources/AbstractResource.java 
b/java/org/apache/catalina/webresources/AbstractResource.java
index 2bd0bdf356..fccc3fb2e2 100644
--- a/java/org/apache/catalina/webresources/AbstractResource.java
+++ b/java/org/apache/catalina/webresources/AbstractResource.java
@@ -16,13 +16,11 @@
  */
 package org.apache.catalina.webresources;
 
-import java.io.IOException;
 import java.io.InputStream;
 import java.security.MessageDigest;
 
 import org.apache.catalina.WebResource;
 import org.apache.catalina.WebResourceRoot;
-import org.apache.catalina.util.IOTools;
 import org.apache.juli.logging.Log;
 import org.apache.tomcat.util.buf.HexUtils;
 import org.apache.tomcat.util.http.FastHttpDateFormat;
@@ -89,34 +87,29 @@ public abstract class AbstractResource implements 
WebResource {
 long contentLength = getContentLength();
 long lastModified = getLastModified();
 if (contentLength > 0 && lastModified > 0) {
-try (InputStream is = getInputStream()) {
-if (contentLength <= 16 * 1024) {
-byte[] buf = new byte[(int) contentLength];
-int n = IOTools.readFully(is, buf);
-if (n > 0) {
-buf = 
ConcurrentMessageDigest.digest("SHA-1", buf);
-strongETag = HexUtils.toHexString(buf);
-} else {
-strongETag = getETag();
-}
+if (contentLength <= 16 * 1024) {
+byte[] buf = getContent();
+if (buf != null) {
+buf = ConcurrentMessageDigest.digest("SHA-1", 
buf);
+strongETag = HexUtils.toHexString(buf);
 } else {
-byte[] buf = new byte[4096];
-try {
-MessageDigest digest = 
MessageDigest.getInstance("SHA-1");
-while (true) {
-int n = is.read(buf);
-if (n <= 0) {
-break;
-}
-digest.update(buf, 0, n);
+strongETag = getETag();
+}
+} else {
+byte[] buf = new byte[4096];
+try (InputStream is = getInputStream()) {
+MessageDigest digest = 
MessageDigest.getInstance("SHA-1");
+while (true) {
+int n = is.read(buf);
+if (n <= 0) {
+break;
 }
-strongETag = 
HexUtils.toHexString(digest.digest());
-} catch (Exception e) {
-strongETag = getETag();
+digest.update(buf, 0, n);
 }
+strongETag = 
HexUtils.toHexString(digest.digest());
+} catch (Exception e) {
+strongETag = getETag();
 }
-} catch (IOException e) {
-strongETag = getETag();
 }
 } else {
 strongETag = getETag();
diff --git a/java/org/apache/catalina/webresources/CachedResource.java 
b/java/org/apache/catalina/webresources/CachedResource.java
index 9a424cc529..83510f9d98 100644
--- a/java/org/apache/catalina/webresources/CachedResource.java
+++ b/java/org/apache/catalina/webresources/CachedResource.java
@@ -39,7 +39,9 @@ import org.apache.catalina.WebResource;
 import org.apache.catalina.WebResourceRoot;
 i

(tomcat) branch 9.0.x updated: Improve strong etags for caching

2024-11-20 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 64afed8570 Improve strong etags for caching
64afed8570 is described below

commit 64afed85707a37309c77abdd1e91b8988acc3438
Author: remm 
AuthorDate: Wed Nov 20 12:26:34 2024 +0100

Improve strong etags for caching
---
 .../catalina/webresources/AbstractResource.java| 45 +-
 .../catalina/webresources/CachedResource.java  | 14 ++-
 .../catalina/servlets/TestWebdavServlet.java   | 24 ++--
 3 files changed, 52 insertions(+), 31 deletions(-)

diff --git a/java/org/apache/catalina/webresources/AbstractResource.java 
b/java/org/apache/catalina/webresources/AbstractResource.java
index 2bd0bdf356..fccc3fb2e2 100644
--- a/java/org/apache/catalina/webresources/AbstractResource.java
+++ b/java/org/apache/catalina/webresources/AbstractResource.java
@@ -16,13 +16,11 @@
  */
 package org.apache.catalina.webresources;
 
-import java.io.IOException;
 import java.io.InputStream;
 import java.security.MessageDigest;
 
 import org.apache.catalina.WebResource;
 import org.apache.catalina.WebResourceRoot;
-import org.apache.catalina.util.IOTools;
 import org.apache.juli.logging.Log;
 import org.apache.tomcat.util.buf.HexUtils;
 import org.apache.tomcat.util.http.FastHttpDateFormat;
@@ -89,34 +87,29 @@ public abstract class AbstractResource implements 
WebResource {
 long contentLength = getContentLength();
 long lastModified = getLastModified();
 if (contentLength > 0 && lastModified > 0) {
-try (InputStream is = getInputStream()) {
-if (contentLength <= 16 * 1024) {
-byte[] buf = new byte[(int) contentLength];
-int n = IOTools.readFully(is, buf);
-if (n > 0) {
-buf = 
ConcurrentMessageDigest.digest("SHA-1", buf);
-strongETag = HexUtils.toHexString(buf);
-} else {
-strongETag = getETag();
-}
+if (contentLength <= 16 * 1024) {
+byte[] buf = getContent();
+if (buf != null) {
+buf = ConcurrentMessageDigest.digest("SHA-1", 
buf);
+strongETag = HexUtils.toHexString(buf);
 } else {
-byte[] buf = new byte[4096];
-try {
-MessageDigest digest = 
MessageDigest.getInstance("SHA-1");
-while (true) {
-int n = is.read(buf);
-if (n <= 0) {
-break;
-}
-digest.update(buf, 0, n);
+strongETag = getETag();
+}
+} else {
+byte[] buf = new byte[4096];
+try (InputStream is = getInputStream()) {
+MessageDigest digest = 
MessageDigest.getInstance("SHA-1");
+while (true) {
+int n = is.read(buf);
+if (n <= 0) {
+break;
 }
-strongETag = 
HexUtils.toHexString(digest.digest());
-} catch (Exception e) {
-strongETag = getETag();
+digest.update(buf, 0, n);
 }
+strongETag = 
HexUtils.toHexString(digest.digest());
+} catch (Exception e) {
+strongETag = getETag();
 }
-} catch (IOException e) {
-strongETag = getETag();
 }
 } else {
 strongETag = getETag();
diff --git a/java/org/apache/catalina/webresources/CachedResource.java 
b/java/org/apache/catalina/webresources/CachedResource.java
index 9a424cc529..83510f9d98 100644
--- a/java/org/apache/catalina/webresources/CachedResource.java
+++ b/java/org/apache/catalina/webresources/CachedResource.java
@@ -39,7 +39,9 @@ import org.apache.catalina.WebResource;
 import org.apache.catalina.WebResourceRoot;
 imp

(tomcat) branch main updated: Avoid unchecked exception for very large files

2024-11-20 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 9ef6a6de3b Avoid unchecked exception for very large files
9ef6a6de3b is described below

commit 9ef6a6de3bdd63f2cd3459aadd6fddadfbb5800d
Author: remm 
AuthorDate: Wed Nov 20 12:14:47 2024 +0100

Avoid unchecked exception for very large files

This works because there's a cache on top returning null for cached
files, but the javadoc is explicit that null should be returned when the
file is too big.
---
 java/org/apache/catalina/webresources/FileResource.java | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/webresources/FileResource.java 
b/java/org/apache/catalina/webresources/FileResource.java
index 354022f909..9b7db00d6d 100644
--- a/java/org/apache/catalina/webresources/FileResource.java
+++ b/java/org/apache/catalina/webresources/FileResource.java
@@ -216,8 +216,10 @@ public class FileResource extends AbstractResource {
 
 if (len > Integer.MAX_VALUE) {
 // Can't create an array that big
-throw new ArrayIndexOutOfBoundsException(
-sm.getString("abstractResource.getContentTooLarge", 
getWebappPath(), Long.valueOf(len)));
+if (getLog().isDebugEnabled()) {
+
getLog().debug(sm.getString("abstractResource.getContentTooLarge", 
getWebappPath(), Long.valueOf(len)));
+}
+return null;
 }
 
 if (len < 0) {


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



(tomcat) branch 10.1.x updated: Avoid unchecked exception for very large files

2024-11-20 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 729859f2cb Avoid unchecked exception for very large files
729859f2cb is described below

commit 729859f2cb97627ebbb379a14b42c687211787e2
Author: remm 
AuthorDate: Wed Nov 20 12:14:47 2024 +0100

Avoid unchecked exception for very large files

This works because there's a cache on top returning null for cached
files, but the javadoc is explicit that null should be returned when the
file is too big.
---
 java/org/apache/catalina/webresources/FileResource.java | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/webresources/FileResource.java 
b/java/org/apache/catalina/webresources/FileResource.java
index 354022f909..9b7db00d6d 100644
--- a/java/org/apache/catalina/webresources/FileResource.java
+++ b/java/org/apache/catalina/webresources/FileResource.java
@@ -216,8 +216,10 @@ public class FileResource extends AbstractResource {
 
 if (len > Integer.MAX_VALUE) {
 // Can't create an array that big
-throw new ArrayIndexOutOfBoundsException(
-sm.getString("abstractResource.getContentTooLarge", 
getWebappPath(), Long.valueOf(len)));
+if (getLog().isDebugEnabled()) {
+
getLog().debug(sm.getString("abstractResource.getContentTooLarge", 
getWebappPath(), Long.valueOf(len)));
+}
+return null;
 }
 
 if (len < 0) {


-
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: Avoid unchecked exception for very large files

2024-11-20 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 09753487d4 Avoid unchecked exception for very large files
09753487d4 is described below

commit 09753487d4e9f76b9830fa90a1ad3bbc2775ff6a
Author: remm 
AuthorDate: Wed Nov 20 12:14:47 2024 +0100

Avoid unchecked exception for very large files

This works because there's a cache on top returning null for cached
files, but the javadoc is explicit that null should be returned when the
file is too big.
---
 java/org/apache/catalina/webresources/FileResource.java | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/webresources/FileResource.java 
b/java/org/apache/catalina/webresources/FileResource.java
index 354022f909..9b7db00d6d 100644
--- a/java/org/apache/catalina/webresources/FileResource.java
+++ b/java/org/apache/catalina/webresources/FileResource.java
@@ -216,8 +216,10 @@ public class FileResource extends AbstractResource {
 
 if (len > Integer.MAX_VALUE) {
 // Can't create an array that big
-throw new ArrayIndexOutOfBoundsException(
-sm.getString("abstractResource.getContentTooLarge", 
getWebappPath(), Long.valueOf(len)));
+if (getLog().isDebugEnabled()) {
+
getLog().debug(sm.getString("abstractResource.getContentTooLarge", 
getWebappPath(), Long.valueOf(len)));
+}
+return null;
 }
 
 if (len < 0) {


-
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: Avoid unchecked exception for very large files

2024-11-20 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 4553b44cb4 Avoid unchecked exception for very large files
4553b44cb4 is described below

commit 4553b44cb4cfc5e8b4ecd19fd752e5470396d050
Author: remm 
AuthorDate: Wed Nov 20 12:14:47 2024 +0100

Avoid unchecked exception for very large files

This works because there's a cache on top returning null for cached
files, but the javadoc is explicit that null should be returned when the
file is too big.
---
 java/org/apache/catalina/webresources/FileResource.java | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/webresources/FileResource.java 
b/java/org/apache/catalina/webresources/FileResource.java
index 354022f909..9b7db00d6d 100644
--- a/java/org/apache/catalina/webresources/FileResource.java
+++ b/java/org/apache/catalina/webresources/FileResource.java
@@ -216,8 +216,10 @@ public class FileResource extends AbstractResource {
 
 if (len > Integer.MAX_VALUE) {
 // Can't create an array that big
-throw new ArrayIndexOutOfBoundsException(
-sm.getString("abstractResource.getContentTooLarge", 
getWebappPath(), Long.valueOf(len)));
+if (getLog().isDebugEnabled()) {
+
getLog().debug(sm.getString("abstractResource.getContentTooLarge", 
getWebappPath(), Long.valueOf(len)));
+}
+return null;
 }
 
 if (len < 0) {


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



(tomcat) branch main updated: Improve strong etags for caching

2024-11-20 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 f1f807e378 Improve strong etags for caching
f1f807e378 is described below

commit f1f807e378d8c2efb07c50f4d934f990a2ef5c05
Author: remm 
AuthorDate: Wed Nov 20 12:26:34 2024 +0100

Improve strong etags for caching
---
 .../catalina/webresources/AbstractResource.java| 45 +-
 .../catalina/webresources/CachedResource.java  | 14 ++-
 .../catalina/servlets/TestWebdavServlet.java   | 24 ++--
 3 files changed, 52 insertions(+), 31 deletions(-)

diff --git a/java/org/apache/catalina/webresources/AbstractResource.java 
b/java/org/apache/catalina/webresources/AbstractResource.java
index 2bd0bdf356..fccc3fb2e2 100644
--- a/java/org/apache/catalina/webresources/AbstractResource.java
+++ b/java/org/apache/catalina/webresources/AbstractResource.java
@@ -16,13 +16,11 @@
  */
 package org.apache.catalina.webresources;
 
-import java.io.IOException;
 import java.io.InputStream;
 import java.security.MessageDigest;
 
 import org.apache.catalina.WebResource;
 import org.apache.catalina.WebResourceRoot;
-import org.apache.catalina.util.IOTools;
 import org.apache.juli.logging.Log;
 import org.apache.tomcat.util.buf.HexUtils;
 import org.apache.tomcat.util.http.FastHttpDateFormat;
@@ -89,34 +87,29 @@ public abstract class AbstractResource implements 
WebResource {
 long contentLength = getContentLength();
 long lastModified = getLastModified();
 if (contentLength > 0 && lastModified > 0) {
-try (InputStream is = getInputStream()) {
-if (contentLength <= 16 * 1024) {
-byte[] buf = new byte[(int) contentLength];
-int n = IOTools.readFully(is, buf);
-if (n > 0) {
-buf = 
ConcurrentMessageDigest.digest("SHA-1", buf);
-strongETag = HexUtils.toHexString(buf);
-} else {
-strongETag = getETag();
-}
+if (contentLength <= 16 * 1024) {
+byte[] buf = getContent();
+if (buf != null) {
+buf = ConcurrentMessageDigest.digest("SHA-1", 
buf);
+strongETag = HexUtils.toHexString(buf);
 } else {
-byte[] buf = new byte[4096];
-try {
-MessageDigest digest = 
MessageDigest.getInstance("SHA-1");
-while (true) {
-int n = is.read(buf);
-if (n <= 0) {
-break;
-}
-digest.update(buf, 0, n);
+strongETag = getETag();
+}
+} else {
+byte[] buf = new byte[4096];
+try (InputStream is = getInputStream()) {
+MessageDigest digest = 
MessageDigest.getInstance("SHA-1");
+while (true) {
+int n = is.read(buf);
+if (n <= 0) {
+break;
 }
-strongETag = 
HexUtils.toHexString(digest.digest());
-} catch (Exception e) {
-strongETag = getETag();
+digest.update(buf, 0, n);
 }
+strongETag = 
HexUtils.toHexString(digest.digest());
+} catch (Exception e) {
+strongETag = getETag();
 }
-} catch (IOException e) {
-strongETag = getETag();
 }
 } else {
 strongETag = getETag();
diff --git a/java/org/apache/catalina/webresources/CachedResource.java 
b/java/org/apache/catalina/webresources/CachedResource.java
index 74fa278d20..5c25c1fb81 100644
--- a/java/org/apache/catalina/webresources/CachedResource.java
+++ b/java/org/apache/catalina/webresources/CachedResource.java
@@ -39,7 +39,9 @@ import org.apache.catalina.WebResource;
 import org.apache.catalina.WebResourceRoot;
 impor

[Bug 69466] New: Content-Length removal from HEAD response should not be mandatory

2024-11-20 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69466

Bug ID: 69466
   Summary: Content-Length removal from HEAD response should not
be mandatory
   Product: Tomcat 10
   Version: 10.1.33
  Hardware: PC
OS: All
Status: NEW
  Severity: normal
  Priority: P2
 Component: Catalina
  Assignee: dev@tomcat.apache.org
  Reporter: kevin+bugzi...@leturc.fr
  Target Milestone: --

The Content-Length header was removed from HEAD response within
https://bz.apache.org/bugzilla/show_bug.cgi?id=69379 but as per the two
mentioned RFCs, this header is not forbidden, it could be present in a HEAD
response.

In RFC 9110, the section 8.6
(https://www.rfc-editor.org/rfc/rfc9110.html#section-8.6) or section 9.3.2
(https://www.rfc-editor.org/rfc/rfc9110.html#section-9.3.2) don't forbid the
Content-Length header.
Section 8.6:
```
A server MAY send a Content-Length header field in a response to a HEAD request
(Section 9.3.2); a server MUST NOT send Content-Length in such a response
unless its field value equals the decimal number of octets that would have been
sent in the content of a response if the same request had used the GET method.
```
Section 9.3.2:
```
However, a server MAY omit header fields for which a value is determined only
while generating the content.
```

This is also the case in RFC 7231 under section 4.3.2
(https://datatracker.ietf.org/doc/html/rfc7231#section-4.3.2)
```
   The HEAD method is identical to GET except that the server MUST NOT
   send a message body in the response (i.e., the response terminates at
   the end of the header section).  The server SHOULD send the same
   header fields in response to a HEAD request as it would have sent if
   the request had been a GET, except that the payload header fields
   (Section 3.3) MAY be omitted
```
The RFC 7231 references the section 3.3 of RFC 7230
(https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.2) which doesn't
forbid the header:
```
   A server MAY send a Content-Length header field in a response to a
   HEAD request (Section 4.3.2 of [RFC7231]); a server MUST NOT send
   Content-Length in such a response unless its field-value equals the
   decimal number of octets that would have been sent in the payload
   body of a response if the same request had used the GET method.
```

In our application we are able to send the Content-Length header for a HEAD
request without computing any content, the value is stored in the same location
than the requested object.

With the recent fix in the Tomcat processor, we are unable to send such header
in a HEAD response.
Would it be possible to allow the Content-Length header if the value is greater
than 0? Or add a configuration parameter to permit such behavior as the RFC
allows it?

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



Buildbot failure in on tomcat-9.0.x

2024-11-20 Thread buildbot
Build status: BUILD FAILED: failed compile (failure)
Worker used: bb_worker2_ubuntu
URL: https://ci2.apache.org/#builders/37/builds/1178
Blamelist: remm 
Build Text: failed compile (failure)
Status Detected: new failure
Build Source Stamp: [branch 9.0.x] 64afed85707a37309c77abdd1e91b8988acc3438


Steps:

  worker_preparation: 0

  git: 0

  shell: 0

  shell_1: 0

  shell_2: 0

  shell_3: 0

  shell_4: 0

  shell_5: 0

  compile: 1

  shell_6: 0

  shell_7: 0

  shell_8: 0

  shell_9: 0

  Rsync docs to nightlies.apache.org: 0

  shell_10: 0

  Rsync RAT to nightlies.apache.org: 0

  compile_1: 2

  shell_11: 0

  Rsync Logs to nightlies.apache.org: 0


-- ASF Buildbot


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



(tomcat) branch main updated: Fix IDE warning

2024-11-20 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 8adbc34f5e Fix IDE warning
8adbc34f5e is described below

commit 8adbc34f5eb871a7fd9bd886e8b10aac15de0030
Author: Mark Thomas 
AuthorDate: Wed Nov 20 17:27:37 2024 +

Fix IDE warning
---
 java/org/apache/catalina/manager/StatusTransformer.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/manager/StatusTransformer.java 
b/java/org/apache/catalina/manager/StatusTransformer.java
index b5a1d2963f..903d880347 100644
--- a/java/org/apache/catalina/manager/StatusTransformer.java
+++ b/java/org/apache/catalina/manager/StatusTransformer.java
@@ -836,7 +836,7 @@ public class StatusTransformer {
 indent(writer, 2).append('{').println();
 appendJSonValue(indent(writer, 3), "name", 
JSONFilter.escape(JSONFilter.escape(name))).append(',');
 appendJSonValue(writer, "startTime",
-new Date(((Long) mBeanServer.getAttribute(objectName, 
"startTime"))).toString())
+new Date(((Long) mBeanServer.getAttribute(objectName, 
"startTime")).longValue()).toString())
 .append(',');
 appendJSonValue(writer, "startupTime", 
mBeanServer.getAttribute(objectName, "startupTime"))
 .append(',');


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



(tomcat) branch main updated: Remove unnecessary code

2024-11-20 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 6620a894f5 Remove unnecessary code
6620a894f5 is described below

commit 6620a894f5aa2dfb371d8a73514e33b9b817cf15
Author: Mark Thomas 
AuthorDate: Wed Nov 20 17:31:19 2024 +

Remove unnecessary code
---
 java/org/apache/catalina/servlets/DefaultServlet.java | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/catalina/servlets/DefaultServlet.java 
b/java/org/apache/catalina/servlets/DefaultServlet.java
index 6a4826e7e5..26a3a1daea 100644
--- a/java/org/apache/catalina/servlets/DefaultServlet.java
+++ b/java/org/apache/catalina/servlets/DefaultServlet.java
@@ -1715,7 +1715,7 @@ public class DefaultServlet extends HttpServlet {
 sb.append("\r\n");
 
 SortManager.Order order;
-if (sortListings && null != request) {
+if (sortListings) {
 order = sortManager.getOrder(request.getQueryString());
 } else {
 order = null;
@@ -1724,7 +1724,7 @@ public class DefaultServlet extends HttpServlet {
 sb.append("\r\n");
 sb.append("\r\n");
 sb.append("");
-if (sortListings && null != request) {
+if (sortListings) {
 sb.append("");
@@ -1735,7 +1735,7 @@ public class DefaultServlet extends HttpServlet {
 }
 sb.append("\r\n");
 sb.append("");
-if (sortListings && null != request) {
+if (sortListings) {
 sb.append("");
@@ -1746,7 +1746,7 @@ public class DefaultServlet extends HttpServlet {
 }
 sb.append("\r\n");
 sb.append("");
-if (sortListings && null != request) {
+if (sortListings) {
 sb.append("");
@@ -1759,7 +1759,7 @@ public class DefaultServlet extends HttpServlet {
 sb.append("\r\n");
 sb.append("\r\n");
 
-if (null != sortManager && null != request) {
+if (null != sortManager) {
 sortManager.sort(entries, request.getQueryString());
 }
 


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



(tomcat) 01/02: Fix IDE warning

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

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

commit 3472b480dbbdfb42eb5b59c5ac248fe18b572085
Author: Mark Thomas 
AuthorDate: Wed Nov 20 17:27:37 2024 +

Fix IDE warning
---
 java/org/apache/catalina/manager/StatusTransformer.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/manager/StatusTransformer.java 
b/java/org/apache/catalina/manager/StatusTransformer.java
index b5a1d2963f..903d880347 100644
--- a/java/org/apache/catalina/manager/StatusTransformer.java
+++ b/java/org/apache/catalina/manager/StatusTransformer.java
@@ -836,7 +836,7 @@ public class StatusTransformer {
 indent(writer, 2).append('{').println();
 appendJSonValue(indent(writer, 3), "name", 
JSONFilter.escape(JSONFilter.escape(name))).append(',');
 appendJSonValue(writer, "startTime",
-new Date(((Long) mBeanServer.getAttribute(objectName, 
"startTime"))).toString())
+new Date(((Long) mBeanServer.getAttribute(objectName, 
"startTime")).longValue()).toString())
 .append(',');
 appendJSonValue(writer, "startupTime", 
mBeanServer.getAttribute(objectName, "startupTime"))
 .append(',');


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



(tomcat) 02/02: Remove unnecessary code

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

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

commit 4d05c686120f4cab78392db6fb8d7ae375efe029
Author: Mark Thomas 
AuthorDate: Wed Nov 20 17:31:19 2024 +

Remove unnecessary code
---
 java/org/apache/catalina/servlets/DefaultServlet.java | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/catalina/servlets/DefaultServlet.java 
b/java/org/apache/catalina/servlets/DefaultServlet.java
index 6a4826e7e5..26a3a1daea 100644
--- a/java/org/apache/catalina/servlets/DefaultServlet.java
+++ b/java/org/apache/catalina/servlets/DefaultServlet.java
@@ -1715,7 +1715,7 @@ public class DefaultServlet extends HttpServlet {
 sb.append("\r\n");
 
 SortManager.Order order;
-if (sortListings && null != request) {
+if (sortListings) {
 order = sortManager.getOrder(request.getQueryString());
 } else {
 order = null;
@@ -1724,7 +1724,7 @@ public class DefaultServlet extends HttpServlet {
 sb.append("\r\n");
 sb.append("\r\n");
 sb.append("");
-if (sortListings && null != request) {
+if (sortListings) {
 sb.append("");
@@ -1735,7 +1735,7 @@ public class DefaultServlet extends HttpServlet {
 }
 sb.append("\r\n");
 sb.append("");
-if (sortListings && null != request) {
+if (sortListings) {
 sb.append("");
@@ -1746,7 +1746,7 @@ public class DefaultServlet extends HttpServlet {
 }
 sb.append("\r\n");
 sb.append("");
-if (sortListings && null != request) {
+if (sortListings) {
 sb.append("");
@@ -1759,7 +1759,7 @@ public class DefaultServlet extends HttpServlet {
 sb.append("\r\n");
 sb.append("\r\n");
 
-if (null != sortManager && null != request) {
+if (null != sortManager) {
 sortManager.sort(entries, request.getQueryString());
 }
 


-
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 (7096cbc6a6 -> 4d05c68612)

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

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


from 7096cbc6a6 Use client locale for directory listings
 new 3472b480db Fix IDE warning
 new 4d05c68612 Remove unnecessary code

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


Summary of changes:
 java/org/apache/catalina/manager/StatusTransformer.java |  2 +-
 java/org/apache/catalina/servlets/DefaultServlet.java   | 10 +-
 2 files changed, 6 insertions(+), 6 deletions(-)


-
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 (c600f62e1d -> ce525420ef)

2024-11-20 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 c600f62e1d Use client locale for directory listings
 new 0616196b20 Fix IDE warning
 new ce525420ef Remove unnecessary code

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


Summary of changes:
 java/org/apache/catalina/manager/StatusTransformer.java |  2 +-
 java/org/apache/catalina/servlets/DefaultServlet.java   | 10 +-
 2 files changed, 6 insertions(+), 6 deletions(-)


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



(tomcat) branch 9.0.x updated: Fix back-port

2024-11-20 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 7a34111b6a Fix back-port
7a34111b6a is described below

commit 7a34111b6aa386105fd0da823a585793463b3f5a
Author: Mark Thomas 
AuthorDate: Wed Nov 20 17:35:43 2024 +

Fix back-port
---
 java/org/apache/catalina/servlets/DefaultServlet.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/servlets/DefaultServlet.java 
b/java/org/apache/catalina/servlets/DefaultServlet.java
index 8b65544c90..28d54bab07 100644
--- a/java/org/apache/catalina/servlets/DefaultServlet.java
+++ b/java/org/apache/catalina/servlets/DefaultServlet.java
@@ -1748,7 +1748,7 @@ public class DefaultServlet extends HttpServlet {
 StringBuilder sb = new StringBuilder();
 
 // Get the right strings
-StringManager sm = 
StringManager.getManager(DefaultServlet.class.getPackageName(), 
request.getLocales());
+StringManager sm = 
StringManager.getManager(DefaultServlet.class.getPackage().getName(), 
request.getLocales());
 
 String directoryWebappPath = resource.getWebappPath();
 WebResource[] entries = resources.listResources(directoryWebappPath);


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



[Bug 69465] New: [GraalVM 21] Fix warnings during native image compilation

2024-11-20 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69465

Bug ID: 69465
   Summary: [GraalVM 21] Fix warnings during native image
compilation
   Product: Tomcat 10
   Version: 10.1.31
  Hardware: PC
OS: Linux
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: Packaging
  Assignee: dev@tomcat.apache.org
  Reporter: maxim.kovale...@hotcode.lv
  Target Milestone: --

Getting warnings during native image compilation when tomcat-embed-core,
tomcat-embed-el and tomcat-embed-websocket are included as dependencies in
GraalVM Native image builds:

```
# Warning: The option
'-H:ReflectionConfigurationResources=META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-websocket/tomcat-reflection.json'
is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in
the future.
# Warning: The option
'-H:ReflectionConfigurationResources=META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-el/tomcat-reflection.json'
is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in
the future.
# Warning: The option
'-H:ResourceConfigurationResources=META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-core/tomcat-resource.json'
is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in
the future.
# Warning: The option
'-H:ReflectionConfigurationResources=META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-core/tomcat-reflection.json'
is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in
the future.
# Warning: The option
'-H:IncludeResources=rabbitmq-amqp-client.properties|version.properties' is
experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the
future.
# Warning: The option
'-H:ResourceConfigurationResources=META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-el/tomcat-resource.json'
is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in
the future.
# Warning: The option
'-H:ResourceConfigurationResources=META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-websocket/tomcat-resource.json'
is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in
the future.
```

Building native image with Tomcat should succeed without warnings.

More details:
JDK: GraalVM 21.0.5+9.1
spring-boot:3.3.5
tomcat-embed-core:10.1.31
tomcat-embed-el:10.1.31
tomcat-embed-websocket:10.1.31

You can check the same fix in netty, micrometer and quarkus:
https://github.com/netty/netty/issues/13595
https://github.com/micrometer-metrics/micrometer/issues/4316
https://github.com/quarkusio/quarkus/issues/35788
https://github.com/oracle/graal/issues/7105

-- 
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 69468] New: Uploaded file is corrupted when using HTTP 2 and JSSE

2024-11-20 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69468

Bug ID: 69468
   Summary: Uploaded file is corrupted when using HTTP 2 and JSSE
   Product: Tomcat 10
   Version: 10.1.33
  Hardware: PC
Status: NEW
  Severity: normal
  Priority: P2
 Component: Catalina
  Assignee: dev@tomcat.apache.org
  Reporter: jiri.tr...@cloverdx.com
  Target Milestone: --

Created attachment 39942
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=39942&action=edit
Example application

Upload of a larger file via multipart HTML form can corrupt uploaded file in
case Tomcat is configured to use SSL connector with HTTP 2 and the native
library is disabled. This error depends on which web browser is used.

How to reproduce:

1) Configure Tomcat to used SSL

I used self signed certificate in a JKS file. In server.xml enable ssl
connector with HTTP 2 protocol.


  
   
  
   


and remove line with "AprLifecycleListener" from it.

2) Use attached application on url https://localhost:8443/TestUpload

3) Upload larger file

The file will be stored in %CATALINA_HOME%\webapps\TestUpload
I used zip file with 6MB jar in it and the zip was damaged. But you can also
create larger text file and compare contents.

4) Use different browsers.

When I used Chrome and Edge the file was corrupted. Firefox froze. But when I
used Waterfox the problem newer happened.

The problem newer happens when Apache Tomcat Native library is enabled.
The problem newer happens when HTTP 2 is disabled.

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