Apache Solr open-source search software
SOLR-15340: Fix wildcard path detection on Windows.
Bruno Roustant6c969f77d794
diff --git a/solr/core/src/java/org/apache/solr/core/SolrPaths.java b/solr/core/src/java/org/apache/solr/core/SolrPaths.javaindex 6e06e086b5a..37fe247a209 100644--- a/solr/core/src/java/org/apache/solr/core/SolrPaths.java+++ b/solr/core/src/java/org/apache/solr/core/SolrPaths.java@@ -90,17 +90,35 @@ public final class SolrPaths {/*** Builds a set of allowed {@link Path}.- * Detects special paths '*' and '_ALL_' that mean all paths are allowed.+ * Detects special paths "*" and "_ALL_" that mean all paths are allowed.*/public static class AllowPathBuilder {- private static final Path WILDCARD_PATH = Paths.get("*");+ private static final String WILDCARD_PATH = "*";private Set<Path> paths;+ /**+ * Adds an allowed path.+ * Detects "*" and "_ALL_" which mean all paths are allowed.+ */+ public AllowPathBuilder addPath(String path) {+ if (path.equals(WILDCARD_PATH)) {+ paths = ALL_PATHS;+ } else {+ addPath(Paths.get(path));+ }+ return this;+ }++ /**+ * Adds an allowed path.+ * Detects "_ALL_" which means all paths are allowed.+ * Does not detect "*" (not supported as a {@link Path} on Windows), see {@link #addPath(String)}.+ */public AllowPathBuilder addPath(Path path) {if (paths != ALL_PATHS) {- if (path.equals(ALL_PATH) || path.equals(WILDCARD_PATH)) {+ if (path.equals(ALL_PATH)) {paths = ALL_PATHS;} else {if (paths == null) {diff --git a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.javaindex 43b3c6f9161..24354fb0d28 100644--- a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java+++ b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java@@ -26,7 +26,6 @@ import java.lang.invoke.MethodHandles;import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.ArrayList;import java.util.Arrays;import java.util.Collections;@@ -372,7 +371,7 @@ public class SolrXmlConfig {String[] pathStrings = COMMA_SEPARATED_PATTERN.split(commaSeparatedString);SolrPaths.AllowPathBuilder allowPathBuilder = new SolrPaths.AllowPathBuilder();for (String p : pathStrings) {- allowPathBuilder.addPath(Paths.get(p));+ allowPathBuilder.addPath(p);}return allowPathBuilder.build();}