Skip to content

Commit 39b9ff7

Browse files
committed
Merge branch 'main' into exclusive2
2 parents b78ce2c + 6f2f68e commit 39b9ff7

File tree

6 files changed

+58
-9
lines changed

6 files changed

+58
-9
lines changed

docs/changelog/123403.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 123403
2+
summary: Use ordered maps for `PipelineConfiguration` xcontent deserialization
3+
area: Ingest Node
4+
type: bug
5+
issues: []

muted-tests.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,15 @@ tests:
340340
- class: org.elasticsearch.action.admin.indices.diskusage.IndexDiskUsageAnalyzerTests
341341
method: testCompletionField
342342
issue: https://github.com/elastic/elasticsearch/issues/123269
343+
- class: org.elasticsearch.index.mapper.IPSyntheticSourceNativeArrayIntegrationTests
344+
method: testSynthesizeArray
345+
issue: https://github.com/elastic/elasticsearch/issues/123417
346+
- class: org.elasticsearch.index.mapper.IPSyntheticSourceNativeArrayIntegrationTests
347+
method: testSynthesizeArrayRandom
348+
issue: https://github.com/elastic/elasticsearch/issues/123418
349+
- class: org.elasticsearch.index.mapper.IPSyntheticSourceNativeArrayIntegrationTests
350+
method: testSynthesizeArrayIgnoreMalformed
351+
issue: https://github.com/elastic/elasticsearch/issues/123419
343352

344353
# Examples:
345354
#

server/src/main/java/org/elasticsearch/cluster/metadata/ComposableIndexTemplate.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.elasticsearch.common.io.stream.StreamOutput;
2020
import org.elasticsearch.common.io.stream.Writeable;
2121
import org.elasticsearch.core.Nullable;
22-
import org.elasticsearch.core.UpdateForV9;
2322
import org.elasticsearch.index.mapper.DataStreamTimestampFieldMapper;
2423
import org.elasticsearch.index.mapper.MapperService;
2524
import org.elasticsearch.xcontent.ConstructingObjectParser;
@@ -373,8 +372,6 @@ public static class DataStreamTemplate implements Writeable, ToXContentObject {
373372

374373
private static final ParseField HIDDEN = new ParseField("hidden");
375374
private static final ParseField ALLOW_CUSTOM_ROUTING = new ParseField("allow_custom_routing");
376-
// Remove this after this PR gets backported
377-
@UpdateForV9(owner = UpdateForV9.Owner.DATA_MANAGEMENT)
378375
private static final ParseField FAILURE_STORE = new ParseField("failure_store");
379376

380377
public static final ConstructingObjectParser<DataStreamTemplate, Void> PARSER = new ConstructingObjectParser<>(

server/src/main/java/org/elasticsearch/ingest/PipelineConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public final class PipelineConfiguration implements SimpleDiffable<PipelineConfi
4646
static {
4747
PARSER.declareString(Builder::setId, new ParseField("id"));
4848
PARSER.declareField(
49-
(parser, builder, aVoid) -> builder.setConfig(parser.map()),
49+
(parser, builder, aVoid) -> builder.setConfig(parser.mapOrdered()),
5050
new ParseField("config"),
5151
ObjectParser.ValueType.OBJECT
5252
);

server/src/test/java/org/elasticsearch/ingest/PipelineConfigurationTests.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
import java.nio.charset.StandardCharsets;
2929
import java.util.HashMap;
3030
import java.util.Map;
31+
import java.util.Set;
3132
import java.util.function.Predicate;
3233

3334
import static org.hamcrest.Matchers.anEmptyMap;
35+
import static org.hamcrest.Matchers.contains;
3436
import static org.hamcrest.Matchers.equalTo;
3537
import static org.hamcrest.Matchers.not;
3638
import static org.hamcrest.Matchers.sameInstance;
@@ -143,6 +145,41 @@ public void testGetVersion() {
143145
}
144146
}
145147

148+
@SuppressWarnings("unchecked")
149+
public void testMapKeyOrderingRoundTrip() throws IOException {
150+
// make up two random keys
151+
String key1 = randomAlphaOfLength(10);
152+
String key2 = randomValueOtherThan(key1, () -> randomAlphaOfLength(10));
153+
// stick them as mappings onto themselves in the _meta of a pipeline configuration
154+
// this happens to use the _meta as a convenient map to test that the ordering of the key sets is the same
155+
String configJson = Strings.format("""
156+
{"description": "blah", "_meta" : {"foo": "bar", "%s": "%s", "%s": "%s"}}""", key1, key1, key2, key2);
157+
PipelineConfiguration configuration = new PipelineConfiguration(
158+
"1",
159+
new BytesArray(configJson.getBytes(StandardCharsets.UTF_8)),
160+
XContentType.JSON
161+
);
162+
163+
// serialize it to bytes
164+
XContentType xContentType = randomFrom(XContentType.values());
165+
final BytesReference bytes;
166+
try (XContentBuilder builder = XContentBuilder.builder(xContentType.xContent())) {
167+
configuration.toXContent(builder, ToXContent.EMPTY_PARAMS);
168+
bytes = BytesReference.bytes(builder);
169+
}
170+
171+
// deserialize it back
172+
ContextParser<Void, PipelineConfiguration> parser = PipelineConfiguration.getParser();
173+
XContentParser xContentParser = xContentType.xContent()
174+
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, bytes.streamInput());
175+
PipelineConfiguration parsed = parser.parse(xContentParser, null);
176+
177+
// make sure the _meta key sets are in the same order
178+
Set<String> keys1 = ((Map<String, Object>) configuration.getConfig().get("_meta")).keySet();
179+
Set<String> keys2 = ((Map<String, Object>) parsed.getConfig().get("_meta")).keySet();
180+
assertThat(keys1, contains(keys2.toArray(new String[0])));
181+
}
182+
146183
@Override
147184
protected PipelineConfiguration createTestInstance() {
148185
BytesArray config;

test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
import org.elasticsearch.core.Nullable;
6565
import org.elasticsearch.core.PathUtils;
6666
import org.elasticsearch.core.TimeValue;
67-
import org.elasticsearch.core.UpdateForV9;
67+
import org.elasticsearch.core.UpdateForV10;
6868
import org.elasticsearch.features.NodeFeature;
6969
import org.elasticsearch.health.node.selection.HealthNode;
7070
import org.elasticsearch.index.IndexSettings;
@@ -1993,11 +1993,12 @@ protected static boolean indexExists(RestClient client, String index) throws IOE
19931993
}
19941994

19951995
/**
1996-
* Deprecation message emitted since 7.12.0 for the rest of the 7.x series. Can be removed in v9 since it is not
1997-
* emitted in v8. Note that this message is also permitted in certain YAML test cases, it can be removed there too.
1998-
* See https://github.com/elastic/elasticsearch/issues/66419 for more details.
1996+
* Deprecation message emitted since 7.12.0 for the rest of the 7.x series. Can be removed in v10 since it is not
1997+
* emitted in v8 or v9 and N-2 versions are now supported.
1998+
* Note that this message is also permitted in certain YAML test cases, it can be removed there too.
1999+
* See https://github.com/elastic/elasticsearch/issues/66419 and https://github.com/elastic/elasticsearch/pull/119594 for more details.
19992000
*/
2000-
@UpdateForV9(owner = UpdateForV9.Owner.DATA_MANAGEMENT)
2001+
@UpdateForV10(owner = UpdateForV10.Owner.DISTRIBUTED_COORDINATION)
20012002
private static final String WAIT_FOR_ACTIVE_SHARDS_DEFAULT_DEPRECATION_MESSAGE = "the default value for the ?wait_for_active_shards "
20022003
+ "parameter will change from '0' to 'index-setting' in version 8; specify '?wait_for_active_shards=index-setting' "
20032004
+ "to adopt the future default behaviour, or '?wait_for_active_shards=0' to preserve today's behaviour";

0 commit comments

Comments
 (0)