You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/09/27 20:55:47 UTC

[tomcat] branch 10.0.x updated (e85bd81 -> 0ce225b)

This is an automated email from the ASF dual-hosted git repository.

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


    from e85bd81  Close WebConnection
     new 31d6242  Close WebConnection
     new 0ce225b  Fix BZ 65586 - Correct bloom filter lookups for directories with final /

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:
 .../apache/catalina/webresources/JarContents.java  | 17 ++++++++--
 ...et.java => TestAbstractArchiveResourceSet.java} | 37 +++++++++-------------
 .../webresources/TesterWebResourceRoot.java        |  3 +-
 test/org/apache/tomcat/unittest/TesterContext.java |  9 ++++--
 webapps/docs/changelog.xml                         | 14 ++++++++
 5 files changed, 53 insertions(+), 27 deletions(-)
 copy test/org/apache/catalina/webresources/{TestJarWarResourceSet.java => TestAbstractArchiveResourceSet.java} (51%)

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


[tomcat] 02/02: Fix BZ 65586 - Correct bloom filter lookups for directories with final /

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 0ce225b3c58120ffbe6ee87dfeec6865bb63de99
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Sep 27 21:38:49 2021 +0100

    Fix BZ 65586 - Correct bloom filter lookups for directories with final /
    
    https://bz.apache.org/bugzilla/show_bug.cgi?id=65586
---
 .../apache/catalina/webresources/JarContents.java  | 17 +++++++-
 .../TestAbstractArchiveResourceSet.java            | 49 ++++++++++++++++++++++
 .../webresources/TesterWebResourceRoot.java        |  3 +-
 test/org/apache/tomcat/unittest/TesterContext.java |  9 +++-
 webapps/docs/changelog.xml                         |  6 +++
 5 files changed, 79 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/catalina/webresources/JarContents.java b/java/org/apache/catalina/webresources/JarContents.java
index c7da5e2..0afa9fa 100644
--- a/java/org/apache/catalina/webresources/JarContents.java
+++ b/java/org/apache/catalina/webresources/JarContents.java
@@ -78,6 +78,16 @@ public final class JarContents {
 
             bits1.set(pathHash1 % TABLE_SIZE);
             bits2.set(pathHash2 % TABLE_SIZE);
+
+            // While directory entry names always end in "/", application code
+            // may look them up without the trailing "/". Add this second form.
+            if (entry.isDirectory()) {
+                pathHash1 = hashcode(name, startPos, name.length() - 1, HASH_PRIME_1);
+                pathHash2 = hashcode(name, startPos, name.length() - 1, HASH_PRIME_2);
+
+                bits1.set(pathHash1 % TABLE_SIZE);
+                bits2.set(pathHash2 % TABLE_SIZE);
+            }
         }
     }
 
@@ -92,9 +102,12 @@ public final class JarContents {
      * @return hashcode of the range.
      */
     private int hashcode(String content, int startPos, int hashPrime) {
+        return hashcode(content, startPos, content.length(), hashPrime);
+    }
+
+    private int hashcode(String content, int startPos, int endPos, int hashPrime) {
         int h = hashPrime/2;
-        int contentLength = content.length();
-        for (int i = startPos; i < contentLength; i++) {
+        for (int i = startPos; i < endPos; i++) {
             h = hashPrime * h + content.charAt(i);
         }
 
diff --git a/test/org/apache/catalina/webresources/TestAbstractArchiveResourceSet.java b/test/org/apache/catalina/webresources/TestAbstractArchiveResourceSet.java
new file mode 100644
index 0000000..7c5b2f2
--- /dev/null
+++ b/test/org/apache/catalina/webresources/TestAbstractArchiveResourceSet.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.webresources;
+
+import java.io.File;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.catalina.WebResource;
+import org.apache.catalina.WebResourceRoot;
+
+public class TestAbstractArchiveResourceSet {
+
+    /*
+     * https://bz.apache.org/bugzilla/show_bug.cgi?id=65586
+     */
+    @Test
+    public void testBloomFilterWithDirectory() {
+        WebResourceRoot root = new TesterWebResourceRoot();
+
+        root.getContext().setUseBloomFilterForArchives(true);
+
+        File file = new File("webapps/examples/WEB-INF/lib/taglibs-standard-impl-1.2.5-migrated-0.0.1.jar");
+
+        JarResourceSet jarResourceSet = new JarResourceSet(root, "/WEB-INF/classes", file.getAbsolutePath(), "/");
+        jarResourceSet.getArchiveEntries(false);
+
+        WebResource r1 = jarResourceSet.getResource("/WEB-INF/classes/org/");
+        Assert.assertTrue(r1.isDirectory());
+
+        WebResource r2 = jarResourceSet.getResource("/WEB-INF/classes/org");
+        Assert.assertTrue(r2.isDirectory());
+    }
+}
diff --git a/test/org/apache/catalina/webresources/TesterWebResourceRoot.java b/test/org/apache/catalina/webresources/TesterWebResourceRoot.java
index 6217f26..a56186e 100644
--- a/test/org/apache/catalina/webresources/TesterWebResourceRoot.java
+++ b/test/org/apache/catalina/webresources/TesterWebResourceRoot.java
@@ -80,9 +80,10 @@ public class TesterWebResourceRoot extends StandardRoot {
         return null;
     }
 
+    Context context = new TesterContext();
     @Override
     public Context getContext() {
-        return new TesterContext();
+        return context;
     }
 
     @Override
diff --git a/test/org/apache/tomcat/unittest/TesterContext.java b/test/org/apache/tomcat/unittest/TesterContext.java
index 7164bcc..b0c624b 100644
--- a/test/org/apache/tomcat/unittest/TesterContext.java
+++ b/test/org/apache/tomcat/unittest/TesterContext.java
@@ -1306,10 +1306,15 @@ public class TesterContext implements Context {
     @Override
     public void setParallelAnnotationScanning(boolean parallelAnnotationScanning) {}
 
+    boolean useBloomFilterForArchives = false;
     @Override
-    public boolean getUseBloomFilterForArchives() { return false; }
+    public boolean getUseBloomFilterForArchives() {
+        return useBloomFilterForArchives;
+    }
 
     @Override
-    public void setUseBloomFilterForArchives(boolean useBloomFilterForArchives) {}
+    public void setUseBloomFilterForArchives(boolean useBloomFilterForArchives) {
+        this.useBloomFilterForArchives = useBloomFilterForArchives;
+    }
 
 }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 831259f..e04d87f 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -115,6 +115,12 @@
         Fix delete then create object manipulations with
         <code>DataSourceUserDatabase</code>. (remm)
       </fix>
+      <fix>
+        <bug>65586</bug>: Fix the bloom filter used to improve performance of
+        archive file look ups in the web resources implementation so it works
+        correctly for directory lookups whether or not the provided directory
+        name includes the trailing <code>/</code>. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">

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


[tomcat] 01/02: Close WebConnection

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 31d62426645824bdfe076a0c0eafa904d90b4fb9
Author: remm <re...@apache.org>
AuthorDate: Mon Sep 27 20:34:18 2021 +0200

    Close WebConnection
    
    The internal upgrade handler should close the associated WebConnection
    on destroy.
---
 webapps/docs/changelog.xml | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 5e19b56..831259f 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -168,6 +168,14 @@
       </fix>
     </changelog>
   </subsection>
+  <subsection name="WebSocket">
+    <changelog>
+      <fix>
+        The internal upgrade handler should close the associated
+        <code>WebConnection</code> on destroy. (remm)
+      </fix>
+    </changelog>
+  </subsection>
   <subsection name="Web applications">
     <changelog>
       <fix>

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