Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/139075.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 139075
summary: Bump jruby/joni to 2.2.6
area: Ingest Node
type: enhancement
issues: []
12 changes: 6 additions & 6 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4418,14 +4418,14 @@
<sha256 value="d8b5b277840e6468dfc26364214455c97a57fe6c373bcfee8cd7621e293d51f2" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jruby.jcodings" name="jcodings" version="1.0.44">
<artifact name="jcodings-1.0.44.jar">
<sha256 value="49190d6ad09056de57d7ed41ed5b4b105e033557b5dd170702decdcf05ee341a" origin="Generated by Gradle"/>
<component group="org.jruby.jcodings" name="jcodings" version="1.0.63">
<artifact name="jcodings-1.0.63.jar">
<sha256 value="ef11e1741a65160c5619cd2c3c79c40ee0affda847062f012616034b9d10e719" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jruby.joni" name="joni" version="2.1.29">
<artifact name="joni-2.1.29.jar">
<sha256 value="aa4b71415682f3d7fa44083cd94a9ec48478ec3b9c30947b4152913d41b1004d" origin="Generated by Gradle"/>
<component group="org.jruby.joni" name="joni" version="2.2.6">
<artifact name="joni-2.2.6.jar">
<sha256 value="fb33f60ab43e38653317bbf41a1fec89cbee270c48e53b0b56d1165c00de0e07" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jsoup" name="jsoup" version="1.13.1">
Expand Down
4 changes: 2 additions & 2 deletions libs/grok/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
apply plugin: 'elasticsearch.publish'

dependencies {
api 'org.jruby.joni:joni:2.1.29'
api 'org.jruby.joni:joni:2.2.6'
// joni dependencies:
api 'org.jruby.jcodings:jcodings:1.0.44'
api 'org.jruby.jcodings:jcodings:1.0.63'

testImplementation(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'grok'
Expand Down
11 changes: 8 additions & 3 deletions libs/grok/src/main/java/org/elasticsearch/grok/Grok.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ private static String groupMatch(String name, Region region, String pattern) {
name.getBytes(StandardCharsets.UTF_8).length,
region
);
int begin = region.beg[number];
int end = region.end[number];
int begin = region.getBeg(number);
int end = region.getEnd(number);
if (begin < 0) { // no match found
return null;
}
Expand Down Expand Up @@ -159,7 +159,12 @@ String toRegex(PatternBank patternBank, String grokPattern) {
grokPart = String.format(Locale.US, "(?<%s>%s)", patternName + "_" + result, pattern);
}
String start = new String(grokPatternBytes, 0, result, StandardCharsets.UTF_8);
String rest = new String(grokPatternBytes, region.end[0], grokPatternBytes.length - region.end[0], StandardCharsets.UTF_8);
String rest = new String(
grokPatternBytes,
region.getEnd(0),
grokPatternBytes.length - region.getEnd(0),
StandardCharsets.UTF_8
);
grokPattern = grokPart + rest;
res.append(start);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,35 +55,35 @@ public GrokCaptureType type() {
*/
public GrokCaptureExtracter objectExtracter(Consumer<Object> emit) {
// We could probably write this code a little more concisely but this makes it clear where we are boxing
return nativeExtracter(new NativeExtracterMap<GrokCaptureExtracter>() {
return nativeExtracter(new NativeExtracterMap<>() {
@Override
public GrokCaptureExtracter forString(Function<Consumer<String>, GrokCaptureExtracter> buildExtracter) {
return buildExtracter.apply(str -> emit.accept(str));
return buildExtracter.apply(emit::accept);
}

@Override
public GrokCaptureExtracter forInt(Function<IntConsumer, GrokCaptureExtracter> buildExtracter) {
return buildExtracter.apply(i -> emit.accept(Integer.valueOf(i)));
return buildExtracter.apply(emit::accept);
}

@Override
public GrokCaptureExtracter forLong(Function<LongConsumer, GrokCaptureExtracter> buildExtracter) {
return buildExtracter.apply(l -> emit.accept(Long.valueOf(l)));
return buildExtracter.apply(emit::accept);
}

@Override
public GrokCaptureExtracter forFloat(Function<FloatConsumer, GrokCaptureExtracter> buildExtracter) {
return buildExtracter.apply(f -> emit.accept(Float.valueOf(f)));
return buildExtracter.apply(emit::accept);
}

@Override
public GrokCaptureExtracter forDouble(Function<DoubleConsumer, GrokCaptureExtracter> buildExtracter) {
return buildExtracter.apply(d -> emit.accept(Double.valueOf(d)));
return buildExtracter.apply(emit::accept);
}

@Override
public GrokCaptureExtracter forBoolean(Function<Consumer<Boolean>, GrokCaptureExtracter> buildExtracter) {
return buildExtracter.apply(b -> emit.accept(b));
return buildExtracter.apply(emit::accept);
}
});
}
Expand All @@ -92,26 +92,26 @@ public GrokCaptureExtracter forBoolean(Function<Consumer<Boolean>, GrokCaptureEx
* Build an extract that has access to the "native" type of the extracter
* match. This means that patterns like {@code %{NUMBER:bytes:float}} has
* access to an actual {@link float}. Extracters returned from this method
* should be stateless stateless and can be reused. Pathological implementations
* should be stateless and can be reused. Pathological implementations
* of the {@code map} parameter could violate this, but the caller should
* take care to stay sane.
* <p>
* While the goal is to produce a {@link GrokCaptureExtracter} that provides
* a primitive, the caller can produce whatever type-safe constructs it
* needs and return them from this method. Thus the {@code <T>} in the type
* needs and return them from this method. Thus, the {@code <T>} in the type
* signature.
*
* @param <T> The type of the result.
* @param map Collection of handlers for each native type. Only one method
* will be called but well behaved implementers are stateless.
* will be called but well-behaved implementers are stateless.
* @return whatever was returned by the handler.
*/
public <T> T nativeExtracter(NativeExtracterMap<T> map) {
return type.nativeExtracter(backRefs, map);
}

/**
* Collection of handlers for each native type. Well behaved implementations
* Collection of handlers for each native type. Well-behaved implementations
* are stateless and produce stateless results.
*/
public interface NativeExtracterMap<T> {
Expand Down Expand Up @@ -153,9 +153,9 @@ public interface NativeExtracterMap<T> {
public GrokCaptureExtracter rangeExtracter(Consumer<Object> emit) {
return (utf8Bytes, offset, region) -> {
for (int number : backRefs) {
if (region.beg[number] >= 0) {
int matchOffset = offset + region.beg[number];
int matchLength = region.end[number] - region.beg[number];
if (region.getBeg(number) >= 0) {
int matchOffset = offset + region.getBeg(number);
int matchLength = region.getEnd(number) - region.getBeg(number);
String match = new String(utf8Bytes, matchOffset, matchLength, StandardCharsets.UTF_8);
emit.accept(new GrokCaptureExtracter.Range(match, matchOffset, matchLength));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ static GrokCaptureType fromString(String str) {
protected static GrokCaptureExtracter rawExtracter(int[] backRefs, Consumer<? super String> emit) {
return (utf8Bytes, offset, region) -> {
for (int number : backRefs) {
if (region.beg[number] >= 0) {
int matchOffset = offset + region.beg[number];
int matchLength = region.end[number] - region.beg[number];
if (region.getBeg(number) >= 0) {
int matchOffset = offset + region.getBeg(number);
int matchLength = region.getEnd(number) - region.getBeg(number);
emit.accept(new String(utf8Bytes, matchOffset, matchLength, StandardCharsets.UTF_8));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ public void extract(byte[] utf8Bytes, int offset, Region region) {
assert patternName != null;

int number = 0;
int matchOffset = offset + region.beg[number];
int matchEnd = offset + region.end[number];
int matchOffset = offset + region.getBeg(number);
int matchEnd = offset + region.getEnd(number);
replacementPositions.add(new Replacement(matchOffset, matchEnd, patternName));
}

Expand Down