Remove deprecated MediaType entries
See gh-33809
This commit is contained in:
@@ -18,7 +18,6 @@ package org.springframework.http;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -120,32 +119,9 @@ public class MediaType extends MimeType implements Serializable {
|
||||
|
||||
/**
|
||||
* A String equivalent of {@link MediaType#APPLICATION_JSON}.
|
||||
* @see #APPLICATION_JSON_UTF8_VALUE
|
||||
*/
|
||||
public static final String APPLICATION_JSON_VALUE = "application/json";
|
||||
|
||||
/**
|
||||
* Media type for {@code application/json;charset=UTF-8}.
|
||||
* @deprecated as of 5.2 in favor of {@link #APPLICATION_JSON}
|
||||
* since major browsers like Chrome
|
||||
* <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=438464">
|
||||
* now comply with the specification</a> and interpret correctly UTF-8 special
|
||||
* characters without requiring a {@code charset=UTF-8} parameter.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final MediaType APPLICATION_JSON_UTF8;
|
||||
|
||||
/**
|
||||
* A String equivalent of {@link MediaType#APPLICATION_JSON_UTF8}.
|
||||
* @deprecated as of 5.2 in favor of {@link #APPLICATION_JSON_VALUE}
|
||||
* since major browsers like Chrome
|
||||
* <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=438464">
|
||||
* now comply with the specification</a> and interpret correctly UTF-8 special
|
||||
* characters without requiring a {@code charset=UTF-8} parameter.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String APPLICATION_JSON_UTF8_VALUE = "application/json;charset=UTF-8";
|
||||
|
||||
/**
|
||||
* Media type for {@code application/octet-stream}.
|
||||
*/
|
||||
@@ -182,32 +158,6 @@ public class MediaType extends MimeType implements Serializable {
|
||||
*/
|
||||
public static final String APPLICATION_PROBLEM_JSON_VALUE = "application/problem+json";
|
||||
|
||||
/**
|
||||
* Media type for {@code application/problem+json}.
|
||||
* @since 5.0
|
||||
* @see <a href="https://www.iana.org/assignments/media-types/application/problem+json">
|
||||
* Problem Details for HTTP APIs, 6.1. application/problem+json</a>
|
||||
* @deprecated as of 5.2 in favor of {@link #APPLICATION_PROBLEM_JSON}
|
||||
* since major browsers like Chrome
|
||||
* <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=438464">
|
||||
* now comply with the specification</a> and interpret correctly UTF-8 special
|
||||
* characters without requiring a {@code charset=UTF-8} parameter.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final MediaType APPLICATION_PROBLEM_JSON_UTF8;
|
||||
|
||||
/**
|
||||
* A String equivalent of {@link MediaType#APPLICATION_PROBLEM_JSON_UTF8}.
|
||||
* @since 5.0
|
||||
* @deprecated as of 5.2 in favor of {@link #APPLICATION_PROBLEM_JSON_VALUE}
|
||||
* since major browsers like Chrome
|
||||
* <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=438464">
|
||||
* now comply with the specification</a> and interpret correctly UTF-8 special
|
||||
* characters without requiring a {@code charset=UTF-8} parameter.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String APPLICATION_PROBLEM_JSON_UTF8_VALUE = "application/problem+json;charset=UTF-8";
|
||||
|
||||
/**
|
||||
* Media type for {@code application/problem+xml}.
|
||||
* @since 5.0
|
||||
@@ -258,26 +208,6 @@ public class MediaType extends MimeType implements Serializable {
|
||||
*/
|
||||
public static final String APPLICATION_NDJSON_VALUE = "application/x-ndjson";
|
||||
|
||||
/**
|
||||
* Media type for {@code application/stream+json}.
|
||||
* @since 5.0
|
||||
* @deprecated as of 5.3, see notice on {@link #APPLICATION_STREAM_JSON_VALUE}.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final MediaType APPLICATION_STREAM_JSON;
|
||||
|
||||
/**
|
||||
* A String equivalent of {@link MediaType#APPLICATION_STREAM_JSON}.
|
||||
* @since 5.0
|
||||
* @deprecated as of 5.3 since it originates from the W3C Activity Streams
|
||||
* specification which has a more specific purpose and has been since
|
||||
* replaced with a different mime type. Use {@link #APPLICATION_NDJSON} as
|
||||
* a replacement or any other line-delimited JSON format (for example, JSON Lines,
|
||||
* JSON Text Sequences).
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String APPLICATION_STREAM_JSON_VALUE = "application/stream+json";
|
||||
|
||||
/**
|
||||
* Media type for {@code application/xhtml+xml}.
|
||||
*/
|
||||
@@ -440,16 +370,13 @@ public class MediaType extends MimeType implements Serializable {
|
||||
APPLICATION_FORM_URLENCODED = new MediaType("application", "x-www-form-urlencoded");
|
||||
APPLICATION_GRAPHQL_RESPONSE = new MediaType("application", "graphql-response+json");
|
||||
APPLICATION_JSON = new MediaType("application", "json");
|
||||
APPLICATION_JSON_UTF8 = new MediaType("application", "json", StandardCharsets.UTF_8);
|
||||
APPLICATION_NDJSON = new MediaType("application", "x-ndjson");
|
||||
APPLICATION_OCTET_STREAM = new MediaType("application", "octet-stream");
|
||||
APPLICATION_PDF = new MediaType("application", "pdf");
|
||||
APPLICATION_PROBLEM_JSON = new MediaType("application", "problem+json");
|
||||
APPLICATION_PROBLEM_JSON_UTF8 = new MediaType("application", "problem+json", StandardCharsets.UTF_8);
|
||||
APPLICATION_PROBLEM_XML = new MediaType("application", "problem+xml");
|
||||
APPLICATION_PROTOBUF = new MediaType("application", "x-protobuf");
|
||||
APPLICATION_RSS_XML = new MediaType("application", "rss+xml");
|
||||
APPLICATION_STREAM_JSON = new MediaType("application", "stream+json");
|
||||
APPLICATION_XHTML_XML = new MediaType("application", "xhtml+xml");
|
||||
APPLICATION_XML = new MediaType("application", "xml");
|
||||
APPLICATION_YAML = new MediaType("application", "yaml");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -59,10 +59,9 @@ public class Jackson2JsonEncoder extends AbstractJackson2Encoder {
|
||||
this(Jackson2ObjectMapperBuilder.json().build());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public Jackson2JsonEncoder(ObjectMapper mapper, MimeType... mimeTypes) {
|
||||
super(mapper, mimeTypes);
|
||||
setStreamingMediaTypes(Arrays.asList(MediaType.APPLICATION_NDJSON, MediaType.APPLICATION_STREAM_JSON));
|
||||
setStreamingMediaTypes(Arrays.asList(MediaType.APPLICATION_NDJSON));
|
||||
this.ssePrettyPrinter = initSsePrettyPrinter();
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON;
|
||||
import static org.springframework.http.MediaType.APPLICATION_NDJSON;
|
||||
import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON;
|
||||
import static org.springframework.http.MediaType.APPLICATION_XML;
|
||||
import static org.springframework.http.codec.json.Jackson2CodecSupport.JSON_VIEW_HINT;
|
||||
|
||||
@@ -77,11 +76,9 @@ class Jackson2JsonDecoderTests extends AbstractDecoderTests<Jackson2JsonDecoder>
|
||||
|
||||
@Override
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void canDecode() {
|
||||
assertThat(decoder.canDecode(ResolvableType.forClass(Pojo.class), APPLICATION_JSON)).isTrue();
|
||||
assertThat(decoder.canDecode(ResolvableType.forClass(Pojo.class), APPLICATION_NDJSON)).isTrue();
|
||||
assertThat(decoder.canDecode(ResolvableType.forClass(Pojo.class), APPLICATION_STREAM_JSON)).isTrue();
|
||||
assertThat(decoder.canDecode(ResolvableType.forClass(Pojo.class), null)).isTrue();
|
||||
|
||||
assertThat(decoder.canDecode(ResolvableType.forClass(String.class), null)).isFalse();
|
||||
|
||||
@@ -49,11 +49,11 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON;
|
||||
import static org.springframework.http.MediaType.APPLICATION_NDJSON;
|
||||
import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM;
|
||||
import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON;
|
||||
import static org.springframework.http.MediaType.APPLICATION_XML;
|
||||
import static org.springframework.http.codec.json.Jackson2CodecSupport.JSON_VIEW_HINT;
|
||||
|
||||
/**
|
||||
* Tests for {@link Jackson2JsonEncoder}.
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
class Jackson2JsonEncoderTests extends AbstractEncoderTests<Jackson2JsonEncoder> {
|
||||
@@ -64,12 +64,10 @@ class Jackson2JsonEncoderTests extends AbstractEncoderTests<Jackson2JsonEncoder>
|
||||
|
||||
@Override
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void canEncode() {
|
||||
ResolvableType pojoType = ResolvableType.forClass(Pojo.class);
|
||||
assertThat(this.encoder.canEncode(pojoType, APPLICATION_JSON)).isTrue();
|
||||
assertThat(this.encoder.canEncode(pojoType, APPLICATION_NDJSON)).isTrue();
|
||||
assertThat(this.encoder.canEncode(pojoType, APPLICATION_STREAM_JSON)).isTrue();
|
||||
assertThat(this.encoder.canEncode(pojoType, null)).isTrue();
|
||||
|
||||
assertThat(this.encoder.canEncode(ResolvableType.forClass(Pojo.class),
|
||||
@@ -94,7 +92,7 @@ class Jackson2JsonEncoderTests extends AbstractEncoderTests<Jackson2JsonEncoder>
|
||||
new Pojo("foofoo", "barbar"),
|
||||
new Pojo("foofoofoo", "barbarbar"));
|
||||
|
||||
testEncodeAll(input, ResolvableType.forClass(Pojo.class), APPLICATION_STREAM_JSON, null, step -> step
|
||||
testEncodeAll(input, ResolvableType.forClass(Pojo.class), APPLICATION_NDJSON, null, step -> step
|
||||
.consumeNextWith(expectString("{\"foo\":\"foo\",\"bar\":\"bar\"}\n"))
|
||||
.consumeNextWith(expectString("{\"foo\":\"foofoo\",\"bar\":\"barbar\"}\n"))
|
||||
.consumeNextWith(expectString("{\"foo\":\"foofoofoo\",\"bar\":\"barbarbar\"}\n"))
|
||||
|
||||
@@ -201,7 +201,6 @@ class ReactiveTypeHandler {
|
||||
* @return the concrete streaming {@code MediaType} if one could be found or {@code null}
|
||||
* if none could be found
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Nullable
|
||||
static MediaType findConcreteJsonStreamMediaType(Collection<MediaType> acceptedMediaTypes) {
|
||||
for (MediaType acceptedType : acceptedMediaTypes) {
|
||||
@@ -220,9 +219,6 @@ class ReactiveTypeHandler {
|
||||
else if (MediaType.APPLICATION_NDJSON.includes(acceptedType)) {
|
||||
return MediaType.APPLICATION_NDJSON;
|
||||
}
|
||||
else if (MediaType.APPLICATION_STREAM_JSON.includes(acceptedType)) {
|
||||
return MediaType.APPLICATION_STREAM_JSON;
|
||||
}
|
||||
}
|
||||
return null; // not a concrete streaming type
|
||||
}
|
||||
|
||||
@@ -158,19 +158,6 @@ class ReactiveTypeHandlerTests {
|
||||
.isEqualTo(MediaType.APPLICATION_NDJSON);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
void findsConcreteStreamingMediaType_plainStreamingJsonFirst() {
|
||||
final List<MediaType> accept = List.of(
|
||||
MediaType.ALL,
|
||||
MediaType.APPLICATION_STREAM_JSON,
|
||||
MediaType.parseMediaType("application/*+x-ndjson"),
|
||||
MediaType.parseMediaType("application/vnd.myapp.v1+x-ndjson"));
|
||||
|
||||
assertThat(ReactiveTypeHandler.findConcreteJsonStreamMediaType(accept))
|
||||
.isEqualTo(MediaType.APPLICATION_STREAM_JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
void deferredResultSubscriberWithOneValue() throws Exception {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user