You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by js...@apache.org on 2024/02/26 13:58:57 UTC

(solr) 01/01: Using apache commons implementation for wildcard matching for glob patterns

This is an automated email from the ASF dual-hosted git repository.

jsweeney pushed a commit to branch SOLR-17181-glob-pattern-performance-degradation
in repository https://gitbox.apache.org/repos/asf/solr.git

commit f30e0fd841190539cd30c3d79028ea9feaa73560
Author: Justin Sweeney <ju...@fullstory.com>
AuthorDate: Mon Feb 26 08:58:39 2024 -0500

    Using apache commons implementation for wildcard matching for glob patterns
---
 solr/solrj/build.gradle                                              | 1 +
 solr/solrj/src/java/org/apache/solr/common/util/GlobPatternUtil.java | 5 ++---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/solr/solrj/build.gradle b/solr/solrj/build.gradle
index 286022c728a..705625e03a2 100644
--- a/solr/solrj/build.gradle
+++ b/solr/solrj/build.gradle
@@ -49,6 +49,7 @@ dependencies {
   })
   implementation 'org.apache.httpcomponents:httpclient'
   implementation 'org.apache.httpcomponents:httpcore'
+  implementation 'commons-io:commons-io'
 
   compileOnly 'com.github.stephenc.jcip:jcip-annotations'
 
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/GlobPatternUtil.java b/solr/solrj/src/java/org/apache/solr/common/util/GlobPatternUtil.java
index 8b26ab5a355..1b812bb21cb 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/GlobPatternUtil.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/GlobPatternUtil.java
@@ -16,8 +16,7 @@
  */
 package org.apache.solr.common.util;
 
-import java.nio.file.FileSystems;
-import java.nio.file.Paths;
+import org.apache.commons.io.FilenameUtils;
 
 /** Provides methods for matching glob patterns against input strings. */
 public class GlobPatternUtil {
@@ -32,6 +31,6 @@ public class GlobPatternUtil {
    * @return true if the input string matches the glob pattern, false otherwise
    */
   public static boolean matches(String pattern, String input) {
-    return FileSystems.getDefault().getPathMatcher("glob:" + pattern).matches(Paths.get(input));
+    return FilenameUtils.wildcardMatch(input, pattern);
   }
 }