Browse Source

Merge remote-tracking branch 'origin/main'

pull/2888/head
spencergibb 2 years ago
parent
commit
d01a17c3df
No known key found for this signature in database
GPG Key ID: 7788A47380690861
  1. 2
      docs/pom.xml
  2. 2
      pom.xml
  3. 2
      spring-cloud-gateway-dependencies/pom.xml
  4. 2
      spring-cloud-gateway-integration-tests/grpc/pom.xml
  5. 2
      spring-cloud-gateway-integration-tests/http2/pom.xml
  6. 2
      spring-cloud-gateway-integration-tests/mvc-failure-analyzer/pom.xml
  7. 2
      spring-cloud-gateway-integration-tests/pom.xml
  8. 2
      spring-cloud-gateway-mvc/pom.xml
  9. 2
      spring-cloud-gateway-sample/pom.xml
  10. 2
      spring-cloud-gateway-server/pom.xml
  11. 16
      spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/filter/headers/observation/ObservedResponseHttpHeadersFilter.java
  12. 42
      spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/headers/observation/ObservedResponseHttpHeadersFilterTests.java
  13. 2
      spring-cloud-gateway-webflux/pom.xml
  14. 2
      spring-cloud-starter-gateway/pom.xml

2
docs/pom.xml

@ -6,7 +6,7 @@ @@ -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>

2
pom.xml

@ -6,7 +6,7 @@ @@ -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>

2
spring-cloud-gateway-dependencies/pom.xml

@ -11,7 +11,7 @@ @@ -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>

2
spring-cloud-gateway-integration-tests/grpc/pom.xml

@ -17,7 +17,7 @@ @@ -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>

2
spring-cloud-gateway-integration-tests/http2/pom.xml

@ -16,7 +16,7 @@ @@ -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>

2
spring-cloud-gateway-integration-tests/mvc-failure-analyzer/pom.xml

@ -16,7 +16,7 @@ @@ -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>

2
spring-cloud-gateway-integration-tests/pom.xml

@ -16,7 +16,7 @@ @@ -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>

2
spring-cloud-gateway-mvc/pom.xml

@ -11,7 +11,7 @@ @@ -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>

2
spring-cloud-gateway-sample/pom.xml

@ -16,7 +16,7 @@ @@ -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>

2
spring-cloud-gateway-server/pom.xml

@ -7,7 +7,7 @@ @@ -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>

16
spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/filter/headers/observation/ObservedResponseHttpHeadersFilter.java

@ -44,13 +44,15 @@ public class ObservedResponseHttpHeadersFilter implements HttpHeadersFilter { @@ -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");

42
spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/headers/observation/ObservedResponseHttpHeadersFilterTests.java

@ -0,0 +1,42 @@ @@ -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));
}
}

2
spring-cloud-gateway-webflux/pom.xml

@ -11,7 +11,7 @@ @@ -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>

2
spring-cloud-starter-gateway/pom.xml

@ -6,7 +6,7 @@ @@ -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>

Loading…
Cancel
Save