From a0a980e8843e0264269f7df805ca08a70fa8a363 Mon Sep 17 00:00:00 2001 From: Olga Maciaszek-Sharma Date: Mon, 1 Apr 2019 20:06:30 +0200 Subject: [PATCH] Fix checkstyle. --- README.adoc | 2 +- .../gateway/filter/GatewayMetricsFilter.java | 19 +++++++++++-------- .../filter/GatewayMetricFilterTests.java | 17 ++++++++++------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/README.adoc b/README.adoc index 2881b5af..a4538b25 100644 --- a/README.adoc +++ b/README.adoc @@ -62,7 +62,7 @@ credentials and you already have those. The projects that require middleware generally include a `docker-compose.yml`, so consider using -https://compose.docker.io/[Docker Compose] to run the middeware servers +https://docs.docker.com/compose/[Docker Compose] to run the middeware servers in Docker containers. See the README in the https://github.com/spring-cloud-samples/scripts[scripts demo repository] for specific instructions about the common cases of mongo, diff --git a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/GatewayMetricsFilter.java b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/GatewayMetricsFilter.java index 314e84e8..e105f6a9 100644 --- a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/GatewayMetricsFilter.java +++ b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/GatewayMetricsFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2013-2018 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. @@ -12,12 +12,15 @@ * 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; -import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_ROUTE_ATTR; +import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.core.instrument.Tags; +import io.micrometer.core.instrument.Timer; +import io.micrometer.core.instrument.Timer.Sample; +import reactor.core.publisher.Mono; import org.springframework.cloud.gateway.route.Route; import org.springframework.core.Ordered; @@ -26,12 +29,11 @@ import org.springframework.http.server.reactive.AbstractServerHttpResponse; import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.web.server.ServerWebExchange; -import io.micrometer.core.instrument.MeterRegistry; -import io.micrometer.core.instrument.Tags; -import io.micrometer.core.instrument.Timer; -import io.micrometer.core.instrument.Timer.Sample; -import reactor.core.publisher.Mono; +import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_ROUTE_ATTR; +/** + * @author Tony Clarke + */ public class GatewayMetricsFilter implements GlobalFilter, Ordered { private MeterRegistry meterRegistry; @@ -102,4 +104,5 @@ public class GatewayMetricsFilter implements GlobalFilter, Ordered { route.getUri().toString(), "httpMethod", httpMethod); sample.stop(meterRegistry.timer("gateway.requests", tags)); } + } diff --git a/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/GatewayMetricFilterTests.java b/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/GatewayMetricFilterTests.java index eac3017e..cb7244f8 100644 --- a/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/GatewayMetricFilterTests.java +++ b/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/GatewayMetricFilterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2013-2018 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. @@ -12,16 +12,14 @@ * 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; -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - +import io.micrometer.core.instrument.MeterRegistry; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringBootConfiguration; @@ -43,7 +41,8 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import io.micrometer.core.instrument.MeterRegistry; +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = RANDOM_PORT) @@ -76,7 +75,8 @@ public class GatewayMetricFilterTests extends BaseWebClientTests { .is5xxServerError(); assertMetricsContainsTag("outcome", HttpStatus.Series.SERVER_ERROR.name()); assertMetricsContainsTag("status", HttpStatus.INTERNAL_SERVER_ERROR.name()); - assertMetricsContainsTag("httpStatusCode", String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR.value())); + assertMetricsContainsTag("httpStatusCode", + String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR.value())); assertMetricsContainsTag("httpMethod", HttpMethod.GET.toString()); assertMetricsContainsTag("routeId", "default_path_to_httpbin"); assertMetricsContainsTag("routeUri", testUri); @@ -109,6 +109,7 @@ public class GatewayMetricFilterTests extends BaseWebClientTests { @RestController @Import(DefaultTestConfig.class) public static class CustomConfig { + @Value("${test.uri}") protected String testUri; @@ -124,5 +125,7 @@ public class GatewayMetricFilterTests extends BaseWebClientTests { public String exception() { throw new RuntimeException("an error"); } + } + }