From 28b50401c54bd45ce3eba0fc212737280db3e14b Mon Sep 17 00:00:00 2001 From: Olga MaciaszekSharma Date: Wed, 7 Jul 2021 14:38:12 +0200 Subject: [PATCH] Revert "Update SNAPSHOT to 2.2.9.RELEASE" This reverts commit 1005749eb530767b3e51e846fb43319e47bbf5b2. --- docs/pom.xml | 2 +- pom.xml | 8 +- spring-cloud-openfeign-core/pom.xml | 2 +- .../openfeign/FeignClientFactoryBean.java | 3 +- ...adBalancerResponseStatusCodeException.java | 6 +- ...ryableFeignBlockingLoadBalancerClient.java | 4 +- ...eFeignBlockingLoadBalancerClientTests.java | 26 +++--- .../openfeign/valid/FeignClientTests.java | 86 ++++++++++--------- spring-cloud-openfeign-dependencies/pom.xml | 4 +- spring-cloud-starter-openfeign/pom.xml | 2 +- 10 files changed, 71 insertions(+), 72 deletions(-) diff --git a/docs/pom.xml b/docs/pom.xml index a3174077..327ae75b 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -6,7 +6,7 @@ org.springframework.cloud spring-cloud-openfeign - 2.2.9.RELEASE + 2.2.9.BUILD-SNAPSHOT spring-cloud-openfeign-docs pom diff --git a/pom.xml b/pom.xml index 2d1c2cd3..e0ad978f 100644 --- a/pom.xml +++ b/pom.xml @@ -4,14 +4,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-cloud-openfeign - 2.2.9.RELEASE + 2.2.9.BUILD-SNAPSHOT pom Spring Cloud OpenFeign Spring Cloud OpenFeign org.springframework.cloud spring-cloud-build - 2.3.5.RELEASE + 2.3.4.RELEASE @@ -26,8 +26,8 @@ ${basedir} 2.11.3 - 2.2.9.RELEASE - 2.2.9.RELEASE + 2.2.9.BUILD-SNAPSHOT + 2.2.9.BUILD-SNAPSHOT 2.10 diff --git a/spring-cloud-openfeign-core/pom.xml b/spring-cloud-openfeign-core/pom.xml index ed012d1a..c50b5720 100644 --- a/spring-cloud-openfeign-core/pom.xml +++ b/spring-cloud-openfeign-core/pom.xml @@ -6,7 +6,7 @@ org.springframework.cloud spring-cloud-openfeign - 2.2.9.RELEASE + 2.2.9.BUILD-SNAPSHOT .. spring-cloud-openfeign-core diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientFactoryBean.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientFactoryBean.java index 59c8b23f..ac24747f 100644 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientFactoryBean.java +++ b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientFactoryBean.java @@ -375,8 +375,7 @@ public class FeignClientFactoryBean implements FactoryBean, Initializing if (!StringUtils.hasText(url)) { if (LOG.isInfoEnabled()) { - LOG.info("For '" + name - + "' URL not provided. Will try picking an instance via load-balancing."); + LOG.info("For '" + name + "' URL not provided. Will try picking an instance via load-balancing."); } if (!name.startsWith("http")) { url = "http://" + name; diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/LoadBalancerResponseStatusCodeException.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/LoadBalancerResponseStatusCodeException.java index 9bcfc1fa..0e7017f8 100644 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/LoadBalancerResponseStatusCodeException.java +++ b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/LoadBalancerResponseStatusCodeException.java @@ -28,13 +28,11 @@ import org.springframework.cloud.client.loadbalancer.RetryableStatusCodeExceptio * * @author Ryan Baxter */ -public class LoadBalancerResponseStatusCodeException - extends RetryableStatusCodeException { +public class LoadBalancerResponseStatusCodeException extends RetryableStatusCodeException { private final Response response; - public LoadBalancerResponseStatusCodeException(String serviceId, Response response, - byte[] body, URI uri) { + public LoadBalancerResponseStatusCodeException(String serviceId, Response response, byte[] body, URI uri) { super(serviceId, response.status(), response, uri); this.response = Response.builder() .body(new ByteArrayInputStream(body), body.length) diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/RetryableFeignBlockingLoadBalancerClient.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/RetryableFeignBlockingLoadBalancerClient.java index 157eebaf..342bb534 100644 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/RetryableFeignBlockingLoadBalancerClient.java +++ b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/RetryableFeignBlockingLoadBalancerClient.java @@ -113,10 +113,10 @@ public class RetryableFeignBlockingLoadBalancerClient implements Client { String.format("Retrying on status code: %d", responseStatus)); } byte[] byteArray = response.body() == null ? new byte[] {} - : StreamUtils.copyToByteArray(response.body().asInputStream()); + : StreamUtils.copyToByteArray(response.body().asInputStream()); response.close(); throw new LoadBalancerResponseStatusCodeException(serviceId, response, - byteArray, URI.create(request.url())); + byteArray, URI.create(request.url())); } return response; }, new LoadBalancedRecoveryCallback() { diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/RetryableFeignBlockingLoadBalancerClientTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/RetryableFeignBlockingLoadBalancerClientTests.java index 5862d425..ca175318 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/RetryableFeignBlockingLoadBalancerClientTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/RetryableFeignBlockingLoadBalancerClientTests.java @@ -119,10 +119,8 @@ class RetryableFeignBlockingLoadBalancerClientTests { private Response testResponse(int status, String body) { // ByteArrayInputStream ignores close() and must be wrapped - InputStream reallyCloseable = new BufferedInputStream( - new ByteArrayInputStream(body.getBytes(StandardCharsets.UTF_8))); - return Response.builder().request(testRequest()).status(status) - .body(reallyCloseable, null).build(); + InputStream reallyCloseable = new BufferedInputStream(new ByteArrayInputStream(body.getBytes(StandardCharsets.UTF_8))); + return Response.builder().request(testRequest()).status(status).body(reallyCloseable, null).build(); } @@ -165,23 +163,23 @@ class RetryableFeignBlockingLoadBalancerClientTests { void shouldExposeResponseBodyOnRetry() throws IOException { properties.getRetryableStatusCodes().add(503); Request request = testRequest(); - when(delegate.execute(any(), any())).thenReturn(testResponse(503, "foo"), - testResponse(503, "foo")); + when(delegate.execute(any(), any())) + .thenReturn(testResponse(503, "foo"), testResponse(503, "foo")); when(retryFactory.createRetryPolicy(any(), eq(loadBalancerClient))) - .thenReturn(new BlockingLoadBalancedRetryPolicy("test", - loadBalancerClient, properties)); + .thenReturn(new BlockingLoadBalancedRetryPolicy("test", + loadBalancerClient, properties)); when(loadBalancerClient.reconstructURI(serviceInstance, - URI.create("http://test/path"))) - .thenReturn(URI.create("http://testhost:80/path")); + URI.create("http://test/path"))) + .thenReturn(URI.create("http://testhost:80/path")); - Response response = feignBlockingLoadBalancerClient.execute(request, - new Request.Options()); + Response response = feignBlockingLoadBalancerClient.execute(request, new Request.Options()); - String bodyContent = IOUtils - .toString(response.body().asReader(StandardCharsets.UTF_8)); + String bodyContent = IOUtils.toString(response.body().asReader(StandardCharsets.UTF_8)); assertThat(bodyContent).isEqualTo("foo"); } + + @Test void shouldPassCorrectRequestToDelegate() throws IOException { Request request = testRequest(); diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientTests.java index 73d89ca0..c747eda0 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientTests.java @@ -181,7 +181,7 @@ public class FeignClientTests { public void testClient() { assertThat(testClient).as("testClient was null").isNotNull(); assertThat(Proxy.isProxyClass(testClient.getClass())) - .as("testClient is not a java Proxy").isTrue(); + .as("testClient is not a java Proxy").isTrue(); InvocationHandler invocationHandler = Proxy.getInvocationHandler(testClient); assertThat(invocationHandler).as("invocationHandler was null").isNotNull(); } @@ -198,7 +198,7 @@ public class FeignClientTests { Hello hello = testClient.getHello(); assertThat(hello).as("hello was null").isNotNull(); assertThat(hello).as("first hello didn't match") - .isEqualTo(new Hello(HELLO_WORLD_1)); + .isEqualTo(new Hello(HELLO_WORLD_1)); } @Test @@ -219,9 +219,9 @@ public class FeignClientTests { List headers = testClient.getHelloHeaders(); assertThat(headers).as("headers was null").isNotNull(); assertThat(headers.contains("myheader1value")) - .as("headers didn't contain myheader1value").isTrue(); + .as("headers didn't contain myheader1value").isTrue(); assertThat(headers.contains("myheader2value")) - .as("headers didn't contain myheader2value").isTrue(); + .as("headers didn't contain myheader2value").isTrue(); } @Test @@ -241,11 +241,12 @@ public class FeignClientTests { @Test public void testServiceId() { - assertThat(testClientServiceId).as("testClientServiceId was null").isNotNull(); + assertThat(testClientServiceId).as("testClientServiceId was null") + .isNotNull(); final Hello hello = testClientServiceId.getHello(); assertThat(hello).as("The hello response was null").isNotNull(); assertThat(hello).as("first hello didn't match") - .isEqualTo(new Hello(HELLO_WORLD_1)); + .isEqualTo(new Hello(HELLO_WORLD_1)); } @Test @@ -259,7 +260,7 @@ public class FeignClientTests { @Test public void testFormattedParams() { List list = Arrays.asList(LocalDate.of(2001, 1, 1), - LocalDate.of(2018, 6, 10)); + LocalDate.of(2018, 6, 10)); List params = testClient.getFormattedParams(list); assertThat(params).as("params was null").isNotNull(); assertThat(params).as("params not converted correctly").isEqualTo(list); @@ -270,13 +271,13 @@ public class FeignClientTests { HystrixCommand> command = testClient.getHellosHystrix(); assertThat(command).as("command was null").isNotNull(); assertThat(command.getCommandGroup().name()).as( - "Hystrix command group name should match the name of the feign client") - .isEqualTo("localapp"); + "Hystrix command group name should match the name of the feign client") + .isEqualTo("localapp"); String configKey = Feign.configKey(TestClient.class, - TestClient.class.getMethod("getHellosHystrix", (Class[]) null)); + TestClient.class.getMethod("getHellosHystrix", (Class[]) null)); assertThat(command.getCommandKey().name()) - .as("Hystrix command key name should match the feign config key") - .isEqualTo(configKey); + .as("Hystrix command key name should match the feign config key") + .isEqualTo(configKey); List hellos = command.execute(); assertThat(hellos).as("hellos was null").isNotNull(); assertThat(getHelloList()).as("hellos didn't match").isEqualTo(hellos); @@ -289,7 +290,7 @@ public class FeignClientTests { Hello hello = single.toBlocking().value(); assertThat(hello).as("hello was null").isNotNull(); assertThat(hello).as("first hello didn't match") - .isEqualTo(new Hello(HELLO_WORLD_1)); + .isEqualTo(new Hello(HELLO_WORLD_1)); } @Test @@ -297,7 +298,7 @@ public class FeignClientTests { ResponseEntity response = testClient.noContent(); assertThat(response).as("response was null").isNotNull(); assertThat(response.getStatusCode()).as("status code was wrong") - .isEqualTo(HttpStatus.NO_CONTENT); + .isEqualTo(HttpStatus.NO_CONTENT); } @Test @@ -305,7 +306,7 @@ public class FeignClientTests { ResponseEntity response = testClient.head(); assertThat(response).as("response was null").isNotNull(); assertThat(response.getStatusCode()).as("status code was wrong") - .isEqualTo(HttpStatus.OK); + .isEqualTo(HttpStatus.OK); } @Test @@ -315,7 +316,7 @@ public class FeignClientTests { Hello hello = entity.getBody(); assertThat(hello).as("hello was null").isNotNull(); assertThat(hello).as("first hello didn't match") - .isEqualTo(new Hello(HELLO_WORLD_1)); + .isEqualTo(new Hello(HELLO_WORLD_1)); } @Test @@ -323,7 +324,7 @@ public class FeignClientTests { String response = testClient.moreComplexContentType("{\"value\":\"OK\"}"); assertThat(response).as("response was null").isNotNull(); assertThat(response).as("didn't respond with {\"value\":\"OK\"}") - .isEqualTo("{\"value\":\"OK\"}"); + .isEqualTo("{\"value\":\"OK\"}"); } @Test @@ -331,7 +332,7 @@ public class FeignClientTests { ResponseEntity response = decodingTestClient.notFound(); assertThat(response).as("response was null").isNotNull(); assertThat(response.getStatusCode()).as("status code was wrong") - .isEqualTo(HttpStatus.NOT_FOUND); + .isEqualTo(HttpStatus.NOT_FOUND); assertThat(response.getBody()).as("response body was not null").isNull(); } @@ -370,7 +371,7 @@ public class FeignClientTests { Hello hello = single.toBlocking().value(); assertThat(hello).as("hello was null").isNotNull(); assertThat(hello.getMessage()).as("message was wrong") - .isEqualTo("fallbacksingle"); + .isEqualTo("fallbacksingle"); } @Test @@ -380,7 +381,7 @@ public class FeignClientTests { Hello hello = command.execute(); assertThat(hello).as("hello was null").isNotNull(); assertThat(hello.getMessage()).as("message was wrong") - .isEqualTo("fallbackcommand"); + .isEqualTo("fallbackcommand"); } @Test @@ -390,7 +391,7 @@ public class FeignClientTests { Hello hello = observable.toBlocking().first(); assertThat(hello).as("hello was null").isNotNull(); assertThat(hello.getMessage()).as("message was wrong") - .isEqualTo("fallbackobservable"); + .isEqualTo("fallbackobservable"); } @Test @@ -400,7 +401,7 @@ public class FeignClientTests { Hello hello = future.get(1, TimeUnit.SECONDS); assertThat(hello).as("hello was null").isNotNull(); assertThat(hello.getMessage()).as("message was wrong") - .isEqualTo("fallbackfuture"); + .isEqualTo("fallbackfuture"); } @Test @@ -409,8 +410,8 @@ public class FeignClientTests { assertThat(hello).as("hello was null").isNotNull(); assertThat(hello.getMessage()).as("hello#message was null").isNotNull(); assertThat(hello.getMessage().contains("500")).as( - "hello#message did not contain the cause (status code) of the fallback invocation") - .isTrue(); + "hello#message did not contain the cause (status code) of the fallback invocation") + .isTrue(); } @Test(expected = HystrixRuntimeException.class) @@ -438,17 +439,17 @@ public class FeignClientTests { @Test public void testHystrixSetterFactory() { HystrixCommand> command = hystrixSetterFactoryClient - .getHellosHystrix(); + .getHellosHystrix(); assertThat(command).as("command was null").isNotNull(); String setterPrefix = TestHystrixSetterFactoryClientConfig.SETTER_PREFIX; assertThat(command.getCommandGroup().name()).as( - "Hystrix command group name should match the name of the feign client with a prefix of " - + setterPrefix) - .isEqualTo(setterPrefix + "localapp5"); + "Hystrix command group name should match the name of the feign client with a prefix of " + + setterPrefix) + .isEqualTo(setterPrefix + "localapp5"); assertThat(command.getCommandKey().name()).as( - "Hystrix command key name should match the request method (space) request path with a prefix of " - + setterPrefix) - .isEqualTo(setterPrefix + "GET /hellos"); + "Hystrix command key name should match the request method (space) request path with a prefix of " + + setterPrefix) + .isEqualTo(setterPrefix + "GET /hellos"); List hellos = command.execute(); assertThat(hellos).as("hellos was null").isNotNull(); assertThat(getHelloList()).as("hellos didn't match").isEqualTo(hellos); @@ -480,7 +481,8 @@ public class FeignClientTests { Hello pojo2 = new Hello(OI_TERRA_2); MockMultipartFile file = new MockMultipartFile("file", "hello.bin", null, "hello".getBytes()); - String response = multipartClient.multipartPojo("abc", "123", pojo1, pojo2, file); + String response = multipartClient.multipartPojo("abc", "123", pojo1, pojo2, + file); assertThat(response).isEqualTo("abc123hello world 1oi terra 2hello.bin"); } @@ -505,8 +507,9 @@ public class FeignClientTests { "hello".getBytes()); MockMultipartFile file2 = new MockMultipartFile("file2", "hello2.bin", null, "hello".getBytes()); - String response = multipartClient.requestPartListOfPojosAndListOfMultipartFiles( - Arrays.asList(pojo1, pojo2), Arrays.asList(file1, file2)); + String response = multipartClient + .requestPartListOfPojosAndListOfMultipartFiles( + Arrays.asList(pojo1, pojo2), Arrays.asList(file1, file2)); assertThat(response).isEqualTo("hello world 1oi terra 2hello1.binhello2.bin"); } @@ -621,7 +624,7 @@ public class FeignClientTests { String getToString(@RequestParam("arg") Arg arg); @PostMapping(path = "/form-urlencoded", - consumes = APPLICATION_FORM_URLENCODED_VALUE) + consumes = APPLICATION_FORM_URLENCODED_VALUE) Hello postFormUrlEncoded(Hello hello); @RequestMapping(method = RequestMethod.GET, path = "/tostring2") @@ -821,7 +824,8 @@ public class FeignClientTests { public HystrixClientWithFallBackFactory create(final Throwable cause) { return () -> { assertThat(cause).isNotNull().as("Cause was null"); - return new Hello("Hello from the fallback side: " + cause.getMessage()); + return new Hello( + "Hello from the fallback side: " + cause.getMessage()); }; } @@ -884,12 +888,12 @@ public class FeignClientTests { return (target, method) -> { String groupKey = SETTER_PREFIX + target.name(); RequestMapping requestMapping = method - .getAnnotation(RequestMapping.class); + .getAnnotation(RequestMapping.class); String commandKey = SETTER_PREFIX + requestMapping.method()[0] + " " - + requestMapping.path()[0]; + + requestMapping.path()[0]; return HystrixCommand.Setter - .withGroupKey(HystrixCommandGroupKey.Factory.asKey(groupKey)) - .andCommandKey(HystrixCommandKey.Factory.asKey(commandKey)); + .withGroupKey(HystrixCommandGroupKey.Factory.asKey(groupKey)) + .andCommandKey(HystrixCommandKey.Factory.asKey(commandKey)); }; } @@ -1157,7 +1161,7 @@ public class FeignClientTests { } @PostMapping(path = "/form-urlencoded", - consumes = APPLICATION_FORM_URLENCODED_VALUE) + consumes = APPLICATION_FORM_URLENCODED_VALUE) Hello postFormUrlEncoded(Hello hello) { return hello; } diff --git a/spring-cloud-openfeign-dependencies/pom.xml b/spring-cloud-openfeign-dependencies/pom.xml index 3b3653b9..e2f459ca 100644 --- a/spring-cloud-openfeign-dependencies/pom.xml +++ b/spring-cloud-openfeign-dependencies/pom.xml @@ -6,11 +6,11 @@ spring-cloud-dependencies-parent org.springframework.cloud - 2.3.5.RELEASE + 2.3.5.BUILD-SNAPSHOT spring-cloud-openfeign-dependencies - 2.2.9.RELEASE + 2.2.9.BUILD-SNAPSHOT pom spring-cloud-openfeign-dependencies Spring Cloud OpenFeign Dependencies diff --git a/spring-cloud-starter-openfeign/pom.xml b/spring-cloud-starter-openfeign/pom.xml index 34b2f184..b76067c0 100644 --- a/spring-cloud-starter-openfeign/pom.xml +++ b/spring-cloud-starter-openfeign/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-openfeign - 2.2.9.RELEASE + 2.2.9.BUILD-SNAPSHOT .. spring-cloud-starter-openfeign