You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2026/07/24 11:48:20 UTC
(myfaces) branch main updated: [perf] improve standard perf
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/myfaces.git
The following commit(s) were added to refs/heads/main by this push:
new 77194f159 [perf] improve standard perf
77194f159 is described below
commit 77194f159a869b566b7f1bf5f972e2f0a245aee2
Author: tandraschko <ta...@apache.org>
AuthorDate: Fri Jul 24 13:48:13 2026 +0200
[perf] improve standard perf
---
.../config/DefaultFacesConfigResourceProvider.java | 35 ++--
.../myfaces/config/MetaInfResourceCache.java | 91 ++++++++++
.../config/impl/FacesConfigUnmarshallerImpl.java | 63 ++++---
.../DefaultResourceLibraryContractsProvider.java | 23 ++-
.../DefaultFaceletConfigResourceProvider.java | 27 +--
.../myfaces/view/facelets/util/Classpath.java | 187 ++++++++++++++++++++-
6 files changed, 362 insertions(+), 64 deletions(-)
diff --git a/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigResourceProvider.java b/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigResourceProvider.java
index 7bb92cca7..0d8fa7a47 100644
--- a/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigResourceProvider.java
+++ b/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigResourceProvider.java
@@ -22,27 +22,22 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import jakarta.faces.context.ExternalContext;
-import org.apache.myfaces.util.lang.ClassUtils;
import org.apache.myfaces.spi.FacesConfigResourceProvider;
-import org.apache.myfaces.view.facelets.util.Classpath;
/**
- *
+ *
* @since 2.0.2
* @author Leonardo Uribe
*/
public class DefaultFacesConfigResourceProvider extends FacesConfigResourceProvider
{
- private static final String META_INF_PREFIX = "META-INF/";
-
private static final String FACES_CONFIG_SUFFIX = ".faces-config.xml";
-
+
/**
* <p>Resource path used to acquire implicit resources buried
* inside application JARs.</p>
@@ -59,21 +54,23 @@ public DefaultFacesConfigResourceProvider()
public Collection<URL> getMetaInfConfigurationResources(ExternalContext context) throws IOException
{
List<URL> urlSet = new ArrayList<>();
-
- ClassLoader cl = ClassUtils.getCurrentLoader(this);
-
- //This usually happens when maven-jetty-plugin is used
- //Scan jars looking for paths including META-INF/faces-config.xml
- Enumeration<URL> resources = cl.getResources(FACES_CONFIG_IMPLICIT);
- while (resources.hasMoreElements())
+
+ // Filter the shared, cached META-INF/ name scan instead of walking every jar again:
+ // - META-INF/faces-config.xml (the standard implicit name), and
+ // - META-INF/*.faces-config.xml (custom names, e.g. maven-jetty-plugin layouts).
+ // Only the handful of matches are resolved to URLs via getResources (as before).
+ ClassLoader loader = MetaInfResourceCache.getClassLoader();
+ for (String name : MetaInfResourceCache.getMetaInfEntryNames(context))
{
- urlSet.add(resources.nextElement());
+ if (name.equals(FACES_CONFIG_IMPLICIT) || name.endsWith(FACES_CONFIG_SUFFIX))
+ {
+ for (Enumeration<URL> resources = loader.getResources(name); resources.hasMoreElements();)
+ {
+ urlSet.add(resources.nextElement());
+ }
+ }
}
- //Scan files inside META-INF ending with .faces-config.xml
- URL[] urls = Classpath.search(cl, META_INF_PREFIX, FACES_CONFIG_SUFFIX);
- Collections.addAll(urlSet, urls);
-
return urlSet;
}
}
diff --git a/impl/src/main/java/org/apache/myfaces/config/MetaInfResourceCache.java b/impl/src/main/java/org/apache/myfaces/config/MetaInfResourceCache.java
new file mode 100644
index 000000000..7c011b3a5
--- /dev/null
+++ b/impl/src/main/java/org/apache/myfaces/config/MetaInfResourceCache.java
@@ -0,0 +1,91 @@
+/*
+ * 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.myfaces.config;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+
+import jakarta.faces.FacesException;
+import jakarta.faces.context.ExternalContext;
+
+import org.apache.myfaces.util.lang.ClassUtils;
+import org.apache.myfaces.view.facelets.util.Classpath;
+
+/**
+ * Caches, per web application, the names of all classpath resource entries under {@code META-INF/}
+ * found in a single scan.
+ *
+ * <p>At startup several independent providers each scan {@code META-INF/} for a different suffix
+ * ({@code *.faces-config.xml}, {@code *.taglib.xml}, {@code contracts/.../jakarta.faces.contract.xml}).
+ * Each scan opens and fully enumerates every jar on the classpath, so doing the walk once and letting
+ * the providers filter the shared name set by suffix avoids walking every jar multiple times. Only the
+ * few matching names are then resolved to URLs via {@link ClassLoader#getResources(String)} (which is
+ * what the providers did previously anyway). The cache lives in the {@link ExternalContext} application
+ * map, so it is scoped to the web application and released on undeploy - no static state.</p>
+ */
+public final class MetaInfResourceCache
+{
+ public static final String META_INF_PREFIX = "META-INF/";
+
+ private static final String CACHE_KEY = MetaInfResourceCache.class.getName() + ".META_INF_NAMES";
+
+ private MetaInfResourceCache()
+ {
+ }
+
+ /**
+ * Returns the names of all classpath resource entries under {@code META-INF/}, scanning the
+ * classpath once per web application and caching the result. Callers filter the returned names by
+ * suffix and resolve matches via {@link ClassLoader#getResources(String)}.
+ */
+ @SuppressWarnings("unchecked")
+ public static Set<String> getMetaInfEntryNames(ExternalContext externalContext)
+ {
+ Map<String, Object> applicationMap = externalContext.getApplicationMap();
+ Set<String> names = (Set<String>) applicationMap.get(CACHE_KEY);
+ if (names == null)
+ {
+ try
+ {
+ names = Classpath.searchResourceNames(getClassLoader(), META_INF_PREFIX);
+ }
+ catch (IOException e)
+ {
+ throw new FacesException(e);
+ }
+ applicationMap.put(CACHE_KEY, names);
+ }
+ return names;
+ }
+
+ /**
+ * The classloader used both to scan and (by the providers) to resolve matches, kept consistent so
+ * the cached names line up with what {@link ClassLoader#getResources(String)} will return.
+ */
+ public static ClassLoader getClassLoader()
+ {
+ ClassLoader loader = ClassUtils.getContextClassLoader();
+ if (loader == null)
+ {
+ loader = MetaInfResourceCache.class.getClassLoader();
+ }
+ return loader;
+ }
+}
diff --git a/impl/src/main/java/org/apache/myfaces/config/impl/FacesConfigUnmarshallerImpl.java b/impl/src/main/java/org/apache/myfaces/config/impl/FacesConfigUnmarshallerImpl.java
index 8fbb9cc63..6520f838e 100755
--- a/impl/src/main/java/org/apache/myfaces/config/impl/FacesConfigUnmarshallerImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/config/impl/FacesConfigUnmarshallerImpl.java
@@ -79,6 +79,14 @@ public class FacesConfigUnmarshallerImpl implements FacesConfigUnmarshaller<Face
{
private static final Logger log = Logger.getLogger(FacesConfigUnmarshallerImpl.class.getName());
+ /**
+ * Shared, immutably-configured factory reused across all faces-config parses to skip the
+ * JAXP provider lookup ({@link DocumentBuilderFactory#newInstance()}) on every startup file.
+ * Access to {@link DocumentBuilderFactory#newDocumentBuilder()} is synchronized on this
+ * instance since the factory is not guaranteed thread-safe.
+ */
+ private static final DocumentBuilderFactory FACTORY = createFactory();
+
private ExternalContext externalContext;
public FacesConfigUnmarshallerImpl(ExternalContext externalContext)
@@ -86,6 +94,29 @@ public FacesConfigUnmarshallerImpl(ExternalContext externalContext)
this.externalContext = externalContext;
}
+ private static DocumentBuilderFactory createFactory()
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setValidating(false);
+ factory.setNamespaceAware(true);
+
+ try
+ {
+ factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+ factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
+ factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+ factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+ factory.setXIncludeAware(false);
+ factory.setExpandEntityReferences(false);
+ }
+ catch (Throwable e)
+ {
+ log.log(Level.WARNING, "DocumentBuilderFactory#setFeature not implemented. Skipping...", e);
+ }
+
+ return factory;
+ }
+
@Override
public FacesConfigImpl getFacesConfig(String s) throws IOException, SAXException
{
@@ -100,25 +131,16 @@ public FacesConfigImpl getFacesConfig(InputStream in, String systemId) throws IO
try
{
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setValidating(false);
- factory.setNamespaceAware(true);
-
- try
- {
- factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
- factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
- factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
- factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
- factory.setXIncludeAware(false);
- factory.setExpandEntityReferences(false);
- }
- catch (Throwable e)
+ // The factory is configured identically for every faces-config, so build it once and
+ // reuse it to avoid the JAXP provider lookup (DocumentBuilderFactory#newInstance) on
+ // every file parsed at startup. newDocumentBuilder() is still called per parse.
+ DocumentBuilderFactory factory = FACTORY;
+
+ DocumentBuilder builder;
+ synchronized (factory)
{
- log.log(Level.WARNING, "DocumentBuilderFactory#setFeature not implemented. Skipping...", e);
+ builder = factory.newDocumentBuilder();
}
-
- DocumentBuilder builder = factory.newDocumentBuilder();
builder.setEntityResolver(new FacesConfigEntityResolver(externalContext));
Document document;
if (systemId == null)
@@ -129,8 +151,11 @@ public FacesConfigImpl getFacesConfig(InputStream in, String systemId) throws IO
{
document = builder.parse(in, systemId);
}
- document.getDocumentElement().normalize();
-
+ // Note: intentionally no Element#normalize() here. Text is always read via
+ // Node#getTextContent() (see getTextContent()), which concatenates all descendant
+ // text regardless of whether adjacent text nodes were coalesced, so normalizing the
+ // whole document tree would only add a full-tree walk at startup with no effect.
+
onAttribute("metadata-complete", document.getDocumentElement(),
(v) -> { facesConfig.setMetadataComplete(v); });
onAttribute("version", document.getDocumentElement(),
diff --git a/impl/src/main/java/org/apache/myfaces/resource/DefaultResourceLibraryContractsProvider.java b/impl/src/main/java/org/apache/myfaces/resource/DefaultResourceLibraryContractsProvider.java
index f2475a0bc..d13e889e5 100644
--- a/impl/src/main/java/org/apache/myfaces/resource/DefaultResourceLibraryContractsProvider.java
+++ b/impl/src/main/java/org/apache/myfaces/resource/DefaultResourceLibraryContractsProvider.java
@@ -19,15 +19,13 @@
package org.apache.myfaces.resource;
import java.io.IOException;
-import java.net.URL;
import java.util.HashSet;
import java.util.Set;
import jakarta.faces.application.ResourceHandler;
import jakarta.faces.context.ExternalContext;
-import org.apache.myfaces.util.lang.ClassUtils;
+import org.apache.myfaces.config.MetaInfResourceCache;
import org.apache.myfaces.util.WebConfigParamUtils;
import org.apache.myfaces.spi.ResourceLibraryContractsProvider;
-import org.apache.myfaces.view.facelets.util.Classpath;
/**
*
@@ -78,17 +76,18 @@ public Set<String> getClassloaderResourceLibraryContracts(ExternalContext contex
{
Set<String> contracts = new HashSet<>();
- URL[] urls = Classpath.search(ClassUtils.getCurrentLoader(this),
- META_INF_CONTRACTS_PREFIX,
- META_INF_CONTRACTS_SUFFIX);
- for (int i = 0; i < urls.length; i++)
+ // Reuse the shared cached META-INF/ name scan and pick entries under META-INF/contracts/ ending
+ // with jakarta.faces.contract.xml, deriving the contract name from the entry path.
+ for (String name : MetaInfResourceCache.getMetaInfEntryNames(context))
{
- String urlString = urls[i].toExternalForm();
- int suffixPos = urlString.lastIndexOf(META_INF_CONTRACTS_FILE);
- int slashPos = urlString.lastIndexOf('/', suffixPos-1);
- if (suffixPos > 0 && slashPos > 0)
+ if (name.startsWith(META_INF_CONTRACTS_PREFIX) && name.endsWith(META_INF_CONTRACTS_SUFFIX))
{
- contracts.add(urlString.substring(slashPos+1, suffixPos));
+ int suffixPos = name.lastIndexOf(META_INF_CONTRACTS_FILE);
+ int slashPos = name.lastIndexOf('/', suffixPos - 1);
+ if (suffixPos > 0 && slashPos > 0)
+ {
+ contracts.add(name.substring(slashPos + 1, suffixPos));
+ }
}
}
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/DefaultFaceletConfigResourceProvider.java b/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/DefaultFaceletConfigResourceProvider.java
index f5e9015bd..888cbedfa 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/DefaultFaceletConfigResourceProvider.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/DefaultFaceletConfigResourceProvider.java
@@ -22,24 +22,21 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
+import java.util.Enumeration;
import java.util.List;
import jakarta.faces.context.ExternalContext;
-import org.apache.myfaces.util.lang.ClassUtils;
+import org.apache.myfaces.config.MetaInfResourceCache;
import org.apache.myfaces.spi.FaceletConfigResourceProvider;
-import org.apache.myfaces.view.facelets.util.Classpath;
/**
- *
+ *
* @since 2.0.2
* @author Leonardo Uribe
*/
public class DefaultFaceletConfigResourceProvider extends FaceletConfigResourceProvider
{
- private static final String META_INF_PREFIX = "META-INF/";
-
private static final String FACELET_TAGLIB_SUFFIX = ".taglib.xml";
public DefaultFaceletConfigResourceProvider()
@@ -52,10 +49,20 @@ public Collection<URL> getFaceletTagLibConfigurationResources(
ExternalContext context) throws IOException
{
List<URL> urlSet = new ArrayList<>();
-
- //Scan files inside META-INF ending with .faces-config.xml
- URL[] urls = Classpath.search(ClassUtils.getCurrentLoader(this), META_INF_PREFIX, FACELET_TAGLIB_SUFFIX);
- Collections.addAll(urlSet, urls);
+
+ // Files inside META-INF ending with .taglib.xml, reusing the shared cached META-INF/ name scan;
+ // only the matches are resolved to URLs via getResources (as before).
+ ClassLoader loader = MetaInfResourceCache.getClassLoader();
+ for (String name : MetaInfResourceCache.getMetaInfEntryNames(context))
+ {
+ if (name.endsWith(FACELET_TAGLIB_SUFFIX))
+ {
+ for (Enumeration<URL> resources = loader.getResources(name); resources.hasMoreElements();)
+ {
+ urlSet.add(resources.nextElement());
+ }
+ }
+ }
return urlSet;
}
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/util/Classpath.java b/impl/src/main/java/org/apache/myfaces/view/facelets/util/Classpath.java
index 7f642da0a..89202fbe8 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/util/Classpath.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/util/Classpath.java
@@ -64,30 +64,209 @@ public static URL[] search(ClassLoader loader, String prefix, String suffix) thr
{
Set<URL> all = new LinkedHashSet<>();
- _searchResource(all, loader, prefix, prefix, suffix);
- _searchResource(all, loader, prefix + "MANIFEST.MF", prefix, suffix);
+ // The two passes below (directory entry + MANIFEST.MF) are both needed because some
+ // classloaders/jars expose only one of them, but for any jar exposed by both we would
+ // otherwise open and fully enumerate its entries twice. Track the jars already scanned
+ // (keyed by the jar file portion of the URL) so each jar is opened and walked only once
+ // per search - startup calls this for every jar on the classpath, several times over.
+ Set<String> scannedJars = new HashSet<>();
+
+ _searchResource(all, loader, prefix, prefix, suffix, scannedJars);
+ _searchResource(all, loader, prefix + "MANIFEST.MF", prefix, suffix, scannedJars);
URL[] urlArray = all.toArray(new URL[all.size()]);
return urlArray;
}
+ /**
+ * Collect, in a single classpath walk, the <em>names</em> of every resource entry whose name
+ * starts with the given {@code prefix} (e.g. {@code "META-INF/"}). Unlike
+ * {@link #search(ClassLoader, String, String)} this neither filters by suffix nor resolves URLs;
+ * it only enumerates jar/directory entries once and returns their names.
+ *
+ * <p>Callers that repeatedly search the same prefix for different suffixes (the startup
+ * config/taglib/contract providers all scan {@code META-INF/}) can walk the classpath once, filter
+ * the returned names by suffix, and resolve the handful of matches via
+ * {@link ClassLoader#getResources(String)} - instead of re-opening and re-enumerating every jar
+ * once per suffix. Keeping only names (not eagerly-built URLs) avoids allocating a URL per entry.</p>
+ */
+ public static Set<String> searchResourceNames(ClassLoader loader, String prefix) throws IOException
+ {
+ Set<String> names = new HashSet<>();
+ Set<String> scannedJars = new HashSet<>();
+
+ _collectResourceNames(names, loader, prefix, prefix, scannedJars);
+ _collectResourceNames(names, loader, prefix + "MANIFEST.MF", prefix, scannedJars);
+
+ return names;
+ }
+
+ private static void _collectResourceNames(Set<String> names, ClassLoader loader, String resource,
+ String prefix, Set<String> scannedJars) throws IOException
+ {
+ for (Enumeration<URL> urls = loader.getResources(resource); urls.hasMoreElements();)
+ {
+ URL url = urls.nextElement();
+
+ String externalForm = url.toExternalForm();
+ int jarSeparator = externalForm.indexOf("!/");
+ String jarKey = jarSeparator != -1 ? externalForm.substring(0, jarSeparator) : null;
+ if (jarKey != null && scannedJars.contains(jarKey))
+ {
+ continue;
+ }
+
+ URLConnection conn = url.openConnection();
+ conn.setUseCaches(false);
+ conn.setDefaultUseCaches(false);
+
+ try (JarFile jar = (conn instanceof JarURLConnection jurlc) ?
+ jurlc.getJarFile() : _getAlternativeJarFile(url))
+ {
+ if (jar != null)
+ {
+ Enumeration<JarEntry> entries = jar.entries();
+ while (entries.hasMoreElements())
+ {
+ String name = entries.nextElement().getName();
+ if (name.startsWith(prefix))
+ {
+ names.add(name);
+ }
+ }
+ if (jarKey != null)
+ {
+ scannedJars.add(jarKey);
+ }
+ }
+ else
+ {
+ File dir = new File(URLDecoder.decode(url.getFile(), StandardCharsets.UTF_8));
+ if (!_collectDirNames(names, dir, prefix))
+ {
+ _collectNamesFromURL(names, prefix, url);
+ }
+ }
+ }
+ catch (Throwable e)
+ {
+ // See _searchResource: a classloader may report a resource that cannot actually be
+ // opened. Ignore and let the other pass (or other classpath entries) cover it.
+ continue;
+ }
+ }
+ }
+
+ private static boolean _collectDirNames(Set<String> names, File dir, String currentPrefix)
+ {
+ // dir corresponds to `currentPrefix` itself (e.g. .../META-INF for prefix "META-INF/")
+ if (dir.exists() && dir.isDirectory())
+ {
+ File[] files = dir.listFiles();
+ if (files != null)
+ {
+ for (File file : files)
+ {
+ if (file.isDirectory())
+ {
+ _collectDirNames(names, file, currentPrefix + file.getName() + '/');
+ }
+ else
+ {
+ names.add(currentPrefix + file.getName());
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ private static void _collectNamesFromURL(Set<String> names, String prefix, URL url) throws IOException
+ {
+ boolean done = false;
+
+ try (InputStream is = _getInputStream(url))
+ {
+ if (is != null)
+ {
+ try
+ {
+ ZipInputStream zis = (is instanceof ZipInputStream stream) ? stream : new ZipInputStream(is);
+ try
+ {
+ ZipEntry entry = zis.getNextEntry();
+ done = entry != null;
+ while (entry != null)
+ {
+ String entryName = entry.getName();
+ if (entryName.startsWith(prefix))
+ {
+ names.add(entryName);
+ }
+ entry = zis.getNextEntry();
+ }
+ }
+ finally
+ {
+ zis.close();
+ }
+ }
+ catch (Exception ignore)
+ {
+ }
+ }
+ }
+
+ if (!done && prefix.length() > 0)
+ {
+ String urlString = url.toExternalForm() + '/';
+ String[] split = prefix.split("/");
+ String parentPrefix = _join(split, true);
+ String end = _join(split, false);
+ urlString = urlString.substring(0, urlString.lastIndexOf(end));
+ if (isExcludedPrefix(urlString))
+ {
+ return;
+ }
+ _collectNamesFromURL(names, parentPrefix, new URL(urlString));
+ }
+ }
+
private static void _searchResource(Set<URL> result, ClassLoader loader, String resource, String prefix,
- String suffix) throws IOException
+ String suffix, Set<String> scannedJars) throws IOException
{
for (Enumeration<URL> urls = loader.getResources(resource); urls.hasMoreElements();)
{
URL url = urls.nextElement();
+
+ // If this URL points inside a jar we already scanned in a previous pass, skip it:
+ // the jar's entries are identical regardless of which META-INF resource led us here.
+ String externalForm = url.toExternalForm();
+ int jarSeparator = externalForm.indexOf("!/");
+ String jarKey = jarSeparator != -1 ? externalForm.substring(0, jarSeparator) : null;
+ if (jarKey != null && scannedJars.contains(jarKey))
+ {
+ continue;
+ }
+
URLConnection conn = url.openConnection();
conn.setUseCaches(false);
conn.setDefaultUseCaches(false);
- try (JarFile jar = (conn instanceof JarURLConnection jurlc) ?
+ try (JarFile jar = (conn instanceof JarURLConnection jurlc) ?
jurlc.getJarFile() : _getAlternativeJarFile(url))
{
if (jar != null)
{
_searchJar(loader, result, jar, prefix, suffix);
+ // Only mark as scanned once we have actually enumerated it, so that a jar which
+ // fails the directory-entry pass can still be picked up by the MANIFEST.MF pass.
+ if (jarKey != null)
+ {
+ scannedJars.add(jarKey);
+ }
}
else
{