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 e36c1672ca 69528: Add multi-release support to JarContents
e36c1672ca is described below

commit e36c1672caeb593dc05590b3eed0ff8c4a7f754d
Author: remm <r...@apache.org>
AuthorDate: Mon Jan 13 14:53:33 2025 +0100

    69528: Add multi-release support to JarContents
---
 java/org/apache/catalina/webresources/JarContents.java |  14 ++++++++++++++
 .../apache/catalina/webresources/TestJarContents.java  |   3 +++
 test/webresources/dir1.jar                             | Bin 778 -> 1372 bytes
 webapps/docs/changelog.xml                             |   5 +++++
 4 files changed, 22 insertions(+)

diff --git a/java/org/apache/catalina/webresources/JarContents.java 
b/java/org/apache/catalina/webresources/JarContents.java
index e5a5d9d69c..87c0693ea6 100644
--- a/java/org/apache/catalina/webresources/JarContents.java
+++ b/java/org/apache/catalina/webresources/JarContents.java
@@ -67,6 +67,20 @@ public final class JarContents {
                 startPos = 1;
             }
 
+            // Versioned entries should be added to the table according to 
their real name
+            if (name.startsWith("META-INF/versions/", startPos)) {
+                int i = name.indexOf('/', 18 + startPos);
+                if (i > 0) {
+                    int version = Integer.parseInt(name.substring(18 + 
startPos, i));
+                    if (version <= Runtime.version().feature()) {
+                        startPos = i + 1;
+                    }
+                }
+                if (startPos == name.length()) {
+                    continue;
+                }
+            }
+
             // Find the correct table slot
             int pathHash1 = hashcode(name, startPos, HASH_PRIME_1);
             int pathHash2 = hashcode(name, startPos, HASH_PRIME_2);
diff --git a/test/org/apache/catalina/webresources/TestJarContents.java 
b/test/org/apache/catalina/webresources/TestJarContents.java
index 6d55281a53..46434c2f12 100644
--- a/test/org/apache/catalina/webresources/TestJarContents.java
+++ b/test/org/apache/catalina/webresources/TestJarContents.java
@@ -70,6 +70,9 @@ public class TestJarContents {
         Assert.assertTrue(testJarContentsObject.mightContainResource(
                 "d1/d1-f1.txt", jar.getAbsolutePath()));
 
+        Assert.assertTrue(testJarContentsObject.mightContainResource(
+                "f9.txt", jar.getAbsolutePath()));
+
         Assert.assertFalse(testJarContentsObject.mightContainResource(
                 "/d7/d1-f1.txt", jar.getAbsolutePath()));
 
diff --git a/test/webresources/dir1.jar b/test/webresources/dir1.jar
index 1f81af0cec..ec0dee36c0 100644
Binary files a/test/webresources/dir1.jar and b/test/webresources/dir1.jar 
differ
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 39ef8fec4e..e7526c5d14 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -131,6 +131,11 @@
         Fix possible edge cases (such as HTTP/1.0) with trying to detect
         requests without body for WebDAV LOCK and PROPFIND. (remm)
       </fix>
+      <fix>
+        <bug>69528</bug>: Add multi-release JAR support for the
+        <code>bloom</code> <code>archiveIndexStrategy</code> of the
+        <code>Resources</code>. (remm)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">


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

Reply via email to