Skip to content

Commit 617f12a

Browse files
committed
Fix tests
1 parent 99bca26 commit 617f12a

File tree

5 files changed

+6
-5
lines changed

5 files changed

+6
-5
lines changed

libs/x-content/impl/src/main/java/org/elasticsearch/xcontent/provider/json/JsonXContentParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private static XContentParseException newXContentParseException(JsonProcessingEx
7070
*/
7171
private static IOException handleParserException(IOException e) throws IOException {
7272
switch (e) {
73-
case JsonEOFException eof -> throw new XContentEOFException(getLocation(eof), "Unexpected end of file", e);
73+
case JsonEOFException eof -> throw new XContentEOFException(getLocation(eof), eof.getMessage(), e);
7474
case JsonParseException pe -> throw newXContentParseException(pe);
7575
case InputCoercionException ice -> throw newXContentParseException(ice);
7676
case CharConversionException cce -> throw new XContentParseException(null, cce.getMessage(), cce);

server/src/test/java/org/elasticsearch/action/bulk/BulkRequestParserTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.concurrent.atomic.AtomicBoolean;
2525
import java.util.stream.Stream;
2626

27+
import static org.hamcrest.Matchers.containsString;
2728
import static org.hamcrest.Matchers.equalTo;
2829

2930
public class BulkRequestParserTests extends ESTestCase {
@@ -394,7 +395,7 @@ public void testFailMissingCloseBrace() {
394395
req -> fail("expected failure before we got this far")
395396
)
396397
);
397-
assertEquals("[1:14] Unexpected end of file", ex.getMessage());
398+
assertThat(ex.getMessage(), containsString("[1:14] Unexpected end-of-input"));
398399
}
399400

400401
public void testFailExtraKeys() {

server/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ public void testBulkActionWithoutCurlyBrace() throws Exception {
432432
() -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON)
433433
);
434434

435-
assertThat(ex.getMessage(), containsString("Unexpected end of file"));
435+
assertThat(ex.getMessage(), containsString("Unexpected end-of-input"));
436436
}
437437

438438
public void testBulkActionWithAdditionalKeys() throws Exception {

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/response/XContentUtilsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void testPositionParserAtTokenAfterField_ThrowsWithMalformedJSON() throws
103103
XContentEOFException.class,
104104
() -> XContentUtils.positionParserAtTokenAfterField(parser, missingField, errorFormat)
105105
);
106-
assertThat(exception.getMessage(), containsString("[4:1] Unexpected end of file"));
106+
assertThat(exception.getMessage(), containsString("[4:1] Unexpected end-of-input"));
107107
}
108108
}
109109

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/response/huggingface/HuggingFaceElserResponseEntityTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public void testFails_ResponseIsInvalidJson_MissingSquareBracket() {
309309
new HttpResult(mock(HttpResponse.class), responseJson.getBytes(StandardCharsets.UTF_8))
310310
)
311311
);
312-
assertThat(thrownException.getMessage(), containsString("[5:1] Unexpected end of file"));
312+
assertThat(thrownException.getMessage(), containsString("[5:1] Unexpected end-of-input"));
313313
assertThat(thrownException.getCause().getMessage(), containsString("expected close marker for Array (start marker at"));
314314
}
315315

0 commit comments

Comments
 (0)