From 24390491740ae4486c373fcbe46654359c310081 Mon Sep 17 00:00:00 2001 From: Joshua Adams Date: Mon, 7 Jul 2025 16:44:53 +0100 Subject: [PATCH 1/2] Add @UpdateForV10 to AbstractObjectParser.declareInt Adds an `@UpdateForV10` annotation to the `AbstractObjectParser .declareInt` method and assigns it to the Core Infra team. This method needs to throw an `IllegalArgumentException` for non-integer values being passed, such as floats, doubles, and stringified floats and doubles. --- .../java/org/elasticsearch/xcontent/AbstractObjectParser.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/x-content/src/main/java/org/elasticsearch/xcontent/AbstractObjectParser.java b/libs/x-content/src/main/java/org/elasticsearch/xcontent/AbstractObjectParser.java index 244e1270fe530..67156048c8afc 100644 --- a/libs/x-content/src/main/java/org/elasticsearch/xcontent/AbstractObjectParser.java +++ b/libs/x-content/src/main/java/org/elasticsearch/xcontent/AbstractObjectParser.java @@ -10,6 +10,7 @@ package org.elasticsearch.xcontent; import org.elasticsearch.core.CheckedFunction; +import org.elasticsearch.core.UpdateForV10; import org.elasticsearch.xcontent.ObjectParser.NamedObjectParser; import org.elasticsearch.xcontent.ObjectParser.ValueType; @@ -245,6 +246,7 @@ public void declareLongOrNull(BiConsumer consumer, long nullValue, ); } + @UpdateForV10(owner = UpdateForV10.Owner.CORE_INFRA) // https://github.com/elastic/elasticsearch/issues/130797 public void declareInt(BiConsumer consumer, ParseField field) { // Using a method reference here angers some compilers declareField(consumer, p -> p.intValue(), field, ValueType.INT); From eb597378fbda5fa62451e6cde55a3a126906d560 Mon Sep 17 00:00:00 2001 From: Joshua Adams Date: Tue, 8 Jul 2025 10:42:05 +0100 Subject: [PATCH 2/2] Add @UpdateForV10 to AbstractObjectParser methods Adds an `@UpdateForV10` annotation to the following methods in `AbstractObjectParser`: `declareInt`, `declareIntOrNull`, `declareLong`, `declareLongOrNull`, `declareIntArray` and `declareLongArray`. The required change is explained in https://github .com/elastic/elasticsearch/issues/130797. The current parsing methods do not throw exceptions when floats or doubles are passed in place of longs or ints. The current behaviour is to truncate the float / double but this can lead to incorrect behaviour, and is also a discrepancy versus the stricter validation found when floats are passed as query parameters. --- .../org/elasticsearch/xcontent/AbstractObjectParser.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/x-content/src/main/java/org/elasticsearch/xcontent/AbstractObjectParser.java b/libs/x-content/src/main/java/org/elasticsearch/xcontent/AbstractObjectParser.java index 67156048c8afc..140ee9357dd08 100644 --- a/libs/x-content/src/main/java/org/elasticsearch/xcontent/AbstractObjectParser.java +++ b/libs/x-content/src/main/java/org/elasticsearch/xcontent/AbstractObjectParser.java @@ -231,11 +231,13 @@ public void declareDoubleOrNull(BiConsumer consumer, double nullV ); } + @UpdateForV10(owner = UpdateForV10.Owner.CORE_INFRA) // https://github.com/elastic/elasticsearch/issues/130797 public void declareLong(BiConsumer consumer, ParseField field) { // Using a method reference here angers some compilers declareField(consumer, p -> p.longValue(), field, ValueType.LONG); } + @UpdateForV10(owner = UpdateForV10.Owner.CORE_INFRA) // https://github.com/elastic/elasticsearch/issues/130797 public void declareLongOrNull(BiConsumer consumer, long nullValue, ParseField field) { // Using a method reference here angers some compilers declareField( @@ -255,6 +257,7 @@ public void declareInt(BiConsumer consumer, ParseField field) { /** * Declare an integer field that parses explicit {@code null}s in the json to a default value. */ + @UpdateForV10(owner = UpdateForV10.Owner.CORE_INFRA) // https://github.com/elastic/elasticsearch/issues/130797 public void declareIntOrNull(BiConsumer consumer, int nullValue, ParseField field) { declareField( consumer, @@ -322,10 +325,12 @@ public void declareFloatArray(BiConsumer> consumer, ParseFiel declareFieldArray(consumer, (p, c) -> p.floatValue(), field, ValueType.FLOAT_ARRAY); } + @UpdateForV10(owner = UpdateForV10.Owner.CORE_INFRA) // https://github.com/elastic/elasticsearch/issues/130797 public void declareLongArray(BiConsumer> consumer, ParseField field) { declareFieldArray(consumer, (p, c) -> p.longValue(), field, ValueType.LONG_ARRAY); } + @UpdateForV10(owner = UpdateForV10.Owner.CORE_INFRA) // https://github.com/elastic/elasticsearch/issues/130797 public void declareIntArray(BiConsumer> consumer, ParseField field) { declareFieldArray(consumer, (p, c) -> p.intValue(), field, ValueType.INT_ARRAY); }