Skip to content

Commit

Permalink
Issue #5086 Fix error on addFile
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Bartel <janb@webtide.com>
  • Loading branch information
janbartel committed Dec 2, 2020
1 parent 31cc298 commit e39ec6c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions jetty-util/src/main/java/org/eclipse/jetty/util/Scanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,16 @@ public void addFile(Path p)
if (p == null)
throw new IllegalStateException("Null path");

File f = p.toFile();
if (!f.exists() || f.isDirectory())
if (!Files.exists(p) || Files.isDirectory(p))
throw new IllegalStateException("Not file or doesn't exist: " + p);

_scannables.putIfAbsent(p, null);
try
{
_scannables.putIfAbsent(p.toRealPath(), new IncludeExcludeSet<>(PathMatcherSet.class));
}
catch (IOException e)
{
throw new IllegalStateException(e);
}
}

/**
Expand All @@ -370,15 +375,13 @@ public IncludeExcludeSet<PathMatcher, Path> addDirectory(Path p)
if (p == null)
throw new IllegalStateException("Null path");

File f = p.toFile();
if (!f.exists() || !f.isDirectory())
if (!Files.exists(p) || !Files.isDirectory(p))
throw new IllegalStateException("Not directory or doesn't exist: " + p);

try
{
Path real = p.toRealPath();
IncludeExcludeSet<PathMatcher, Path> includesExcludes = new IncludeExcludeSet<>(PathMatcherSet.class);
IncludeExcludeSet<PathMatcher, Path> prev = _scannables.putIfAbsent(real, includesExcludes);
IncludeExcludeSet<PathMatcher, Path> prev = _scannables.putIfAbsent(p.toRealPath(), includesExcludes);
if (prev != null)
includesExcludes = prev;
return includesExcludes;
Expand Down

0 comments on commit e39ec6c

Please sign in to comment.