From 49d688f99c1ff9cb44a0c61e413fed46da9d83a1 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Tue, 30 May 2023 11:11:09 +0200 Subject: [PATCH] Mark ClientHttpResponse::getRawStatusCode for removal --- .../mock/http/client/MockClientHttpResponse.java | 8 +------- .../http/client/AbstractClientHttpResponse.java | 5 +++-- .../http/client/BufferingClientHttpResponseWrapper.java | 8 +------- .../springframework/http/client/ClientHttpResponse.java | 8 +++++--- .../http/client/HttpComponentsClientHttpResponse.java | 8 +------- .../http/client/OkHttp3ClientHttpResponse.java | 8 +------- .../http/client/SimpleClientHttpResponse.java | 6 ------ .../web/client/ClientHttpResponseDecorator.java | 8 +------- .../testfixture/http/client/MockClientHttpResponse.java | 8 +------- 9 files changed, 14 insertions(+), 53 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpResponse.java b/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpResponse.java index ec164e005d..328068f111 100644 --- a/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpResponse.java +++ b/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -90,12 +90,6 @@ public class MockClientHttpResponse extends MockHttpInputMessage implements Clie return this.statusCode; } - @Override - @Deprecated - public int getRawStatusCode() { - return this.statusCode.value(); - } - @Override public String getStatusText() { return (this.statusCode instanceof HttpStatus status ? status.getReasonPhrase() : ""); diff --git a/spring-web/src/main/java/org/springframework/http/client/AbstractClientHttpResponse.java b/spring-web/src/main/java/org/springframework/http/client/AbstractClientHttpResponse.java index db9e5d1961..08fd2b3cb9 100644 --- a/spring-web/src/main/java/org/springframework/http/client/AbstractClientHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/client/AbstractClientHttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -27,10 +27,11 @@ import org.springframework.http.HttpStatusCode; * @since 3.1.1 * @deprecated as of 6.0, with no direct replacement */ -@Deprecated(since = "6.0") +@Deprecated(since = "6.0", forRemoval = true) public abstract class AbstractClientHttpResponse implements ClientHttpResponse { @Override + @SuppressWarnings("removal") public HttpStatusCode getStatusCode() throws IOException { return HttpStatusCode.valueOf(getRawStatusCode()); } diff --git a/spring-web/src/main/java/org/springframework/http/client/BufferingClientHttpResponseWrapper.java b/spring-web/src/main/java/org/springframework/http/client/BufferingClientHttpResponseWrapper.java index 5c23f6b980..482a23e7da 100644 --- a/spring-web/src/main/java/org/springframework/http/client/BufferingClientHttpResponseWrapper.java +++ b/spring-web/src/main/java/org/springframework/http/client/BufferingClientHttpResponseWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2023 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. @@ -50,12 +50,6 @@ final class BufferingClientHttpResponseWrapper implements ClientHttpResponse { return this.response.getStatusCode(); } - @Override - @Deprecated - public int getRawStatusCode() throws IOException { - return this.response.getRawStatusCode(); - } - @Override public String getStatusText() throws IOException { return this.response.getStatusText(); diff --git a/spring-web/src/main/java/org/springframework/http/client/ClientHttpResponse.java b/spring-web/src/main/java/org/springframework/http/client/ClientHttpResponse.java index ab4001df32..f879c3db90 100644 --- a/spring-web/src/main/java/org/springframework/http/client/ClientHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/client/ClientHttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -50,8 +50,10 @@ public interface ClientHttpResponse extends HttpInputMessage, Closeable { * @see #getStatusCode() * @deprecated as of 6.0, in favor of {@link #getStatusCode()} */ - @Deprecated(since = "6.0") - int getRawStatusCode() throws IOException; + @Deprecated(since = "6.0", forRemoval = true) + default int getRawStatusCode() throws IOException { + return getStatusCode().value(); + } /** * Get the HTTP status text of the response. diff --git a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpResponse.java b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpResponse.java index 9e7b59e5ba..b4090bad14 100644 --- a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -57,12 +57,6 @@ final class HttpComponentsClientHttpResponse implements ClientHttpResponse { return HttpStatusCode.valueOf(this.httpResponse.getCode()); } - @Override - @Deprecated - public int getRawStatusCode() { - return this.httpResponse.getCode(); - } - @Override public String getStatusText() { return this.httpResponse.getReasonPhrase(); diff --git a/spring-web/src/main/java/org/springframework/http/client/OkHttp3ClientHttpResponse.java b/spring-web/src/main/java/org/springframework/http/client/OkHttp3ClientHttpResponse.java index ec5e8b927b..7aab8cee78 100644 --- a/spring-web/src/main/java/org/springframework/http/client/OkHttp3ClientHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/client/OkHttp3ClientHttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -54,12 +54,6 @@ class OkHttp3ClientHttpResponse implements ClientHttpResponse { return HttpStatusCode.valueOf(this.response.code()); } - @Override - @Deprecated - public int getRawStatusCode() { - return this.response.code(); - } - @Override public String getStatusText() { return this.response.message(); diff --git a/spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpResponse.java b/spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpResponse.java index f4cf612bc4..04be39a040 100644 --- a/spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpResponse.java @@ -55,12 +55,6 @@ final class SimpleClientHttpResponse implements ClientHttpResponse { return HttpStatusCode.valueOf(this.connection.getResponseCode()); } - @Override - @Deprecated - public int getRawStatusCode() throws IOException { - return this.connection.getResponseCode(); - } - @Override public String getStatusText() throws IOException { String result = this.connection.getResponseMessage(); diff --git a/spring-web/src/main/java/org/springframework/web/client/ClientHttpResponseDecorator.java b/spring-web/src/main/java/org/springframework/web/client/ClientHttpResponseDecorator.java index 3f79664487..69430e081d 100644 --- a/spring-web/src/main/java/org/springframework/web/client/ClientHttpResponseDecorator.java +++ b/spring-web/src/main/java/org/springframework/web/client/ClientHttpResponseDecorator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -55,12 +55,6 @@ class ClientHttpResponseDecorator implements ClientHttpResponse { return this.delegate.getStatusCode(); } - @SuppressWarnings("deprecation") - @Override - public int getRawStatusCode() throws IOException { - return this.delegate.getRawStatusCode(); - } - @Override public String getStatusText() throws IOException { return this.delegate.getStatusText(); diff --git a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/client/MockClientHttpResponse.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/client/MockClientHttpResponse.java index 45a3829e78..ae4f646490 100644 --- a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/client/MockClientHttpResponse.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/client/MockClientHttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -90,12 +90,6 @@ public class MockClientHttpResponse extends MockHttpInputMessage implements Clie return this.statusCode; } - @Override - @Deprecated - public int getRawStatusCode() { - return this.statusCode.value(); - } - @Override public String getStatusText() { return (this.statusCode instanceof HttpStatus status ? status.getReasonPhrase() : "");