martin-g commented on a change in pull request #352:
URL: https://github.com/apache/tomcat/pull/352#discussion_r489294641



##########
File path: java/org/apache/catalina/webresources/AbstractArchiveResourceSet.java
##########
@@ -211,6 +216,50 @@ public final WebResource getResource(String path) {
         String webAppMount = getWebAppMount();
         WebResourceRoot root = getRoot();
 
+
+        /*
+         * This initializes (when necessary) and checks the jarContents, which
+         * is a highly efficient index of the files stored in the jar. If
+         * jarContents reports that this resource definitely does not contain
+         * the path, we can end this method and move on to the next jar.
+         *
+         * Note: the initialization is thread-safe because multiple 
simultaneous
+         * threads will create a complete and valid copy, then set the shared
+         * pointer. This guarantees the shared pointer will always go to a
+         * valid object. The cost of multiple copies is small since only one of
+         * them will be long-lived.
+         */
+        try {
+            if ((root.getContext() != null) && (root.getContext().getParent()) 
!= null &&
+                    (((Host) 
root.getContext().getParent()).getFastClasspathScanning())) {
+
+                if (jarContents == null ||
+                        ((System.currentTimeMillis() - prevJarOpenTime > 
jarRefreshTime))) {
+
+                    if (!openJarFile().equals(jar)) {
+                        try {
+                            jar = openJarFile();
+                            jarContents = new JarContents(jar);
+                            prevJarOpenTime = System.currentTimeMillis();
+                            closeJarFile();
+                        } catch (IOException ioe) {
+                            throw new RuntimeException("Unable to parse 
contents of JAR", ioe);
+                        } finally {
+                            closeJarFile();
+                        }
+                    } else {
+                        closeJarFile();
+                    }
+                }
+                if (!jarContents.mightContainResource(path, webAppMount)) {
+                    return new EmptyResource(root, path);
+                }
+            }
+        } catch (Exception e) {
+            // Do nothing

Review comment:
       why nothing ? 
   IMO it should be logged as WARNING, or at least DEBUG




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

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

Reply via email to