Skip to content

Commit 9f34b7e

Browse files
committed
fix tests
1 parent a53bfd2 commit 9f34b7e

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

server/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,9 @@ public static void readMultiLineFormat(
272272
)
273273
) {
274274
Map<String, Object> source = parser.map();
275-
// In Jackson 2.21+, parser.map() leaves the parser at END_OBJECT, need to advance past it
276-
XContentParser.Token token = parser.currentToken() == XContentParser.Token.END_OBJECT
277-
? parser.nextToken()
278-
: parser.currentToken();
279-
if (token != null) {
275+
// In Jackson 2.21+, parser.map() may leave the parser past END_OBJECT
276+
// Only check for extra tokens if we're still positioned in the stream
277+
if (parser.currentToken() != null && parser.nextToken() != null) {
280278
throw new XContentParseException(parser.getTokenLocation(), "Unexpected token after end of object");
281279
}
282280
Object expandWildcards = null;
@@ -364,11 +362,9 @@ public static void readMultiLineFormat(
364362
)
365363
) {
366364
consumer.accept(searchRequest, parser);
367-
// In Jackson 2.21+, after parsing, the parser may be at END_OBJECT, need to advance past it
368-
XContentParser.Token token = parser.currentToken() == XContentParser.Token.END_OBJECT
369-
? parser.nextToken()
370-
: parser.currentToken();
371-
if (token != null) {
365+
// In Jackson 2.21+, after parsing, the parser may be past END_OBJECT
366+
// Only check for extra tokens if we're still positioned in the stream
367+
if (parser.currentToken() != null && parser.nextToken() != null) {
372368
throw new XContentParseException(parser.getTokenLocation(), "Unexpected token after end of object");
373369
}
374370
}

server/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,11 +546,12 @@ public void testFailOnExtraCharacters() throws IOException {
546546
""");
547547
fail("should have caught second line; extra closing brackets");
548548
} catch (XContentParseException e) {
549+
// Jackson 2.21.0 changed the error message format
549550
assertThat(
550551
e.getMessage(),
551552
containsString(
552-
"Unexpected close marker '}': expected ']' (for root starting at "
553-
+ "[Source: (byte[])\"{ \"query\": {\"match_all\": {}}}}}}different error message\""
553+
"Unexpected close marker '}': no open Object to close\n"
554+
+ " at [Source: (byte[])\"{ \"query\": {\"match_all\": {}}}}}}different error message\""
554555
)
555556
);
556557
}

0 commit comments

Comments
 (0)