Skip to content

Commit

Permalink
Remove deprecated web APIs
Browse files Browse the repository at this point in the history
This commit also marks for removal APIs that were deprecated a long time
ago but were not marked for removal.

See spring-projectsgh-33809
  • Loading branch information
bclozel committed Dec 8, 2024
1 parent 5044b70 commit 810da11
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 330 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -20,7 +20,6 @@
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.time.ZonedDateTime;
import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.Base64;
import java.util.BitSet;
Expand All @@ -36,7 +35,6 @@
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.US_ASCII;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME;

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

@Nullable
private final Long size;

@Nullable
private final ZonedDateTime creationDate;

@Nullable
private final ZonedDateTime modificationDate;

@Nullable
private final ZonedDateTime readDate;


/**
* Private constructor. See static factory methods in this class.
*/
private ContentDisposition(@Nullable String type, @Nullable String name, @Nullable String filename,
@Nullable Charset charset, @Nullable Long size, @Nullable ZonedDateTime creationDate,
@Nullable ZonedDateTime modificationDate, @Nullable ZonedDateTime readDate) {
@Nullable Charset charset) {

this.type = type;
this.name = name;
this.filename = filename;
this.charset = charset;
this.size = size;
this.creationDate = creationDate;
this.modificationDate = modificationDate;
this.readDate = readDate;
}


Expand Down Expand Up @@ -177,71 +158,19 @@ public Charset getCharset() {
return this.charset;
}

/**
* Return the value of the {@literal size} parameter, or {@code null} if not defined.
* @deprecated since 5.2.3 as per
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
* to be removed in a future release.
*/
@Deprecated
@Nullable
public Long getSize() {
return this.size;
}

/**
* Return the value of the {@literal creation-date} parameter, or {@code null} if not defined.
* @deprecated since 5.2.3 as per
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
* to be removed in a future release.
*/
@Deprecated
@Nullable
public ZonedDateTime getCreationDate() {
return this.creationDate;
}

/**
* Return the value of the {@literal modification-date} parameter, or {@code null} if not defined.
* @deprecated since 5.2.3 as per
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
* to be removed in a future release.
*/
@Deprecated
@Nullable
public ZonedDateTime getModificationDate() {
return this.modificationDate;
}

/**
* Return the value of the {@literal read-date} parameter, or {@code null} if not defined.
* @deprecated since 5.2.3 as per
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
* to be removed in a future release.
*/
@Deprecated
@Nullable
public ZonedDateTime getReadDate() {
return this.readDate;
}

@Override
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof ContentDisposition that &&
ObjectUtils.nullSafeEquals(this.type, that.type) &&
ObjectUtils.nullSafeEquals(this.name, that.name) &&
ObjectUtils.nullSafeEquals(this.filename, that.filename) &&
ObjectUtils.nullSafeEquals(this.charset, that.charset) &&
ObjectUtils.nullSafeEquals(this.size, that.size) &&
ObjectUtils.nullSafeEquals(this.creationDate, that.creationDate)&&
ObjectUtils.nullSafeEquals(this.modificationDate, that.modificationDate)&&
ObjectUtils.nullSafeEquals(this.readDate, that.readDate)));
ObjectUtils.nullSafeEquals(this.charset, that.charset)));
}

@Override
public int hashCode() {
return ObjectUtils.nullSafeHash(this.type, this.name,this.filename,
this.charset, this.size, this.creationDate, this.modificationDate, this.readDate);
return ObjectUtils.nullSafeHash(this.type, this.name,this.filename, this.charset);
}

/**
Expand Down Expand Up @@ -270,25 +199,6 @@ public String toString() {
sb.append(encodeRfc5987Filename(this.filename, this.charset));
}
}
if (this.size != null) {
sb.append("; size=");
sb.append(this.size);
}
if (this.creationDate != null) {
sb.append("; creation-date=\"");
sb.append(RFC_1123_DATE_TIME.format(this.creationDate));
sb.append('\"');
}
if (this.modificationDate != null) {
sb.append("; modification-date=\"");
sb.append(RFC_1123_DATE_TIME.format(this.modificationDate));
sb.append('\"');
}
if (this.readDate != null) {
sb.append("; read-date=\"");
sb.append(RFC_1123_DATE_TIME.format(this.readDate));
sb.append('\"');
}
return sb.toString();
}

Expand Down Expand Up @@ -331,7 +241,7 @@ public static Builder builder(String type) {
* Return an empty content disposition.
*/
public static ContentDisposition empty() {
return new ContentDisposition("", null, null, null, null, null, null, null);
return new ContentDisposition("", null, null, null);
}

/**
Expand Down Expand Up @@ -376,7 +286,7 @@ else if (attribute.equals("filename*") ) {
}
}
else if (attribute.equals("filename") && (filename == null)) {
if (value.startsWith("=?") ) {
if (value.startsWith("=?")) {
Matcher matcher = BASE64_ENCODED_PATTERN.matcher(value);
if (matcher.find()) {
Base64.Decoder decoder = Base64.getDecoder();
Expand Down Expand Up @@ -415,39 +325,12 @@ else if (value.indexOf('\\') != -1) {
filename = value;
}
}
else if (attribute.equals("size") ) {
size = Long.parseLong(value);
}
else if (attribute.equals("creation-date")) {
try {
creationDate = ZonedDateTime.parse(value, RFC_1123_DATE_TIME);
}
catch (DateTimeParseException ex) {
// ignore
}
}
else if (attribute.equals("modification-date")) {
try {
modificationDate = ZonedDateTime.parse(value, RFC_1123_DATE_TIME);
}
catch (DateTimeParseException ex) {
// ignore
}
}
else if (attribute.equals("read-date")) {
try {
readDate = ZonedDateTime.parse(value, RFC_1123_DATE_TIME);
}
catch (DateTimeParseException ex) {
// ignore
}
}
}
else {
throw new IllegalArgumentException("Invalid content disposition format");
}
}
return new ContentDisposition(type, name, filename, charset, size, creationDate, modificationDate, readDate);
return new ContentDisposition(type, name, filename, charset);
}

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

/**
* Set the value of the {@literal size} parameter.
* @deprecated since 5.2.3 as per
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
* to be removed in a future release.
*/
@Deprecated
Builder size(@Nullable Long size);

/**
* Set the value of the {@literal creation-date} parameter.
* @deprecated since 5.2.3 as per
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
* to be removed in a future release.
*/
@Deprecated
Builder creationDate(@Nullable ZonedDateTime creationDate);

/**
* Set the value of the {@literal modification-date} parameter.
* @deprecated since 5.2.3 as per
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
* to be removed in a future release.
*/
@Deprecated
Builder modificationDate(@Nullable ZonedDateTime modificationDate);

/**
* Set the value of the {@literal read-date} parameter.
* @deprecated since 5.2.3 as per
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
* to be removed in a future release.
*/
@Deprecated
Builder readDate(@Nullable ZonedDateTime readDate);

/**
* Build the content disposition.
*/
Expand All @@ -770,17 +617,6 @@ private static class BuilderImpl implements Builder {
@Nullable
private Charset charset;

@Nullable
private Long size;

@Nullable
private ZonedDateTime creationDate;

@Nullable
private ZonedDateTime modificationDate;

@Nullable
private ZonedDateTime readDate;

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

@Override
@SuppressWarnings("deprecation")
public Builder size(@Nullable Long size) {
this.size = size;
return this;
}

@Override
@SuppressWarnings("deprecation")
public Builder creationDate(@Nullable ZonedDateTime creationDate) {
this.creationDate = creationDate;
return this;
}

@Override
@SuppressWarnings("deprecation")
public Builder modificationDate(@Nullable ZonedDateTime modificationDate) {
this.modificationDate = modificationDate;
return this;
}

@Override
@SuppressWarnings("deprecation")
public Builder readDate(@Nullable ZonedDateTime readDate) {
this.readDate = readDate;
return this;
}

@Override
public ContentDisposition build() {
return new ContentDisposition(this.type, this.name, this.filename, this.charset,
this.size, this.creationDate, this.modificationDate, this.readDate);
return new ContentDisposition(this.type, this.name, this.filename, this.charset);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,6 @@ public abstract class HttpMediaTypeException extends ServletException implements
private final Object[] messageDetailArguments;


/**
* Create a new HttpMediaTypeException.
* @param message the exception message
* @deprecated as of 6.0
*/
@Deprecated
protected HttpMediaTypeException(String message) {
this(message, Collections.emptyList());
}

/**
* Create a new HttpMediaTypeException with a list of supported media types.
* @param supportedMediaTypes the list of supported media types
* @deprecated as of 6.0
*/
@Deprecated
protected HttpMediaTypeException(String message, List<MediaType> supportedMediaTypes) {
this(message, supportedMediaTypes, null, null);
}

/**
* Create a new HttpMediaTypeException with a list of supported media types.
* @param supportedMediaTypes the list of supported media types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,6 @@ public HttpStatusCode getStatusCode() {
return this.statusCode;
}

/**
* Return the raw HTTP status code value.
* @deprecated in favor of {@link #getStatusCode()}, for removal in 7.0
*/
@Deprecated(since = "6.0")
public int getRawStatusCode() {
return this.statusCode.value();
}

/**
* Return the HTTP status text.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,6 @@ public HttpHeaders getHeaders() {
return headers;
}

/**
* Delegates to {@link #getHeaders()}.
* @since 5.1.13
* @deprecated as of 6.0 in favor of {@link #getHeaders()}
*/
@Deprecated(since = "6.0")
@Override
public HttpHeaders getResponseHeaders() {
return getHeaders();
}

/**
* Return the HTTP method for the failed request.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,6 @@ public HttpHeaders getHeaders() {
return headers;
}

/**
* Delegates to {@link #getHeaders()}.
* @since 5.1.13
* @deprecated as of 6.0 in favor of {@link #getHeaders()}
*/
@Deprecated(since = "6.0")
@Override
public HttpHeaders getResponseHeaders() {
return getHeaders();
}

/**
* Return the list of supported content types in cases when the Accept
* header is parsed but not supported, or an empty list otherwise.
Expand Down
Loading

0 comments on commit 810da11

Please sign in to comment.