Skip to content

Commit 459d209

Browse files
committed
More test fixes
1 parent 2b3f32b commit 459d209

File tree

7 files changed

+7
-8
lines changed

7 files changed

+7
-8
lines changed

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

+1-1
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), eof.getMessage(), e);
73+
case JsonEOFException eof -> throw new XContentEOFException(getLocation(eof), "Unexpected end of file", 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);

modules/reindex/src/test/java/org/elasticsearch/reindex/remote/RemoteRequestBuildersTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public void testInitialSearchEntity() throws IOException {
246246
);
247247
assertThat(e.getCause().getMessage(), containsString("Unexpected character (',' (code 44))"));
248248
e = expectThrows(RuntimeException.class, () -> initialSearch(searchRequest, new BytesArray("{"), remoteVersion));
249-
assertThat(e.getCause().getMessage(), containsString("Unexpected end-of-input"));
249+
assertThat(e.getCause().getMessage(), containsString("Unexpected end of file"));
250250
}
251251

252252
public void testScrollParams() {

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

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

27-
import static org.hamcrest.Matchers.containsString;
2827
import static org.hamcrest.Matchers.equalTo;
2928

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

401400
public void testFailExtraKeys() {

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

+1-1
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-input"));
435+
assertThat(ex.getMessage(), containsString("Unexpected end of file"));
436436
}
437437

438438
public void testBulkActionWithAdditionalKeys() throws Exception {

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

+1-1
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-input"));
106+
assertThat(exception.getMessage(), containsString("[4:1] Unexpected end of file"));
107107
}
108108
}
109109

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

+1-1
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-input"));
312+
assertThat(thrownException.getMessage(), containsString("[5:1] Unexpected end of file"));
313313
assertThat(thrownException.getCause().getMessage(), containsString("expected close marker for Array (start marker at"));
314314
}
315315

x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachmentParserTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public void testInitialRequestContainsInvalidPayload() throws Exception {
239239
XContentParseException.class,
240240
() -> reportingAttachmentParser.toAttachment(createWatchExecutionContext(), Payload.EMPTY, attachment)
241241
);
242-
assertThat(e.getMessage(), containsString("Unexpected end-of-input"));
242+
assertThat(e.getMessage(), containsString("Unexpected end of file"));
243243
}
244244

245245
public void testInitialRequestContainsPathAsObject() throws Exception {

0 commit comments

Comments
 (0)