Skip to content

Commit 63b169b

Browse files
authored
Upgrade joni from 2.1.6 to 2.1.29 (#47570)
Backport of #47374 Changed the Grok class to use searchInterruptible(...) instead of search(...) otherwise we can't interrupt long running matching via the thread watch dog. Joni now also provides another way to interrupt long running matches. By invoking the interrupt() method on the Matcher. We need then to refactor the watch thread dog to keep track of Matchers instead of Threads, but it is a better way of doing this, since interrupting would be more direct (not every 30k iterations) and efficient (checking a volatile field). This work needs to be done in a follow up.
1 parent 0b4fb05 commit 63b169b

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

libs/grok/build.gradle

+1-8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
dependencies {
21-
compile 'org.jruby.joni:joni:2.1.6'
21+
compile 'org.jruby.joni:joni:2.1.29'
2222
// joni dependencies:
2323
compile 'org.jruby.jcodings:jcodings:1.0.44'
2424

@@ -30,10 +30,3 @@ dependencies {
3030
forbiddenApisMain {
3131
replaceSignatureFiles 'jdk-signatures'
3232
}
33-
34-
thirdPartyAudit.ignoreMissingClasses (
35-
// joni has AsmCompilerSupport, but that isn't being used:
36-
'org.objectweb.asm.ClassWriter',
37-
'org.objectweb.asm.MethodVisitor',
38-
'org.objectweb.asm.Opcodes'
39-
)
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3cb751702e1194ff24259155db4d37e9383d4320

libs/grok/licenses/joni-2.1.6.jar.sha1

-1
This file was deleted.

libs/grok/src/main/java/org/elasticsearch/grok/Grok.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ public String toRegex(String grokPattern) {
175175
int result;
176176
try {
177177
threadWatchdog.register();
178-
result = matcher.search(0, grokPatternBytes.length, Option.NONE);
178+
result = matcher.searchInterruptible(0, grokPatternBytes.length, Option.NONE);
179+
} catch (InterruptedException e) {
180+
result = Matcher.INTERRUPTED;
179181
} finally {
180182
threadWatchdog.unregister();
181183
}
@@ -224,7 +226,9 @@ public boolean match(String text) {
224226
int result;
225227
try {
226228
threadWatchdog.register();
227-
result = matcher.search(0, text.length(), Option.DEFAULT);
229+
result = matcher.searchInterruptible(0, text.length(), Option.DEFAULT);
230+
} catch (InterruptedException e) {
231+
result = Matcher.INTERRUPTED;
228232
} finally {
229233
threadWatchdog.unregister();
230234
}
@@ -244,7 +248,9 @@ public Map<String, Object> captures(String text) {
244248
int result;
245249
try {
246250
threadWatchdog.register();
247-
result = matcher.search(0, textAsBytes.length, Option.DEFAULT);
251+
result = matcher.searchInterruptible(0, textAsBytes.length, Option.DEFAULT);
252+
} catch (InterruptedException e) {
253+
result = Matcher.INTERRUPTED;
248254
} finally {
249255
threadWatchdog.unregister();
250256
}

0 commit comments

Comments
 (0)