Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ public abstract class Jackson2CodecSupport {
private static final List<MimeType> defaultMimeTypes = List.of(
MediaType.APPLICATION_JSON,
new MediaType("application", "*+json"),
MediaType.APPLICATION_NDJSON);
MediaType.APPLICATION_NDJSON,
new MediaType("application", "*+x-ndjson")
);


protected final Log logger = HttpLogging.forLogName(getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public class JacksonJsonDecoder extends AbstractJacksonDecoder<JsonMapper> {
private static final MimeType[] DEFAULT_JSON_MIME_TYPES = new MimeType[] {
MediaType.APPLICATION_JSON,
new MediaType("application", "*+json"),
MediaType.APPLICATION_NDJSON
MediaType.APPLICATION_NDJSON,
new MediaType("application", "*+x-ndjson")
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public class JacksonJsonEncoder extends AbstractJacksonEncoder<JsonMapper> {
private static final MimeType[] DEFAULT_JSON_MIME_TYPES = new MimeType[] {
MediaType.APPLICATION_JSON,
new MediaType("application", "*+json"),
MediaType.APPLICATION_NDJSON
MediaType.APPLICATION_NDJSON,
new MediaType("application", "*+x-ndjson")
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public class JacksonJsonHttpMessageConverter extends AbstractJacksonHttpMessageC
Collections.singletonList(MediaType.APPLICATION_PROBLEM_JSON);

private static final MediaType[] DEFAULT_JSON_MIME_TYPES = new MediaType[] {
MediaType.APPLICATION_JSON, new MediaType("application", "*+json") };
MediaType.APPLICATION_JSON, new MediaType("application", "*+json"),
MediaType.APPLICATION_NDJSON, new MediaType("application", "*+x-ndjson") };


private @Nullable String jsonPrefix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ void canDecodeWithObjectMapperRegistrationForType() {

}

@Test
void canDecodeVendorSuffixedNdjson() {
MediaType vendorNdjson = MediaType.parseMediaType("application/vnd.example.v1+x-ndjson");
assertThat(decoder.canDecode(ResolvableType.forClass(Pojo.class), vendorNdjson)).isTrue();
}

@Test // SPR-15866
void canDecodeWithProvidedMimeType() {
MimeType textJavascript = new MimeType("text", "javascript", StandardCharsets.UTF_8);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ void canDecodeWithObjectMapperRegistrationForType() {
assertThat(decoder.canDecode(ResolvableType.forClass(Map.class), MediaType.APPLICATION_JSON)).isTrue();
}

@Test
void canDecodeVendorSuffixedNdjson() {
MediaType vendorNdjson = MediaType.parseMediaType("application/vnd.example.v1+x-ndjson");
assertThat(decoder.canDecode(ResolvableType.forClass(Pojo.class), vendorNdjson)).isTrue();
}

@Test // SPR-15866
void canDecodeWithProvidedMimeType() {
MimeType textJavascript = new MimeType("text", "javascript", StandardCharsets.UTF_8);
Expand Down