Issue #5129 - Directories discovered via classpath glob are not valid
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
parent
4a19ef4bb2
commit
d91cab0354
|
@ -331,19 +331,12 @@ public class WebAppClassLoader extends URLClassLoader implements ClassVisibility
|
|||
Resource resource = lib.addPath(entry);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("addJar - {}", resource);
|
||||
if (resource.isDirectory())
|
||||
String fnlc = resource.getName().toLowerCase(Locale.ENGLISH);
|
||||
// don't check if this is a directory (prevents use of symlinks), see Bug 353165
|
||||
if (isFileSupported(fnlc))
|
||||
{
|
||||
addURL(resource.getURI().toURL());
|
||||
}
|
||||
else
|
||||
{
|
||||
String fnlc = resource.getName().toLowerCase(Locale.ENGLISH);
|
||||
// don't check if this is a directory (prevents use of symlinks), see Bug 353165
|
||||
if (isFileSupported(fnlc))
|
||||
{
|
||||
String jar = URIUtil.encodeSpecific(resource.toString(), ",;");
|
||||
addClassPath(jar);
|
||||
}
|
||||
String jar = URIUtil.encodeSpecific(resource.toString(), ",;");
|
||||
addClassPath(jar);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -1038,30 +1038,8 @@ public class WebInfConfiguration extends AbstractConfiguration
|
|||
while (tokenizer.hasMoreTokens())
|
||||
{
|
||||
String token = tokenizer.nextToken().trim();
|
||||
if (isGlobReference(token))
|
||||
{
|
||||
String dir = token.substring(0, token.length() - 2);
|
||||
// Use directory
|
||||
Resource dirResource = context.newResource(dir);
|
||||
if (dirResource.exists() && dirResource.isDirectory())
|
||||
{
|
||||
// To obtain the list of files
|
||||
String[] entries = dirResource.list();
|
||||
if (entries != null)
|
||||
{
|
||||
Arrays.sort(entries);
|
||||
for (String entry : entries)
|
||||
{
|
||||
Resource resource = dirResource.addPath(entry);
|
||||
if (resource.isDirectory())
|
||||
{
|
||||
dirResources.add(resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
// ignore glob references, they only refer to lists of jars/zips anyway
|
||||
if (!isGlobReference(token))
|
||||
{
|
||||
Resource resource = context.newResource(token);
|
||||
if (resource.exists() && resource.isDirectory())
|
||||
|
|
|
@ -133,12 +133,8 @@ public class WebAppContextExtraClasspathTest
|
|||
Path extLibsDir = MavenTestingUtils.getTestResourcePathDir("ext");
|
||||
extLibsDir = extLibsDir.toAbsolutePath();
|
||||
List<Path> expectedPaths = Files.list(extLibsDir)
|
||||
.filter((path) ->
|
||||
{
|
||||
if (Files.isDirectory(path))
|
||||
return true;
|
||||
return Files.isRegularFile(path) && path.toString().endsWith(".jar");
|
||||
})
|
||||
.filter(Files::isRegularFile)
|
||||
.filter((path) -> path.toString().endsWith(".jar"))
|
||||
.collect(Collectors.toList());
|
||||
List<Path> actualPaths = new ArrayList<>();
|
||||
for (URL url : webAppClassLoader.getURLs())
|
||||
|
|
Loading…
Reference in New Issue