Browse Source

Merge branch '2.2.x'

pull/1760/head
spencergibb 5 years ago
parent
commit
158ce3d844
No known key found for this signature in database
GPG Key ID: 7788A47380690861
  1. 6
      spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/SpringCloudCircuitBreakerResilience4JFilterFactory.java
  2. 9
      spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/factory/SpringCloudCircuitBreakerResilience4JFilterFactoryTests.java

6
spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/SpringCloudCircuitBreakerResilience4JFilterFactory.java

@ -22,8 +22,9 @@ import reactor.core.publisher.Mono; @@ -22,8 +22,9 @@ import reactor.core.publisher.Mono;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.cloud.client.circuitbreaker.ReactiveCircuitBreakerFactory;
import org.springframework.cloud.gateway.support.ServiceUnavailableException;
import org.springframework.cloud.gateway.support.TimeoutException;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.DispatcherHandler;
import org.springframework.web.server.ResponseStatusException;
/**
* @author Ryan Baxter
@ -40,7 +41,8 @@ public class SpringCloudCircuitBreakerResilience4JFilterFactory @@ -40,7 +41,8 @@ public class SpringCloudCircuitBreakerResilience4JFilterFactory
@Override
protected Mono<Void> handleErrorWithoutFallback(Throwable t) {
if (java.util.concurrent.TimeoutException.class.isInstance(t)) {
return Mono.error(new TimeoutException());
return Mono.error(new ResponseStatusException(HttpStatus.GATEWAY_TIMEOUT,
t.getMessage(), t));
}
if (CallNotPermittedException.class.isInstance(t)) {
return Mono.error(new ServiceUnavailableException());

9
spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/factory/SpringCloudCircuitBreakerResilience4JFilterFactoryTests.java

@ -71,6 +71,15 @@ public class SpringCloudCircuitBreakerResilience4JFilterFactoryTests @@ -71,6 +71,15 @@ public class SpringCloudCircuitBreakerResilience4JFilterFactoryTests
.value(RETRIEVED_EXCEPTION, containsString("TimeoutException"));
}
@Test
public void cbFilterTimesoutMessage() {
testClient.get().uri("/delay/3").header("Host", "www.sccbtimeout.org").exchange()
.expectStatus().isEqualTo(HttpStatus.GATEWAY_TIMEOUT).expectBody()
.jsonPath("$.status")
.isEqualTo(String.valueOf(HttpStatus.GATEWAY_TIMEOUT.value()))
.jsonPath("$.message").value(containsString("1000ms"));
}
@Test
public void toStringFormat() {
SpringCloudCircuitBreakerFilterFactory.Config config = new SpringCloudCircuitBreakerFilterFactory.Config()

Loading…
Cancel
Save