Skip to content

Commit bb53234

Browse files
committed
Prevent 500s on pipeline searchText glob match
The oro project routinely throws indicating a bug when dealing with the simplest glob string to regex converter. Use the java nio file glob matcher instead.
1 parent a9beda0 commit bb53234

File tree

3 files changed

+8
-19
lines changed

3 files changed

+8
-19
lines changed

blueocean-rest-impl/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@
4343
<groupId>org.jenkins-ci.plugins</groupId>
4444
<artifactId>credentials</artifactId>
4545
</dependency>
46-
<dependency>
47-
<groupId>oro</groupId>
48-
<artifactId>oro</artifactId>
49-
</dependency>
5046
<!-- Test plugins -->
5147
<dependency>
5248
<groupId>org.jenkins-ci.plugins</groupId>
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
package io.jenkins.blueocean.service.embedded.util;
22

3-
import org.apache.oro.text.GlobCompiler;
4-
import org.apache.oro.text.regex.MalformedPatternException;
5-
import org.apache.oro.text.regex.Pattern;
6-
import org.apache.oro.text.regex.Perl5Matcher;
3+
import java.nio.file.FileSystems;
4+
import java.nio.file.PathMatcher;
75

86
/**
9-
* Matches glob string patters
7+
* Matches case-insensitive glob string patterns
108
* See https://en.wikipedia.org/wiki/Glob_(programming)
119
*/
1210
public final class GlobMatcher {
1311

14-
private static final GlobCompiler GLOB_COMPILER = new GlobCompiler();
15-
private static final Perl5Matcher MATCHER = new Perl5Matcher();
16-
private final Pattern pattern;
12+
private final PathMatcher matcher;
1713

1814
public GlobMatcher(String patternStr) {
1915
try {
20-
this.pattern = GLOB_COMPILER.compile(patternStr, GlobCompiler.CASE_INSENSITIVE_MASK);
16+
String multiDirUpperGlobPattern = patternStr.replaceAll("\\*", "**").toUpperCase();
17+
this.matcher = FileSystems.getDefault().getPathMatcher("glob:" + multiDirUpperGlobPattern);
2118
} catch (Throwable e) {
2219
throw new IllegalArgumentException(String.format("bad pattern '%s'", patternStr), e);
2320
}
@@ -28,6 +25,7 @@ public GlobMatcher(String patternStr) {
2825
* @return matches pattern or not
2926
*/
3027
public boolean matches(String input) {
31-
return MATCHER.matches(input, pattern);
28+
String upperInput = input.toUpperCase();
29+
return matcher.matches(FileSystems.getDefault().getPath(upperInput));
3230
}
3331
}

pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,11 +417,6 @@
417417
<version>${jenkins-test-harness.version}</version>
418418
<scope>test</scope>
419419
</dependency>
420-
<dependency>
421-
<groupId>oro</groupId>
422-
<artifactId>oro</artifactId>
423-
<version>2.0.8</version>
424-
</dependency>
425420
<dependency>
426421
<groupId>org.bitbucket.b_c</groupId>
427422
<artifactId>jose4j</artifactId>

0 commit comments

Comments
 (0)