From 5c91e44eaf86f0b6c74afead33b6d1bd8aed9921 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 3 Jul 2019 11:48:09 +0200 Subject: [PATCH 1/2] Issue #3700 better handling of null location (#3837) Issue #3700 if a location is null then consider if there are inclusions and/or exclusions when matching a class. Signed-off-by: Greg Wilkins --- .../eclipse/jetty/util/IncludeExcludeSet.java | 5 +++++ .../eclipse/jetty/webapp/ClasspathPattern.java | 16 ++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/IncludeExcludeSet.java b/jetty-util/src/main/java/org/eclipse/jetty/util/IncludeExcludeSet.java index 667de3629d6..ef928e97707 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/IncludeExcludeSet.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/IncludeExcludeSet.java @@ -193,6 +193,11 @@ public class IncludeExcludeSet implements Predicate

return !_includes.isEmpty(); } + public boolean hasExcludes() + { + return !_excludes.isEmpty(); + } + public int size() { return _includes.size() + _excludes.size(); diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/ClasspathPattern.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/ClasspathPattern.java index 69f8f9db279..bd61bb55b2b 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/ClasspathPattern.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/ClasspathPattern.java @@ -734,14 +734,14 @@ public class ClasspathPattern extends AbstractSet return false; URI uri = location.get(); - if (uri != null) - { - Boolean byLocation = locations.isIncludedAndNotExcluded(uri); - if (Boolean.FALSE == byLocation) - return false; + if (uri == null) + return locations.isEmpty() || locations.hasExcludes() && !locations.hasIncludes(); + + Boolean byLocation = locations.isIncludedAndNotExcluded(uri); + if (Boolean.FALSE == byLocation) + return false; + + return Boolean.TRUE.equals(byName) || Boolean.TRUE.equals(byLocation) || !(names.hasIncludes() || locations.hasIncludes()); - return Boolean.TRUE.equals(byName) || Boolean.TRUE.equals(byLocation) || !(names.hasIncludes() || locations.hasIncludes()); - } - return false; } } From f84337d5b29b23e4fbf71b82b524e9551be3d1b7 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 3 Jul 2019 11:48:49 +0200 Subject: [PATCH 2/2] Issue #3840 Slow skip for PathResource (#3845) Reverted to use FileInputStream Signed-off-by: Greg Wilkins --- .../eclipse/jetty/util/resource/PathResource.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/PathResource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/PathResource.java index 8e89ed694bf..2e2c327b06a 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/PathResource.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/PathResource.java @@ -19,6 +19,7 @@ package org.eclipse.jetty.util.resource; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; @@ -378,14 +379,9 @@ public class PathResource extends Resource @Override public InputStream getInputStream() throws IOException { - /* Mimic behavior from old FileResource class and its - * usage of java.io.FileInputStream(File) which will trigger - * an IOException on construction if the path is a directory - */ - if (Files.isDirectory(path)) - throw new IOException(path + " is a directory"); - - return Files.newInputStream(path, StandardOpenOption.READ); + // Use a FileInputStream rather than Files.newInputStream(path) + // since it produces a stream with a fast skip implementation + return new FileInputStream(getFile()); } @Override