Merge remote-tracking branch 'origin/main'

This commit is contained in:
spencergibb
2023-03-03 16:56:22 -05:00
14 changed files with 63 additions and 19 deletions

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>4.0.3-SNAPSHOT</version>
<version>4.0.4-SNAPSHOT</version>
</parent>
<artifactId>spring-cloud-gateway-docs</artifactId>
<packaging>jar</packaging>

View File

@@ -6,7 +6,7 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>4.0.3-SNAPSHOT</version>
<version>4.0.4-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Spring Cloud Gateway</name>

View File

@@ -11,7 +11,7 @@
</parent>
<artifactId>spring-cloud-gateway-dependencies</artifactId>
<version>4.0.3-SNAPSHOT</version>
<version>4.0.4-SNAPSHOT</version>
<packaging>pom</packaging>
<name>spring-cloud-gateway-dependencies</name>

View File

@@ -17,7 +17,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway-integration-tests</artifactId>
<version>4.0.3-SNAPSHOT</version>
<version>4.0.4-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>

View File

@@ -16,7 +16,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway-integration-tests</artifactId>
<version>4.0.3-SNAPSHOT</version>
<version>4.0.4-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>

View File

@@ -16,7 +16,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway-integration-tests</artifactId>
<version>4.0.3-SNAPSHOT</version>
<version>4.0.4-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>

View File

@@ -16,7 +16,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>4.0.3-SNAPSHOT</version>
<version>4.0.4-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>

View File

@@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>4.0.3-SNAPSHOT</version>
<version>4.0.4-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

View File

@@ -16,7 +16,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>4.0.3-SNAPSHOT</version>
<version>4.0.4-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>4.0.3-SNAPSHOT</version>
<version>4.0.4-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-gateway-server</artifactId>

View File

@@ -44,13 +44,15 @@ public class ObservedResponseHttpHeadersFilter implements HttpHeadersFilter {
if (childObservation == null) {
return input;
}
GatewayContext context = (GatewayContext) childObservation.getContext();
if (log.isDebugEnabled()) {
log.debug("Will instrument the response");
}
context.setResponse(exchange.getResponse());
if (log.isDebugEnabled()) {
log.debug("The response was handled for observation " + childObservation);
Observation.Context childObservationContext = childObservation.getContext();
if (childObservationContext instanceof GatewayContext context) {
if (log.isDebugEnabled()) {
log.debug("Will instrument the response");
}
context.setResponse(exchange.getResponse());
if (log.isDebugEnabled()) {
log.debug("The response was handled for observation " + childObservation);
}
}
childObservation.stop();
exchange.getAttributes().put(OBSERVATION_STOPPED, "true");

View File

@@ -0,0 +1,42 @@
/*
* Copyright 2013-2022 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.gateway.filter.headers.observation;
import io.micrometer.observation.Observation;
import org.junit.jupiter.api.Test;
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
import org.springframework.mock.web.server.MockServerWebExchange;
import org.springframework.web.server.ServerWebExchange;
import static org.assertj.core.api.BDDAssertions.thenNoException;
class ObservedResponseHttpHeadersFilterTests {
@Test
void shouldDoNothingWhenObservationIsNoOp() {
MockServerHttpRequest request = MockServerHttpRequest.get("/get").build();
ServerWebExchange exchange = MockServerWebExchange.from(request);
exchange.getAttributes().put(ServerWebExchangeUtils.GATEWAY_OBSERVATION_ATTR, Observation.NOOP);
ObservedResponseHttpHeadersFilter filter = new ObservedResponseHttpHeadersFilter();
thenNoException().isThrownBy(() -> filter.filter(new HttpHeaders(), exchange));
}
}

View File

@@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>4.0.3-SNAPSHOT</version>
<version>4.0.4-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>4.0.3-SNAPSHOT</version>
<version>4.0.4-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-starter-gateway</artifactId>