Upgrade joni from 2.1.6 to 2.1.29 ()

Backport of 

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.
This commit is contained in:
Martijn van Groningen 2019-10-04 12:54:49 -05:00 committed by GitHub
parent 0b4fb05540
commit 63b169b600
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 12 deletions
libs/grok
build.gradle
licenses
src/main/java/org/elasticsearch/grok

@ -18,7 +18,7 @@
*/ */
dependencies { dependencies {
compile 'org.jruby.joni:joni:2.1.6' compile 'org.jruby.joni:joni:2.1.29'
// joni dependencies: // joni dependencies:
compile 'org.jruby.jcodings:jcodings:1.0.44' compile 'org.jruby.jcodings:jcodings:1.0.44'
@ -30,10 +30,3 @@ dependencies {
forbiddenApisMain { forbiddenApisMain {
replaceSignatureFiles 'jdk-signatures' replaceSignatureFiles 'jdk-signatures'
} }
thirdPartyAudit.ignoreMissingClasses (
// joni has AsmCompilerSupport, but that isn't being used:
'org.objectweb.asm.ClassWriter',
'org.objectweb.asm.MethodVisitor',
'org.objectweb.asm.Opcodes'
)

@ -0,0 +1 @@
3cb751702e1194ff24259155db4d37e9383d4320

@ -1 +0,0 @@
0f23c95a06eaecbc8c74c7458a8bfd13e4fd2d3a

@ -175,7 +175,9 @@ public final class Grok {
int result; int result;
try { try {
threadWatchdog.register(); threadWatchdog.register();
result = matcher.search(0, grokPatternBytes.length, Option.NONE); result = matcher.searchInterruptible(0, grokPatternBytes.length, Option.NONE);
} catch (InterruptedException e) {
result = Matcher.INTERRUPTED;
} finally { } finally {
threadWatchdog.unregister(); threadWatchdog.unregister();
} }
@ -224,7 +226,9 @@ public final class Grok {
int result; int result;
try { try {
threadWatchdog.register(); threadWatchdog.register();
result = matcher.search(0, text.length(), Option.DEFAULT); result = matcher.searchInterruptible(0, text.length(), Option.DEFAULT);
} catch (InterruptedException e) {
result = Matcher.INTERRUPTED;
} finally { } finally {
threadWatchdog.unregister(); threadWatchdog.unregister();
} }
@ -244,7 +248,9 @@ public final class Grok {
int result; int result;
try { try {
threadWatchdog.register(); threadWatchdog.register();
result = matcher.search(0, textAsBytes.length, Option.DEFAULT); result = matcher.searchInterruptible(0, textAsBytes.length, Option.DEFAULT);
} catch (InterruptedException e) {
result = Matcher.INTERRUPTED;
} finally { } finally {
threadWatchdog.unregister(); threadWatchdog.unregister();
} }