Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>3.0.3</version>
<version>3.0.4-SNAPSHOT</version>
</parent>
<artifactId>spring-cloud-gateway-docs</artifactId>
<packaging>jar</packaging>
Expand Down
Binary file modified docs/src/main/asciidoc/images/gateway-grafana-dashboard.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>3.0.3</version>
<version>3.0.4-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Spring Cloud Gateway</name>
Expand All @@ -15,7 +15,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build</artifactId>
<version>3.0.3</version>
<version>3.0.4-SNAPSHOT</version>
<relativePath/>
</parent>
<scm>
Expand Down Expand Up @@ -54,8 +54,8 @@
<blockhound.version>1.0.6.RELEASE</blockhound.version>
<java.version>1.8</java.version>
<junit-pioneer.version>1.0.0</junit-pioneer.version>
<spring-cloud-circuitbreaker.version>2.0.2</spring-cloud-circuitbreaker.version>
<spring-cloud-commons.version>3.0.3</spring-cloud-commons.version>
<spring-cloud-circuitbreaker.version>2.0.3-SNAPSHOT</spring-cloud-circuitbreaker.version>
<spring-cloud-commons.version>3.0.4-SNAPSHOT</spring-cloud-commons.version>
<testcontainers.version>1.15.1</testcontainers.version>
</properties>

Expand Down
4 changes: 2 additions & 2 deletions spring-cloud-gateway-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<parent>
<artifactId>spring-cloud-dependencies-parent</artifactId>
<groupId>org.springframework.cloud</groupId>
<version>3.0.3</version>
<version>3.0.4-SNAPSHOT</version>
<relativePath/>
</parent>

<artifactId>spring-cloud-gateway-dependencies</artifactId>
<version>3.0.3</version>
<version>3.0.4-SNAPSHOT</version>
<packaging>pom</packaging>

<name>spring-cloud-gateway-dependencies</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway-integration-tests</artifactId>
<version>3.0.3</version>
<version>3.0.4-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-cloud-gateway-integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>3.0.3</version>
<version>3.0.4-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-cloud-gateway-mvc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>3.0.3</version>
<version>3.0.4-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-cloud-gateway-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>3.0.3</version>
<version>3.0.4-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-cloud-gateway-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>3.0.3</version>
<version>3.0.4-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-gateway-server</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,16 @@ public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
return cb.run(chain.filter(exchange).doOnSuccess(v -> {
if (statuses.contains(exchange.getResponse().getStatusCode())) {
HttpStatus status = exchange.getResponse().getStatusCode();
exchange.getResponse().setStatusCode(null);
reset(exchange);
throw new CircuitBreakerStatusCodeException(status);
}
}), t -> {
if (config.getFallbackUri() == null) {
return Mono.error(t);
}

exchange.getResponse().setStatusCode(null);
reset(exchange);

// TODO: copied from RouteToRequestUrlFilter
URI uri = exchange.getRequest().getURI();
// TODO: assume always?
Expand All @@ -121,7 +122,7 @@ public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {

ServerHttpRequest request = exchange.getRequest().mutate().uri(requestUrl).build();
return getDispatcherHandler().handle(exchange.mutate().request(request).build());
}).onErrorResume(t -> handleErrorWithoutFallback(t));
}).onErrorResume(t -> handleErrorWithoutFallback(t, config.isResumeWithoutError()));
}

@Override
Expand All @@ -132,7 +133,7 @@ public String toString() {
};
}

protected abstract Mono<Void> handleErrorWithoutFallback(Throwable t);
protected abstract Mono<Void> handleErrorWithoutFallback(Throwable t, boolean resumeWithoutError);

private void addExceptionDetails(Throwable t, ServerWebExchange exchange) {
ofNullable(t).ifPresent(
Expand All @@ -154,6 +155,8 @@ public static class Config implements HasRouteId {

private Set<String> statusCodes = new HashSet<>();

private boolean resumeWithoutError = false;

@Override
public void setRouteId(String routeId) {
this.routeId = routeId;
Expand Down Expand Up @@ -206,6 +209,14 @@ public Config addStatusCode(String statusCode) {
return this;
}

public boolean isResumeWithoutError() {
return resumeWithoutError;
}

public void setResumeWithoutError(boolean resumeWithoutError) {
this.resumeWithoutError = resumeWithoutError;
}

}

public class CircuitBreakerStatusCodeException extends HttpStatusCodeException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ public SpringCloudCircuitBreakerResilience4JFilterFactory(
}

@Override
protected Mono<Void> handleErrorWithoutFallback(Throwable t) {
protected Mono<Void> handleErrorWithoutFallback(Throwable t, boolean resumeWithoutError) {
if (java.util.concurrent.TimeoutException.class.isInstance(t)) {
return Mono.error(new ResponseStatusException(HttpStatus.GATEWAY_TIMEOUT, t.getMessage(), t));
}
if (CallNotPermittedException.class.isInstance(t)) {
return Mono.error(new ServiceUnavailableException());
}
if (resumeWithoutError) {
return Mono.empty();
}
return Mono.error(t);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,17 @@ public void filterStatusCodeFallback() {
.isOk().expectHeader().valueEquals(ROUTE_ID_HEADER, "circuitbreaker_fallback_test_statuscode");
}

@Test
public void filterStatusCodeResumeWithoutError() {
testClient.get().uri("/status/500").header("Host", "www.circuitbreakerresumewithouterror.org").exchange()
.expectStatus().isEqualTo(500);

testClient.get().uri("/status/404").header("Host", "www.circuitbreakerresumewithouterror.org").exchange()
.expectStatus().isEqualTo(404);

testClient.get().uri("/status/200").header("Host", "www.circuitbreakerresumewithouterror.org").exchange()
.expectStatus().isOk().expectHeader()
.valueEquals(ROUTE_ID_HEADER, "circuitbreaker_resume_without_error");
}

}
Binary file modified spring-cloud-gateway-server/src/test/resources/1x1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions spring-cloud-gateway-server/src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ spring:
- "NOT_FOUND"
fallbackUri: forward:/statusCodeFallbackController

# =====================================
- id: circuitbreaker_resume_without_error
uri: ${test.uri}
predicates:
- Host=**.circuitbreakerresumewithouterror.org
filters:
- name: CircuitBreaker
args:
name: resumewithouterror
statusCodes:
- 500
- "NOT_FOUND"
resume-without-error: true

# =====================================
- id: change_uri_test
uri: ${test.uri}
Expand Down
2 changes: 1 addition & 1 deletion spring-cloud-gateway-webflux/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>3.0.3</version>
<version>3.0.4-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-cloud-starter-gateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>3.0.3</version>
<version>3.0.4-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-starter-gateway</artifactId>
Expand Down