Skip to content

Commit 785aab8

Browse files
committed
Rename ApiDeprecationHandler to insert "Version"
The name is a bit long, but it is necessary to indicate it's a handler for a deprecation version, and the decision is based on the version, not an individual endpoint. See gh-35049
1 parent 7606a92 commit 785aab8

File tree

14 files changed

+47
-47
lines changed

14 files changed

+47
-47
lines changed

spring-web/src/main/java/org/springframework/web/accept/ApiDeprecationHandler.java renamed to spring-web/src/main/java/org/springframework/web/accept/ApiVersionDeprecationHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
/**
2323
* Contract to add handling of requests with a deprecated API version. Typically,
2424
* this involves use of response headers to send hints and information about
25-
* the deprecation to clients.
25+
* the deprecated version to clients.
2626
*
2727
* @author Rossen Stoyanchev
2828
* @since 7.0
29-
* @see StandardApiDeprecationHandler
29+
* @see StandardApiVersionDeprecationHandler
3030
*/
31-
public interface ApiDeprecationHandler {
31+
public interface ApiVersionDeprecationHandler {
3232

3333
/**
3434
* Check if the requested API version is deprecated, and if so handle it

spring-web/src/main/java/org/springframework/web/accept/ApiVersionStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void validateVersion(@Nullable Comparable<?> requestVersion, HttpServletRequest
6969
* @param version the resolved and parsed request version
7070
* @param request the current request
7171
* @param response the current response
72-
* @see ApiDeprecationHandler
72+
* @see ApiVersionDeprecationHandler
7373
*/
7474
void handleDeprecations(Comparable<?> version, HttpServletRequest request, HttpServletResponse response);
7575

spring-web/src/main/java/org/springframework/web/accept/DefaultApiVersionStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class DefaultApiVersionStrategy implements ApiVersionStrategy {
4444

4545
private final @Nullable Comparable<?> defaultVersion;
4646

47-
private final @Nullable ApiDeprecationHandler deprecationHandler;
47+
private final @Nullable ApiVersionDeprecationHandler deprecationHandler;
4848

4949
private final Set<Comparable<?>> supportedVersions = new TreeSet<>();
5050

@@ -65,7 +65,7 @@ public class DefaultApiVersionStrategy implements ApiVersionStrategy {
6565
public DefaultApiVersionStrategy(
6666
List<ApiVersionResolver> versionResolvers, ApiVersionParser<?> versionParser,
6767
boolean versionRequired, @Nullable String defaultVersion,
68-
@Nullable ApiDeprecationHandler deprecationHandler) {
68+
@Nullable ApiVersionDeprecationHandler deprecationHandler) {
6969

7070
Assert.notEmpty(versionResolvers, "At least one ApiVersionResolver is required");
7171
Assert.notNull(versionParser, "ApiVersionParser is required");

spring-web/src/main/java/org/springframework/web/accept/StandardApiDeprecationHandler.java renamed to spring-web/src/main/java/org/springframework/web/accept/StandardApiVersionDeprecationHandler.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import org.springframework.util.Assert;
3434

3535
/**
36-
* {@code ApiDeprecationHandler} based on
36+
* {@code ApiVersionDeprecationHandler} based on
3737
* <a href="https://datatracker.ietf.org/doc/html/rfc9745">RFC 9745</a> and
3838
* <a href="https://datatracker.ietf.org/doc/html/rfc8594">RFC 8594</a> that
3939
* provides the option to set the "Deprecation" and "Sunset" response headers,
@@ -45,7 +45,7 @@
4545
* @author Rossen Stoyanchev
4646
* @since 7.0
4747
*/
48-
public class StandardApiDeprecationHandler implements ApiDeprecationHandler {
48+
public class StandardApiVersionDeprecationHandler implements ApiVersionDeprecationHandler {
4949

5050
private final ApiVersionParser<?> versionParser;
5151

@@ -57,9 +57,9 @@ public class StandardApiDeprecationHandler implements ApiDeprecationHandler {
5757
* <p>By default, {@link SemanticApiVersionParser} is used to parse configured
5858
* API versions, so those can be compared to request versions parsed at runtime.
5959
* If you have a custom parser, then please use the
60-
* {@link #StandardApiDeprecationHandler(ApiVersionParser)} constructor.
60+
* {@link #StandardApiVersionDeprecationHandler(ApiVersionParser)} constructor.
6161
*/
62-
public StandardApiDeprecationHandler() {
62+
public StandardApiVersionDeprecationHandler() {
6363
this(new SemanticApiVersionParser());
6464
}
6565

@@ -68,7 +68,7 @@ public StandardApiDeprecationHandler() {
6868
* This needs to be the same as the parser type used at runtime to parse
6969
* request versions.
7070
*/
71-
public StandardApiDeprecationHandler(ApiVersionParser<?> parser) {
71+
public StandardApiVersionDeprecationHandler(ApiVersionParser<?> parser) {
7272
this.versionParser = parser;
7373
}
7474

@@ -109,7 +109,7 @@ public void handleVersion(
109109

110110
@Override
111111
public String toString() {
112-
return "StandardApiDeprecationHandler " + this.infos.values();
112+
return "StandardApiVersionDeprecationHandler " + this.infos.values();
113113
}
114114

115115

@@ -122,7 +122,7 @@ public final class VersionSpec {
122122

123123
private VersionSpec(Comparable<?> version) {
124124
this.version = version;
125-
StandardApiDeprecationHandler.this.infos.put(version, new VersionInfo(version));
125+
StandardApiVersionDeprecationHandler.this.infos.put(version, new VersionInfo(version));
126126
}
127127

128128
/**
@@ -198,7 +198,7 @@ public VersionSpec setSunsetLink(URI uri, MediaType mediaType) {
198198
}
199199

200200
private VersionSpec map(Function<VersionInfo, VersionInfo> function) {
201-
StandardApiDeprecationHandler.this.infos.compute(this.version, (version, versionInfo) -> {
201+
StandardApiVersionDeprecationHandler.this.infos.compute(this.version, (version, versionInfo) -> {
202202
Assert.state(versionInfo != null, "No VersionInfo");
203203
return function.apply(versionInfo);
204204
});

spring-web/src/test/java/org/springframework/web/accept/StandardApiDeprecationHandlerTests.java renamed to spring-web/src/test/java/org/springframework/web/accept/StandardApiVersionDeprecationHandlerTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
import static org.assertj.core.api.Assertions.assertThat;
2929

3030
/**
31-
* Unit tests for {@link StandardApiDeprecationHandler}.
31+
* Unit tests for {@link StandardApiVersionDeprecationHandler}.
3232
* @author Rossen Stoyanchev
3333
*/
34-
public class StandardApiDeprecationHandlerTests {
34+
public class StandardApiVersionDeprecationHandlerTests {
3535

3636
private final MockHttpServletRequest request = new MockHttpServletRequest();
3737

@@ -45,7 +45,7 @@ void basic() {
4545
String sunsetUrl = "https://example.org/sunset";
4646

4747
ApiVersionParser<String> parser = version -> version;
48-
StandardApiDeprecationHandler handler = new StandardApiDeprecationHandler(parser);
48+
StandardApiVersionDeprecationHandler handler = new StandardApiVersionDeprecationHandler(parser);
4949

5050
handler.configureVersion("1.1")
5151
.setDeprecationDate(getDate("Fri, 30 Jun 2023 23:59:59 GMT"))

spring-webflux/src/main/java/org/springframework/web/reactive/accept/ApiDeprecationHandler.java renamed to spring-webflux/src/main/java/org/springframework/web/reactive/accept/ApiVersionDeprecationHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
/**
2222
* Contract to add handling of requests with a deprecated API version. Typically,
2323
* this involves use of response headers to send hints and information about
24-
* the deprecation to clients.
24+
* the deprecated version to clients.
2525
*
2626
* @author Rossen Stoyanchev
2727
* @since 7.0
2828
*/
29-
public interface ApiDeprecationHandler {
29+
public interface ApiVersionDeprecationHandler {
3030

3131
/**
3232
* Check if the requested API version is deprecated, and if so handle it

spring-webflux/src/main/java/org/springframework/web/reactive/accept/ApiVersionStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void validateVersion(@Nullable Comparable<?> requestVersion, ServerWebExchange e
7070
* to specify relevant dates and provide links to further details.
7171
* @param version the resolved and parsed request version
7272
* @param exchange the current exchange
73-
* @see ApiDeprecationHandler
73+
* @see ApiVersionDeprecationHandler
7474
*/
7575
void handleDeprecations(Comparable<?> version, ServerWebExchange exchange);
7676

spring-webflux/src/main/java/org/springframework/web/reactive/accept/DefaultApiVersionStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class DefaultApiVersionStrategy implements ApiVersionStrategy {
5252

5353
private final Set<Comparable<?>> detectedVersions = new TreeSet<>();
5454

55-
private final @Nullable ApiDeprecationHandler deprecationHandler;
55+
private final @Nullable ApiVersionDeprecationHandler deprecationHandler;
5656

5757

5858
/**
@@ -74,7 +74,7 @@ public class DefaultApiVersionStrategy implements ApiVersionStrategy {
7474
public DefaultApiVersionStrategy(
7575
List<ApiVersionResolver> versionResolvers, ApiVersionParser<?> versionParser,
7676
boolean versionRequired, @Nullable String defaultVersion, boolean detectSupportedVersions,
77-
@Nullable ApiDeprecationHandler deprecationHandler) {
77+
@Nullable ApiVersionDeprecationHandler deprecationHandler) {
7878

7979
Assert.notEmpty(versionResolvers, "At least one ApiVersionResolver is required");
8080
Assert.notNull(versionParser, "ApiVersionParser is required");

spring-webflux/src/main/java/org/springframework/web/reactive/accept/StandardApiDeprecationHandler.java renamed to spring-webflux/src/main/java/org/springframework/web/reactive/accept/StandardApiVersionDeprecationHandler.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import org.springframework.web.server.ServerWebExchange;
3535

3636
/**
37-
* {@code ApiDeprecationHandler} based on
37+
* {@code ApiVersionDeprecationHandler} based on
3838
* <a href="https://datatracker.ietf.org/doc/html/rfc9745">RFC 9745</a> and
3939
* <a href="https://datatracker.ietf.org/doc/html/rfc8594">RFC 8594</a> that
4040
* provides the option to set the "Deprecation" and "Sunset" response headers,
@@ -46,7 +46,7 @@
4646
* @author Rossen Stoyanchev
4747
* @since 7.0
4848
*/
49-
public class StandardApiDeprecationHandler implements ApiDeprecationHandler {
49+
public class StandardApiVersionDeprecationHandler implements ApiVersionDeprecationHandler {
5050

5151
private final ApiVersionParser<?> versionParser;
5252

@@ -58,9 +58,9 @@ public class StandardApiDeprecationHandler implements ApiDeprecationHandler {
5858
* <p>By default, {@link SemanticApiVersionParser} is used to parse configured
5959
* API versions, so those can be compared to request versions parsed at runtime.
6060
* If you have a custom parser, then please use the
61-
* {@link #StandardApiDeprecationHandler(ApiVersionParser)} constructor.
61+
* {@link #StandardApiVersionDeprecationHandler(ApiVersionParser)} constructor.
6262
*/
63-
public StandardApiDeprecationHandler() {
63+
public StandardApiVersionDeprecationHandler() {
6464
this(new SemanticApiVersionParser());
6565
}
6666

@@ -69,7 +69,7 @@ public StandardApiDeprecationHandler() {
6969
* This needs to be the same as the parser type used at runtime to parse
7070
* request versions.
7171
*/
72-
public StandardApiDeprecationHandler(ApiVersionParser<?> parser) {
72+
public StandardApiVersionDeprecationHandler(ApiVersionParser<?> parser) {
7373
this.versionParser = parser;
7474
}
7575

@@ -108,7 +108,7 @@ public void handleVersion(Comparable<?> requestVersion, ServerWebExchange exchan
108108

109109
@Override
110110
public String toString() {
111-
return "StandardApiDeprecationHandler " + this.infos.values();
111+
return "StandardApiVersionDeprecationHandler " + this.infos.values();
112112
}
113113

114114

@@ -121,7 +121,7 @@ public final class VersionSpec {
121121

122122
private VersionSpec(Comparable<?> version) {
123123
this.version = version;
124-
StandardApiDeprecationHandler.this.infos.put(version, new VersionInfo(version));
124+
StandardApiVersionDeprecationHandler.this.infos.put(version, new VersionInfo(version));
125125
}
126126

127127
/**
@@ -197,7 +197,7 @@ public VersionSpec setSunsetLink(URI uri, MediaType mediaType) {
197197
}
198198

199199
private VersionSpec map(Function<VersionInfo, VersionInfo> function) {
200-
StandardApiDeprecationHandler.this.infos.compute(this.version, (version, versionInfo) -> {
200+
StandardApiVersionDeprecationHandler.this.infos.compute(this.version, (version, versionInfo) -> {
201201
Assert.state(versionInfo != null, "No VersionInfo");
202202
return function.apply(versionInfo);
203203
});

spring-webflux/src/main/java/org/springframework/web/reactive/config/ApiVersionConfigurer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
import org.springframework.web.accept.ApiVersionParser;
3030
import org.springframework.web.accept.InvalidApiVersionException;
3131
import org.springframework.web.accept.SemanticApiVersionParser;
32-
import org.springframework.web.reactive.accept.ApiDeprecationHandler;
32+
import org.springframework.web.reactive.accept.ApiVersionDeprecationHandler;
3333
import org.springframework.web.reactive.accept.ApiVersionResolver;
3434
import org.springframework.web.reactive.accept.ApiVersionStrategy;
3535
import org.springframework.web.reactive.accept.DefaultApiVersionStrategy;
3636
import org.springframework.web.reactive.accept.MediaTypeParamApiVersionResolver;
3737
import org.springframework.web.reactive.accept.PathApiVersionResolver;
38-
import org.springframework.web.reactive.accept.StandardApiDeprecationHandler;
38+
import org.springframework.web.reactive.accept.StandardApiVersionDeprecationHandler;
3939

4040
/**
4141
* Configure API versioning.
@@ -53,7 +53,7 @@ public class ApiVersionConfigurer {
5353

5454
private @Nullable String defaultVersion;
5555

56-
private @Nullable ApiDeprecationHandler deprecationHandler;
56+
private @Nullable ApiVersionDeprecationHandler deprecationHandler;
5757

5858
private final Set<String> supportedVersions = new LinkedHashSet<>();
5959

@@ -150,9 +150,9 @@ public ApiVersionConfigurer setDefaultVersion(@Nullable String defaultVersion) {
150150
* version. Typically, this involves sending hints and information about
151151
* the deprecation in response headers.
152152
* @param handler the handler to use
153-
* @see StandardApiDeprecationHandler
153+
* @see StandardApiVersionDeprecationHandler
154154
*/
155-
public ApiVersionConfigurer setDeprecationHandler(ApiDeprecationHandler handler) {
155+
public ApiVersionConfigurer setDeprecationHandler(ApiVersionDeprecationHandler handler) {
156156
this.deprecationHandler = handler;
157157
return this;
158158
}

0 commit comments

Comments
 (0)