From 19596b237e7c95ea840cc58ce31653d4d7e0abe1 Mon Sep 17 00:00:00 2001 From: gregw Date: Wed, 28 Oct 2020 16:12:21 +0100 Subject: [PATCH] Fixes #5521 ResourceCollection list NPE Ensure that dirs passed to addPath end with / so they can be detected as dirs even if they do not exist. --- .../java/org/eclipse/jetty/webapp/MetaInfConfiguration.java | 6 +++--- .../java/org/eclipse/jetty/webapp/WebInfConfiguration.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaInfConfiguration.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaInfConfiguration.java index d87cb521d520..89c9744e9415 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaInfConfiguration.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaInfConfiguration.java @@ -206,13 +206,13 @@ else if (LOG.isDebugEnabled()) if (target.isDirectory()) { //TODO think how to handle an unpacked jar file (eg for osgi) - resourcesDir = target.addPath("/META-INF/resources"); + resourcesDir = target.addPath("/META-INF/resources/"); } else { //Resource represents a packed jar URI uri = target.getURI(); - resourcesDir = Resource.newResource(uriJarPrefix(uri, "!/META-INF/resources")); + resourcesDir = Resource.newResource(uriJarPrefix(uri, "!/META-INF/resources/")); } if (!resourcesDir.exists() || !resourcesDir.isDirectory()) @@ -227,7 +227,7 @@ else if (LOG.isDebugEnabled()) if (old != null) resourcesDir = old; else if (LOG.isDebugEnabled()) - LOG.debug(target + " META-INF/resources cache updated"); + LOG.debug(target + " META-INF/resources/ cache updated"); } if (resourcesDir == EmptyResource.INSTANCE) diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebInfConfiguration.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebInfConfiguration.java index 34a3cef407a5..e943a026d3c3 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebInfConfiguration.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebInfConfiguration.java @@ -907,7 +907,7 @@ protected List findWebInfLibJars(WebAppContext context) return null; List jarResources = new ArrayList<>(); - Resource webInfLib = webInf.addPath("/lib"); + Resource webInfLib = webInf.addPath("lib/"); if (webInfLib.exists() && webInfLib.isDirectory()) { String[] files = webInfLib.list();