Skip to content

Commit

Permalink
Fixes #10164 - ensure only valid URIs are added to WebAppClassLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
joakime committed Nov 1, 2023
1 parent 6469f4e commit ad9e358
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.jetty.ee10.webapp.WebAppClassLoader;
import org.eclipse.jetty.ee10.webapp.WebAppContext;
import org.eclipse.jetty.ee10.webapp.WebInfConfiguration;
import org.eclipse.jetty.util.URIUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -59,7 +60,28 @@ public void configure(WebAppContext context) throws Exception
LOG.debug("Setting up classpath ...");
for (URI uri : jwac.getClassPathUris())
{
loader.addClassPath(uri.toASCIIString());
// Not all Resource types supported by Jetty can be supported by WebAppClassLoader
String scheme = uri.getScheme();
if (scheme == null || scheme.equals("file"))
{
// no scheme? or "file" scheme, assume it is just a path.
loader.addClassPath(uri.getPath());
continue;
}

if (scheme.equals("jar"))
{
URI container = URIUtil.unwrapContainer(uri);
if (container.getScheme().equals("file"))
{
// Just add a reference to the
loader.addClassPath(container.getPath());
continue;
}
}

// Anything else is a warning
LOG.warn("Skipping unsupported URI on ClassPath: {}", uri);
}
}

Expand Down

0 comments on commit ad9e358

Please sign in to comment.