Skip to content

Commit 5044b70

Browse files
committed
Remove deprecated MediaType entries
See gh-33809
1 parent ff28d2d commit 5044b70

File tree

6 files changed

+4
-100
lines changed

6 files changed

+4
-100
lines changed

spring-web/src/main/java/org/springframework/http/MediaType.java

-73
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import java.io.Serializable;
2020
import java.nio.charset.Charset;
21-
import java.nio.charset.StandardCharsets;
2221
import java.util.ArrayList;
2322
import java.util.Collection;
2423
import java.util.Collections;
@@ -120,32 +119,9 @@ public class MediaType extends MimeType implements Serializable {
120119

121120
/**
122121
* A String equivalent of {@link MediaType#APPLICATION_JSON}.
123-
* @see #APPLICATION_JSON_UTF8_VALUE
124122
*/
125123
public static final String APPLICATION_JSON_VALUE = "application/json";
126124

127-
/**
128-
* Media type for {@code application/json;charset=UTF-8}.
129-
* @deprecated as of 5.2 in favor of {@link #APPLICATION_JSON}
130-
* since major browsers like Chrome
131-
* <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=438464">
132-
* now comply with the specification</a> and interpret correctly UTF-8 special
133-
* characters without requiring a {@code charset=UTF-8} parameter.
134-
*/
135-
@Deprecated
136-
public static final MediaType APPLICATION_JSON_UTF8;
137-
138-
/**
139-
* A String equivalent of {@link MediaType#APPLICATION_JSON_UTF8}.
140-
* @deprecated as of 5.2 in favor of {@link #APPLICATION_JSON_VALUE}
141-
* since major browsers like Chrome
142-
* <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=438464">
143-
* now comply with the specification</a> and interpret correctly UTF-8 special
144-
* characters without requiring a {@code charset=UTF-8} parameter.
145-
*/
146-
@Deprecated
147-
public static final String APPLICATION_JSON_UTF8_VALUE = "application/json;charset=UTF-8";
148-
149125
/**
150126
* Media type for {@code application/octet-stream}.
151127
*/
@@ -182,32 +158,6 @@ public class MediaType extends MimeType implements Serializable {
182158
*/
183159
public static final String APPLICATION_PROBLEM_JSON_VALUE = "application/problem+json";
184160

185-
/**
186-
* Media type for {@code application/problem+json}.
187-
* @since 5.0
188-
* @see <a href="https://www.iana.org/assignments/media-types/application/problem+json">
189-
* Problem Details for HTTP APIs, 6.1. application/problem+json</a>
190-
* @deprecated as of 5.2 in favor of {@link #APPLICATION_PROBLEM_JSON}
191-
* since major browsers like Chrome
192-
* <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=438464">
193-
* now comply with the specification</a> and interpret correctly UTF-8 special
194-
* characters without requiring a {@code charset=UTF-8} parameter.
195-
*/
196-
@Deprecated
197-
public static final MediaType APPLICATION_PROBLEM_JSON_UTF8;
198-
199-
/**
200-
* A String equivalent of {@link MediaType#APPLICATION_PROBLEM_JSON_UTF8}.
201-
* @since 5.0
202-
* @deprecated as of 5.2 in favor of {@link #APPLICATION_PROBLEM_JSON_VALUE}
203-
* since major browsers like Chrome
204-
* <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=438464">
205-
* now comply with the specification</a> and interpret correctly UTF-8 special
206-
* characters without requiring a {@code charset=UTF-8} parameter.
207-
*/
208-
@Deprecated
209-
public static final String APPLICATION_PROBLEM_JSON_UTF8_VALUE = "application/problem+json;charset=UTF-8";
210-
211161
/**
212162
* Media type for {@code application/problem+xml}.
213163
* @since 5.0
@@ -258,26 +208,6 @@ public class MediaType extends MimeType implements Serializable {
258208
*/
259209
public static final String APPLICATION_NDJSON_VALUE = "application/x-ndjson";
260210

261-
/**
262-
* Media type for {@code application/stream+json}.
263-
* @since 5.0
264-
* @deprecated as of 5.3, see notice on {@link #APPLICATION_STREAM_JSON_VALUE}.
265-
*/
266-
@Deprecated
267-
public static final MediaType APPLICATION_STREAM_JSON;
268-
269-
/**
270-
* A String equivalent of {@link MediaType#APPLICATION_STREAM_JSON}.
271-
* @since 5.0
272-
* @deprecated as of 5.3 since it originates from the W3C Activity Streams
273-
* specification which has a more specific purpose and has been since
274-
* replaced with a different mime type. Use {@link #APPLICATION_NDJSON} as
275-
* a replacement or any other line-delimited JSON format (for example, JSON Lines,
276-
* JSON Text Sequences).
277-
*/
278-
@Deprecated
279-
public static final String APPLICATION_STREAM_JSON_VALUE = "application/stream+json";
280-
281211
/**
282212
* Media type for {@code application/xhtml+xml}.
283213
*/
@@ -440,16 +370,13 @@ public class MediaType extends MimeType implements Serializable {
440370
APPLICATION_FORM_URLENCODED = new MediaType("application", "x-www-form-urlencoded");
441371
APPLICATION_GRAPHQL_RESPONSE = new MediaType("application", "graphql-response+json");
442372
APPLICATION_JSON = new MediaType("application", "json");
443-
APPLICATION_JSON_UTF8 = new MediaType("application", "json", StandardCharsets.UTF_8);
444373
APPLICATION_NDJSON = new MediaType("application", "x-ndjson");
445374
APPLICATION_OCTET_STREAM = new MediaType("application", "octet-stream");
446375
APPLICATION_PDF = new MediaType("application", "pdf");
447376
APPLICATION_PROBLEM_JSON = new MediaType("application", "problem+json");
448-
APPLICATION_PROBLEM_JSON_UTF8 = new MediaType("application", "problem+json", StandardCharsets.UTF_8);
449377
APPLICATION_PROBLEM_XML = new MediaType("application", "problem+xml");
450378
APPLICATION_PROTOBUF = new MediaType("application", "x-protobuf");
451379
APPLICATION_RSS_XML = new MediaType("application", "rss+xml");
452-
APPLICATION_STREAM_JSON = new MediaType("application", "stream+json");
453380
APPLICATION_XHTML_XML = new MediaType("application", "xhtml+xml");
454381
APPLICATION_XML = new MediaType("application", "xml");
455382
APPLICATION_YAML = new MediaType("application", "yaml");

spring-web/src/main/java/org/springframework/http/codec/json/Jackson2JsonEncoder.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -59,10 +59,9 @@ public Jackson2JsonEncoder() {
5959
this(Jackson2ObjectMapperBuilder.json().build());
6060
}
6161

62-
@SuppressWarnings("deprecation")
6362
public Jackson2JsonEncoder(ObjectMapper mapper, MimeType... mimeTypes) {
6463
super(mapper, mimeTypes);
65-
setStreamingMediaTypes(Arrays.asList(MediaType.APPLICATION_NDJSON, MediaType.APPLICATION_STREAM_JSON));
64+
setStreamingMediaTypes(Arrays.asList(MediaType.APPLICATION_NDJSON));
6665
this.ssePrettyPrinter = initSsePrettyPrinter();
6766
}
6867

spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java

-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
5454
import static org.springframework.http.MediaType.APPLICATION_JSON;
5555
import static org.springframework.http.MediaType.APPLICATION_NDJSON;
56-
import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON;
5756
import static org.springframework.http.MediaType.APPLICATION_XML;
5857
import static org.springframework.http.codec.json.Jackson2CodecSupport.JSON_VIEW_HINT;
5958

@@ -77,11 +76,9 @@ public Jackson2JsonDecoderTests() {
7776

7877
@Override
7978
@Test
80-
@SuppressWarnings("deprecation")
8179
public void canDecode() {
8280
assertThat(decoder.canDecode(ResolvableType.forClass(Pojo.class), APPLICATION_JSON)).isTrue();
8381
assertThat(decoder.canDecode(ResolvableType.forClass(Pojo.class), APPLICATION_NDJSON)).isTrue();
84-
assertThat(decoder.canDecode(ResolvableType.forClass(Pojo.class), APPLICATION_STREAM_JSON)).isTrue();
8582
assertThat(decoder.canDecode(ResolvableType.forClass(Pojo.class), null)).isTrue();
8683

8784
assertThat(decoder.canDecode(ResolvableType.forClass(String.class), null)).isFalse();

spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonEncoderTests.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@
4949
import static org.springframework.http.MediaType.APPLICATION_JSON;
5050
import static org.springframework.http.MediaType.APPLICATION_NDJSON;
5151
import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM;
52-
import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON;
5352
import static org.springframework.http.MediaType.APPLICATION_XML;
5453
import static org.springframework.http.codec.json.Jackson2CodecSupport.JSON_VIEW_HINT;
5554

5655
/**
56+
* Tests for {@link Jackson2JsonEncoder}.
5757
* @author Sebastien Deleuze
5858
*/
5959
class Jackson2JsonEncoderTests extends AbstractEncoderTests<Jackson2JsonEncoder> {
@@ -64,12 +64,10 @@ public Jackson2JsonEncoderTests() {
6464

6565
@Override
6666
@Test
67-
@SuppressWarnings("deprecation")
6867
public void canEncode() {
6968
ResolvableType pojoType = ResolvableType.forClass(Pojo.class);
7069
assertThat(this.encoder.canEncode(pojoType, APPLICATION_JSON)).isTrue();
7170
assertThat(this.encoder.canEncode(pojoType, APPLICATION_NDJSON)).isTrue();
72-
assertThat(this.encoder.canEncode(pojoType, APPLICATION_STREAM_JSON)).isTrue();
7371
assertThat(this.encoder.canEncode(pojoType, null)).isTrue();
7472

7573
assertThat(this.encoder.canEncode(ResolvableType.forClass(Pojo.class),
@@ -94,7 +92,7 @@ public void encode() throws Exception {
9492
new Pojo("foofoo", "barbar"),
9593
new Pojo("foofoofoo", "barbarbar"));
9694

97-
testEncodeAll(input, ResolvableType.forClass(Pojo.class), APPLICATION_STREAM_JSON, null, step -> step
95+
testEncodeAll(input, ResolvableType.forClass(Pojo.class), APPLICATION_NDJSON, null, step -> step
9896
.consumeNextWith(expectString("{\"foo\":\"foo\",\"bar\":\"bar\"}\n"))
9997
.consumeNextWith(expectString("{\"foo\":\"foofoo\",\"bar\":\"barbar\"}\n"))
10098
.consumeNextWith(expectString("{\"foo\":\"foofoofoo\",\"bar\":\"barbarbar\"}\n"))

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ReactiveTypeHandler.java

-4
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ public ResponseBodyEmitter handleValue(Object returnValue, MethodParameter retur
201201
* @return the concrete streaming {@code MediaType} if one could be found or {@code null}
202202
* if none could be found
203203
*/
204-
@SuppressWarnings("deprecation")
205204
@Nullable
206205
static MediaType findConcreteJsonStreamMediaType(Collection<MediaType> acceptedMediaTypes) {
207206
for (MediaType acceptedType : acceptedMediaTypes) {
@@ -220,9 +219,6 @@ static MediaType findConcreteJsonStreamMediaType(Collection<MediaType> acceptedM
220219
else if (MediaType.APPLICATION_NDJSON.includes(acceptedType)) {
221220
return MediaType.APPLICATION_NDJSON;
222221
}
223-
else if (MediaType.APPLICATION_STREAM_JSON.includes(acceptedType)) {
224-
return MediaType.APPLICATION_STREAM_JSON;
225-
}
226222
}
227223
return null; // not a concrete streaming type
228224
}

spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ReactiveTypeHandlerTests.java

-13
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,6 @@ void findsConcreteStreamingMediaType_plainNdJsonFirst() {
158158
.isEqualTo(MediaType.APPLICATION_NDJSON);
159159
}
160160

161-
@SuppressWarnings("deprecation")
162-
@Test
163-
void findsConcreteStreamingMediaType_plainStreamingJsonFirst() {
164-
final List<MediaType> accept = List.of(
165-
MediaType.ALL,
166-
MediaType.APPLICATION_STREAM_JSON,
167-
MediaType.parseMediaType("application/*+x-ndjson"),
168-
MediaType.parseMediaType("application/vnd.myapp.v1+x-ndjson"));
169-
170-
assertThat(ReactiveTypeHandler.findConcreteJsonStreamMediaType(accept))
171-
.isEqualTo(MediaType.APPLICATION_STREAM_JSON);
172-
}
173-
174161
@Test
175162
void deferredResultSubscriberWithOneValue() throws Exception {
176163

0 commit comments

Comments
 (0)