Skip to content

Commit 810da11

Browse files
committed
Remove deprecated web APIs
This commit also marks for removal APIs that were deprecated a long time ago but were not marked for removal. See gh-33809
1 parent 5044b70 commit 810da11

File tree

13 files changed

+19
-330
lines changed

13 files changed

+19
-330
lines changed

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

+8-201
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.
@@ -20,7 +20,6 @@
2020
import java.nio.charset.Charset;
2121
import java.nio.charset.StandardCharsets;
2222
import java.time.ZonedDateTime;
23-
import java.time.format.DateTimeParseException;
2423
import java.util.ArrayList;
2524
import java.util.Base64;
2625
import java.util.BitSet;
@@ -36,7 +35,6 @@
3635
import static java.nio.charset.StandardCharsets.ISO_8859_1;
3736
import static java.nio.charset.StandardCharsets.US_ASCII;
3837
import static java.nio.charset.StandardCharsets.UTF_8;
39-
import static java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME;
4038

4139
/**
4240
* Representation of the Content-Disposition type and parameters as defined in RFC 6266.
@@ -85,34 +83,17 @@ public final class ContentDisposition {
8583
@Nullable
8684
private final Charset charset;
8785

88-
@Nullable
89-
private final Long size;
90-
91-
@Nullable
92-
private final ZonedDateTime creationDate;
93-
94-
@Nullable
95-
private final ZonedDateTime modificationDate;
96-
97-
@Nullable
98-
private final ZonedDateTime readDate;
99-
10086

10187
/**
10288
* Private constructor. See static factory methods in this class.
10389
*/
10490
private ContentDisposition(@Nullable String type, @Nullable String name, @Nullable String filename,
105-
@Nullable Charset charset, @Nullable Long size, @Nullable ZonedDateTime creationDate,
106-
@Nullable ZonedDateTime modificationDate, @Nullable ZonedDateTime readDate) {
91+
@Nullable Charset charset) {
10792

10893
this.type = type;
10994
this.name = name;
11095
this.filename = filename;
11196
this.charset = charset;
112-
this.size = size;
113-
this.creationDate = creationDate;
114-
this.modificationDate = modificationDate;
115-
this.readDate = readDate;
11697
}
11798

11899

@@ -177,71 +158,19 @@ public Charset getCharset() {
177158
return this.charset;
178159
}
179160

180-
/**
181-
* Return the value of the {@literal size} parameter, or {@code null} if not defined.
182-
* @deprecated since 5.2.3 as per
183-
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
184-
* to be removed in a future release.
185-
*/
186-
@Deprecated
187-
@Nullable
188-
public Long getSize() {
189-
return this.size;
190-
}
191-
192-
/**
193-
* Return the value of the {@literal creation-date} parameter, or {@code null} if not defined.
194-
* @deprecated since 5.2.3 as per
195-
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
196-
* to be removed in a future release.
197-
*/
198-
@Deprecated
199-
@Nullable
200-
public ZonedDateTime getCreationDate() {
201-
return this.creationDate;
202-
}
203-
204-
/**
205-
* Return the value of the {@literal modification-date} parameter, or {@code null} if not defined.
206-
* @deprecated since 5.2.3 as per
207-
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
208-
* to be removed in a future release.
209-
*/
210-
@Deprecated
211-
@Nullable
212-
public ZonedDateTime getModificationDate() {
213-
return this.modificationDate;
214-
}
215-
216-
/**
217-
* Return the value of the {@literal read-date} parameter, or {@code null} if not defined.
218-
* @deprecated since 5.2.3 as per
219-
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
220-
* to be removed in a future release.
221-
*/
222-
@Deprecated
223-
@Nullable
224-
public ZonedDateTime getReadDate() {
225-
return this.readDate;
226-
}
227161

228162
@Override
229163
public boolean equals(@Nullable Object other) {
230164
return (this == other || (other instanceof ContentDisposition that &&
231165
ObjectUtils.nullSafeEquals(this.type, that.type) &&
232166
ObjectUtils.nullSafeEquals(this.name, that.name) &&
233167
ObjectUtils.nullSafeEquals(this.filename, that.filename) &&
234-
ObjectUtils.nullSafeEquals(this.charset, that.charset) &&
235-
ObjectUtils.nullSafeEquals(this.size, that.size) &&
236-
ObjectUtils.nullSafeEquals(this.creationDate, that.creationDate)&&
237-
ObjectUtils.nullSafeEquals(this.modificationDate, that.modificationDate)&&
238-
ObjectUtils.nullSafeEquals(this.readDate, that.readDate)));
168+
ObjectUtils.nullSafeEquals(this.charset, that.charset)));
239169
}
240170

241171
@Override
242172
public int hashCode() {
243-
return ObjectUtils.nullSafeHash(this.type, this.name,this.filename,
244-
this.charset, this.size, this.creationDate, this.modificationDate, this.readDate);
173+
return ObjectUtils.nullSafeHash(this.type, this.name,this.filename, this.charset);
245174
}
246175

247176
/**
@@ -270,25 +199,6 @@ public String toString() {
270199
sb.append(encodeRfc5987Filename(this.filename, this.charset));
271200
}
272201
}
273-
if (this.size != null) {
274-
sb.append("; size=");
275-
sb.append(this.size);
276-
}
277-
if (this.creationDate != null) {
278-
sb.append("; creation-date=\"");
279-
sb.append(RFC_1123_DATE_TIME.format(this.creationDate));
280-
sb.append('\"');
281-
}
282-
if (this.modificationDate != null) {
283-
sb.append("; modification-date=\"");
284-
sb.append(RFC_1123_DATE_TIME.format(this.modificationDate));
285-
sb.append('\"');
286-
}
287-
if (this.readDate != null) {
288-
sb.append("; read-date=\"");
289-
sb.append(RFC_1123_DATE_TIME.format(this.readDate));
290-
sb.append('\"');
291-
}
292202
return sb.toString();
293203
}
294204

@@ -331,7 +241,7 @@ public static Builder builder(String type) {
331241
* Return an empty content disposition.
332242
*/
333243
public static ContentDisposition empty() {
334-
return new ContentDisposition("", null, null, null, null, null, null, null);
244+
return new ContentDisposition("", null, null, null);
335245
}
336246

337247
/**
@@ -376,7 +286,7 @@ else if (attribute.equals("filename*") ) {
376286
}
377287
}
378288
else if (attribute.equals("filename") && (filename == null)) {
379-
if (value.startsWith("=?") ) {
289+
if (value.startsWith("=?")) {
380290
Matcher matcher = BASE64_ENCODED_PATTERN.matcher(value);
381291
if (matcher.find()) {
382292
Base64.Decoder decoder = Base64.getDecoder();
@@ -415,39 +325,12 @@ else if (value.indexOf('\\') != -1) {
415325
filename = value;
416326
}
417327
}
418-
else if (attribute.equals("size") ) {
419-
size = Long.parseLong(value);
420-
}
421-
else if (attribute.equals("creation-date")) {
422-
try {
423-
creationDate = ZonedDateTime.parse(value, RFC_1123_DATE_TIME);
424-
}
425-
catch (DateTimeParseException ex) {
426-
// ignore
427-
}
428-
}
429-
else if (attribute.equals("modification-date")) {
430-
try {
431-
modificationDate = ZonedDateTime.parse(value, RFC_1123_DATE_TIME);
432-
}
433-
catch (DateTimeParseException ex) {
434-
// ignore
435-
}
436-
}
437-
else if (attribute.equals("read-date")) {
438-
try {
439-
readDate = ZonedDateTime.parse(value, RFC_1123_DATE_TIME);
440-
}
441-
catch (DateTimeParseException ex) {
442-
// ignore
443-
}
444-
}
445328
}
446329
else {
447330
throw new IllegalArgumentException("Invalid content disposition format");
448331
}
449332
}
450-
return new ContentDisposition(type, name, filename, charset, size, creationDate, modificationDate, readDate);
333+
return new ContentDisposition(type, name, filename, charset);
451334
}
452335

453336
private static List<String> tokenize(String headerValue) {
@@ -714,42 +597,6 @@ public interface Builder {
714597
*/
715598
Builder filename(@Nullable String filename, @Nullable Charset charset);
716599

717-
/**
718-
* Set the value of the {@literal size} parameter.
719-
* @deprecated since 5.2.3 as per
720-
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
721-
* to be removed in a future release.
722-
*/
723-
@Deprecated
724-
Builder size(@Nullable Long size);
725-
726-
/**
727-
* Set the value of the {@literal creation-date} parameter.
728-
* @deprecated since 5.2.3 as per
729-
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
730-
* to be removed in a future release.
731-
*/
732-
@Deprecated
733-
Builder creationDate(@Nullable ZonedDateTime creationDate);
734-
735-
/**
736-
* Set the value of the {@literal modification-date} parameter.
737-
* @deprecated since 5.2.3 as per
738-
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
739-
* to be removed in a future release.
740-
*/
741-
@Deprecated
742-
Builder modificationDate(@Nullable ZonedDateTime modificationDate);
743-
744-
/**
745-
* Set the value of the {@literal read-date} parameter.
746-
* @deprecated since 5.2.3 as per
747-
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
748-
* to be removed in a future release.
749-
*/
750-
@Deprecated
751-
Builder readDate(@Nullable ZonedDateTime readDate);
752-
753600
/**
754601
* Build the content disposition.
755602
*/
@@ -770,17 +617,6 @@ private static class BuilderImpl implements Builder {
770617
@Nullable
771618
private Charset charset;
772619

773-
@Nullable
774-
private Long size;
775-
776-
@Nullable
777-
private ZonedDateTime creationDate;
778-
779-
@Nullable
780-
private ZonedDateTime modificationDate;
781-
782-
@Nullable
783-
private ZonedDateTime readDate;
784620

785621
public BuilderImpl(String type) {
786622
Assert.hasText(type, "'type' must not be not empty");
@@ -806,38 +642,9 @@ public Builder filename(@Nullable String filename, @Nullable Charset charset) {
806642
return this;
807643
}
808644

809-
@Override
810-
@SuppressWarnings("deprecation")
811-
public Builder size(@Nullable Long size) {
812-
this.size = size;
813-
return this;
814-
}
815-
816-
@Override
817-
@SuppressWarnings("deprecation")
818-
public Builder creationDate(@Nullable ZonedDateTime creationDate) {
819-
this.creationDate = creationDate;
820-
return this;
821-
}
822-
823-
@Override
824-
@SuppressWarnings("deprecation")
825-
public Builder modificationDate(@Nullable ZonedDateTime modificationDate) {
826-
this.modificationDate = modificationDate;
827-
return this;
828-
}
829-
830-
@Override
831-
@SuppressWarnings("deprecation")
832-
public Builder readDate(@Nullable ZonedDateTime readDate) {
833-
this.readDate = readDate;
834-
return this;
835-
}
836-
837645
@Override
838646
public ContentDisposition build() {
839-
return new ContentDisposition(this.type, this.name, this.filename, this.charset,
840-
this.size, this.creationDate, this.modificationDate, this.readDate);
647+
return new ContentDisposition(this.type, this.name, this.filename, this.charset);
841648
}
842649
}
843650

spring-web/src/main/java/org/springframework/web/HttpMediaTypeException.java

-20
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,6 @@ public abstract class HttpMediaTypeException extends ServletException implements
4444
private final Object[] messageDetailArguments;
4545

4646

47-
/**
48-
* Create a new HttpMediaTypeException.
49-
* @param message the exception message
50-
* @deprecated as of 6.0
51-
*/
52-
@Deprecated
53-
protected HttpMediaTypeException(String message) {
54-
this(message, Collections.emptyList());
55-
}
56-
57-
/**
58-
* Create a new HttpMediaTypeException with a list of supported media types.
59-
* @param supportedMediaTypes the list of supported media types
60-
* @deprecated as of 6.0
61-
*/
62-
@Deprecated
63-
protected HttpMediaTypeException(String message, List<MediaType> supportedMediaTypes) {
64-
this(message, supportedMediaTypes, null, null);
65-
}
66-
6747
/**
6848
* Create a new HttpMediaTypeException with a list of supported media types.
6949
* @param supportedMediaTypes the list of supported media types

spring-web/src/main/java/org/springframework/web/client/RestClientResponseException.java

-9
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,6 @@ public HttpStatusCode getStatusCode() {
123123
return this.statusCode;
124124
}
125125

126-
/**
127-
* Return the raw HTTP status code value.
128-
* @deprecated in favor of {@link #getStatusCode()}, for removal in 7.0
129-
*/
130-
@Deprecated(since = "6.0")
131-
public int getRawStatusCode() {
132-
return this.statusCode.value();
133-
}
134-
135126
/**
136127
* Return the HTTP status text.
137128
*/

spring-web/src/main/java/org/springframework/web/server/MethodNotAllowedException.java

-11
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,6 @@ public HttpHeaders getHeaders() {
7676
return headers;
7777
}
7878

79-
/**
80-
* Delegates to {@link #getHeaders()}.
81-
* @since 5.1.13
82-
* @deprecated as of 6.0 in favor of {@link #getHeaders()}
83-
*/
84-
@Deprecated(since = "6.0")
85-
@Override
86-
public HttpHeaders getResponseHeaders() {
87-
return getHeaders();
88-
}
89-
9079
/**
9180
* Return the HTTP method for the failed request.
9281
*/

spring-web/src/main/java/org/springframework/web/server/NotAcceptableStatusException.java

-11
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,6 @@ public HttpHeaders getHeaders() {
7676
return headers;
7777
}
7878

79-
/**
80-
* Delegates to {@link #getHeaders()}.
81-
* @since 5.1.13
82-
* @deprecated as of 6.0 in favor of {@link #getHeaders()}
83-
*/
84-
@Deprecated(since = "6.0")
85-
@Override
86-
public HttpHeaders getResponseHeaders() {
87-
return getHeaders();
88-
}
89-
9079
/**
9180
* Return the list of supported content types in cases when the Accept
9281
* header is parsed but not supported, or an empty list otherwise.

0 commit comments

Comments
 (0)