From f17f1d19a7a1b027171e971d9c47b768607b3f3a Mon Sep 17 00:00:00 2001 From: zhangtong2 Date: Tue, 24 Dec 2024 18:25:25 +0800 Subject: [PATCH] Compatible with springboot 3.4.x for ClienthttpResponse --- .../sentinel/rest/SentinelClientHttpResponse.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-sentinel/src/main/java/com/alibaba/cloud/sentinel/rest/SentinelClientHttpResponse.java b/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-sentinel/src/main/java/com/alibaba/cloud/sentinel/rest/SentinelClientHttpResponse.java index be8c9cdba8..295c202da5 100644 --- a/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-sentinel/src/main/java/com/alibaba/cloud/sentinel/rest/SentinelClientHttpResponse.java +++ b/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-sentinel/src/main/java/com/alibaba/cloud/sentinel/rest/SentinelClientHttpResponse.java @@ -29,15 +29,16 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; +import org.springframework.http.HttpStatusCode; import org.springframework.http.MediaType; -import org.springframework.http.client.AbstractClientHttpResponse; +import org.springframework.http.client.ClientHttpResponse; /** * Using by {@link SentinelRestTemplate} and {@link SentinelProtectInterceptor}. * * @author Jim */ -public class SentinelClientHttpResponse extends AbstractClientHttpResponse { +public class SentinelClientHttpResponse implements ClientHttpResponse { private String blockResponse = "RestTemplate request block by sentinel"; @@ -48,6 +49,11 @@ public SentinelClientHttpResponse(String blockResponse) { this.blockResponse = blockResponse; } + @Override + public HttpStatusCode getStatusCode() throws IOException { + return HttpStatus.OK; + } + @Override public int getRawStatusCode() throws IOException { return HttpStatus.OK.value();