Skip to content

Commit

Permalink
Issue #5129 - Directories discovered via classpath glob are not valid
Browse files Browse the repository at this point in the history
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
  • Loading branch information
joakime committed Aug 11, 2020
1 parent 4a19ef4 commit d91cab0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 42 deletions.
Expand Up @@ -331,19 +331,12 @@ public void addJars(Resource lib)
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)
Expand Down
Expand Up @@ -1038,30 +1038,8 @@ protected List<Resource> findExtraClasspathDirs(WebAppContext context)
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())
Expand Down
Expand Up @@ -133,12 +133,8 @@ public void testExtraClasspathGlob(String extraClasspathGlobReference) throws Ex
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())
Expand Down

0 comments on commit d91cab0

Please sign in to comment.