Skip to content

Commit 3fcfd60

Browse files
Unmute and fix testSubParserArray (#40626)
testSubParserArray failed, fixed and improved to not always have an object as outer-level inside array. Closes #40617
1 parent c820549 commit 3fcfd60

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

libs/x-content/src/test/java/org/elasticsearch/common/xcontent/XContentParserTests.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
package org.elasticsearch.common.xcontent;
2121

2222
import com.fasterxml.jackson.core.JsonParseException;
23-
2423
import org.elasticsearch.common.CheckedSupplier;
2524
import org.elasticsearch.common.Strings;
2625
import org.elasticsearch.common.bytes.BytesReference;
@@ -369,7 +368,6 @@ public void testSubParserObject() throws IOException {
369368
}
370369
}
371370

372-
@AwaitsFix(bugUrl="https://github.com/elastic/elasticsearch/issues/40617")
373371
public void testSubParserArray() throws IOException {
374372
XContentBuilder builder = XContentFactory.jsonBuilder();
375373
int numberOfArrayElements = randomInt(10);
@@ -378,7 +376,7 @@ public void testSubParserArray() throws IOException {
378376
builder.startArray();
379377
int numberOfTokens = 0;
380378
for (int i = 0; i < numberOfArrayElements; ++i) {
381-
numberOfTokens += generateRandomObjectForMarking(builder);
379+
numberOfTokens += generateRandomObject(builder, 0);
382380
}
383381
builder.endArray();
384382
builder.endObject();
@@ -392,7 +390,7 @@ public void testSubParserArray() throws IOException {
392390
assertEquals(XContentParser.Token.START_ARRAY, parser.nextToken()); // [
393391
XContentParser subParser = new XContentSubParser(parser);
394392
try {
395-
int tokensToSkip = randomInt(numberOfTokens - 1);
393+
int tokensToSkip = randomInt(numberOfTokens);
396394
for (int i = 0; i < tokensToSkip; i++) {
397395
// Simulate incomplete parsing
398396
assertNotNull(subParser.nextToken());

0 commit comments

Comments
 (0)