From a5b0a33155b56cfbb20bd157cb5507cefad0b3de Mon Sep 17 00:00:00 2001 From: za-PanJing Date: Tue, 29 Dec 2020 17:20:51 +0800 Subject: [PATCH 01/12] Fix bug for FeignException cannot get the correct charset (#1325) --- core/src/main/java/feign/FeignException.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/feign/FeignException.java b/core/src/main/java/feign/FeignException.java index 5d182f407..de2fcdd64 100644 --- a/core/src/main/java/feign/FeignException.java +++ b/core/src/main/java/feign/FeignException.java @@ -450,11 +450,11 @@ private static String getResponseBodyPreview(byte[] body, Charset charset) { private static Charset getResponseCharset(Map> headers) { Collection strings = headers.get("content-type"); - if (strings == null || strings.size() == 0) { + if (strings == null || strings.isEmpty()) { return null; } - Pattern pattern = Pattern.compile("charset=([^\\s])"); + Pattern pattern = Pattern.compile(".*charset=([^\\s|^;]+).*"); Matcher matcher = pattern.matcher(strings.iterator().next()); if (!matcher.lookingAt()) { return null; From 209f6fc198a056bc8131f6a40fd9f9831ad64508 Mon Sep 17 00:00:00 2001 From: za-PanJing Date: Wed, 30 Dec 2020 20:19:31 +0800 Subject: [PATCH 02/12] Add test for (Fix bug for FeignException cannot get the correct charset) (#1325) --- .../test/java/feign/FeignExceptionTest.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/core/src/test/java/feign/FeignExceptionTest.java b/core/src/test/java/feign/FeignExceptionTest.java index b761b7735..402ca673d 100644 --- a/core/src/test/java/feign/FeignExceptionTest.java +++ b/core/src/test/java/feign/FeignExceptionTest.java @@ -14,9 +14,11 @@ package feign; import org.junit.Test; + import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.util.Collections; +import java.util.*; + import static org.assertj.core.api.Assertions.assertThat; public class FeignExceptionTest { @@ -58,6 +60,30 @@ public void canCreateWithRequestOnly() { assertThat(exception.request()).isNotNull(); } + @Test + public void canCreateWithOtherCharsetResponse() { + Map> map = new HashMap<>(); + map.put("connection", new ArrayList<>(Collections.singletonList("keep-alive"))); + map.put("content-length", new ArrayList<>(Collections.singletonList("100"))); + map.put("content-type", new ArrayList<>(Collections.singletonList("application/json;charset=UTF-16BE"))); + + Request request = Request.create(Request.HttpMethod.GET, + "/home", Collections.emptyMap(), + "data".getBytes(StandardCharsets.UTF_16BE), + StandardCharsets.UTF_16BE, + null); + + Response response = Response.builder() + .status(400) + .body("response".getBytes(StandardCharsets.UTF_16BE)) + .headers(map) + .request(request) + .build(); + + FeignException exception = FeignException.errorStatus("methodKey", response); + assertThat(exception.getMessage()).isEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); + } + @Test(expected = NullPointerException.class) public void nullRequestShouldThrowNPEwThrowable() { new Derived(404, "message", null, new Throwable()); From 1d3a41c4242ea202354ab6f83ddee8bf3ed0def1 Mon Sep 17 00:00:00 2001 From: za-PanJing Date: Wed, 30 Dec 2020 20:25:57 +0800 Subject: [PATCH 03/12] Add more test for (Fix bug for FeignException cannot get the correct charset) (#1325) --- .../test/java/feign/FeignExceptionTest.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/core/src/test/java/feign/FeignExceptionTest.java b/core/src/test/java/feign/FeignExceptionTest.java index 402ca673d..a68df3d67 100644 --- a/core/src/test/java/feign/FeignExceptionTest.java +++ b/core/src/test/java/feign/FeignExceptionTest.java @@ -61,7 +61,7 @@ public void canCreateWithRequestOnly() { } @Test - public void canCreateWithOtherCharsetResponse() { + public void createFeignExceptionWithCorrectCharsetResponse() { Map> map = new HashMap<>(); map.put("connection", new ArrayList<>(Collections.singletonList("keep-alive"))); map.put("content-length", new ArrayList<>(Collections.singletonList("100"))); @@ -84,6 +84,30 @@ public void canCreateWithOtherCharsetResponse() { assertThat(exception.getMessage()).isEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); } + @Test + public void createFeignExceptionWithErrorCharsetResponse() { + Map> map = new HashMap<>(); + map.put("connection", new ArrayList<>(Collections.singletonList("keep-alive"))); + map.put("content-length", new ArrayList<>(Collections.singletonList("100"))); + map.put("content-type", new ArrayList<>(Collections.singletonList("application/json;charset=UTF-8"))); + + Request request = Request.create(Request.HttpMethod.GET, + "/home", Collections.emptyMap(), + "data".getBytes(StandardCharsets.UTF_16BE), + StandardCharsets.UTF_16BE, + null); + + Response response = Response.builder() + .status(400) + .body("response".getBytes(StandardCharsets.UTF_16BE)) + .headers(map) + .request(request) + .build(); + + FeignException exception = FeignException.errorStatus("methodKey", response); + assertThat(exception.getMessage()).isNotEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); + } + @Test(expected = NullPointerException.class) public void nullRequestShouldThrowNPEwThrowable() { new Derived(404, "message", null, new Throwable()); From db0ff87fec37c68cf8bccc37f9ddb851ca2b04ae Mon Sep 17 00:00:00 2001 From: za-panjing Date: Mon, 4 Jan 2021 10:07:01 +0800 Subject: [PATCH 04/12] Format test for (Fix bug for FeignException cannot get the correct charset) (#1325) --- .../test/java/feign/FeignExceptionTest.java | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/core/src/test/java/feign/FeignExceptionTest.java b/core/src/test/java/feign/FeignExceptionTest.java index a68df3d67..e2608e165 100644 --- a/core/src/test/java/feign/FeignExceptionTest.java +++ b/core/src/test/java/feign/FeignExceptionTest.java @@ -14,11 +14,9 @@ package feign; import org.junit.Test; - import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.*; - import static org.assertj.core.api.Assertions.assertThat; public class FeignExceptionTest { @@ -65,23 +63,25 @@ public void createFeignExceptionWithCorrectCharsetResponse() { Map> map = new HashMap<>(); map.put("connection", new ArrayList<>(Collections.singletonList("keep-alive"))); map.put("content-length", new ArrayList<>(Collections.singletonList("100"))); - map.put("content-type", new ArrayList<>(Collections.singletonList("application/json;charset=UTF-16BE"))); + map.put("content-type", + new ArrayList<>(Collections.singletonList("application/json;charset=UTF-16BE"))); Request request = Request.create(Request.HttpMethod.GET, - "/home", Collections.emptyMap(), - "data".getBytes(StandardCharsets.UTF_16BE), - StandardCharsets.UTF_16BE, - null); + "/home", Collections.emptyMap(), + "data".getBytes(StandardCharsets.UTF_16BE), + StandardCharsets.UTF_16BE, + null); Response response = Response.builder() - .status(400) - .body("response".getBytes(StandardCharsets.UTF_16BE)) - .headers(map) - .request(request) - .build(); + .status(400) + .body("response".getBytes(StandardCharsets.UTF_16BE)) + .headers(map) + .request(request) + .build(); FeignException exception = FeignException.errorStatus("methodKey", response); - assertThat(exception.getMessage()).isEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); + assertThat(exception.getMessage()) + .isEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); } @Test @@ -89,23 +89,25 @@ public void createFeignExceptionWithErrorCharsetResponse() { Map> map = new HashMap<>(); map.put("connection", new ArrayList<>(Collections.singletonList("keep-alive"))); map.put("content-length", new ArrayList<>(Collections.singletonList("100"))); - map.put("content-type", new ArrayList<>(Collections.singletonList("application/json;charset=UTF-8"))); + map.put("content-type", + new ArrayList<>(Collections.singletonList("application/json;charset=UTF-8"))); Request request = Request.create(Request.HttpMethod.GET, - "/home", Collections.emptyMap(), - "data".getBytes(StandardCharsets.UTF_16BE), - StandardCharsets.UTF_16BE, - null); + "/home", Collections.emptyMap(), + "data".getBytes(StandardCharsets.UTF_16BE), + StandardCharsets.UTF_16BE, + null); Response response = Response.builder() - .status(400) - .body("response".getBytes(StandardCharsets.UTF_16BE)) - .headers(map) - .request(request) - .build(); + .status(400) + .body("response".getBytes(StandardCharsets.UTF_16BE)) + .headers(map) + .request(request) + .build(); FeignException exception = FeignException.errorStatus("methodKey", response); - assertThat(exception.getMessage()).isNotEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); + assertThat(exception.getMessage()) + .isNotEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); } @Test(expected = NullPointerException.class) From b8a6b65c419740fd81bc7edfdbfe8810ba0af77e Mon Sep 17 00:00:00 2001 From: za-PanJing Date: Tue, 29 Dec 2020 17:20:51 +0800 Subject: [PATCH 05/12] Fix bug for FeignException cannot get the correct charset (#1325) --- core/src/main/java/feign/FeignException.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/feign/FeignException.java b/core/src/main/java/feign/FeignException.java index 5d182f407..de2fcdd64 100644 --- a/core/src/main/java/feign/FeignException.java +++ b/core/src/main/java/feign/FeignException.java @@ -450,11 +450,11 @@ private static String getResponseBodyPreview(byte[] body, Charset charset) { private static Charset getResponseCharset(Map> headers) { Collection strings = headers.get("content-type"); - if (strings == null || strings.size() == 0) { + if (strings == null || strings.isEmpty()) { return null; } - Pattern pattern = Pattern.compile("charset=([^\\s])"); + Pattern pattern = Pattern.compile(".*charset=([^\\s|^;]+).*"); Matcher matcher = pattern.matcher(strings.iterator().next()); if (!matcher.lookingAt()) { return null; From 4fdc4950b629d71f268f68b7f229cc5713eeff2f Mon Sep 17 00:00:00 2001 From: za-PanJing Date: Wed, 30 Dec 2020 20:19:31 +0800 Subject: [PATCH 06/12] Add test for (Fix bug for FeignException cannot get the correct charset) (#1325) --- .../test/java/feign/FeignExceptionTest.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/core/src/test/java/feign/FeignExceptionTest.java b/core/src/test/java/feign/FeignExceptionTest.java index b761b7735..402ca673d 100644 --- a/core/src/test/java/feign/FeignExceptionTest.java +++ b/core/src/test/java/feign/FeignExceptionTest.java @@ -14,9 +14,11 @@ package feign; import org.junit.Test; + import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.util.Collections; +import java.util.*; + import static org.assertj.core.api.Assertions.assertThat; public class FeignExceptionTest { @@ -58,6 +60,30 @@ public void canCreateWithRequestOnly() { assertThat(exception.request()).isNotNull(); } + @Test + public void canCreateWithOtherCharsetResponse() { + Map> map = new HashMap<>(); + map.put("connection", new ArrayList<>(Collections.singletonList("keep-alive"))); + map.put("content-length", new ArrayList<>(Collections.singletonList("100"))); + map.put("content-type", new ArrayList<>(Collections.singletonList("application/json;charset=UTF-16BE"))); + + Request request = Request.create(Request.HttpMethod.GET, + "/home", Collections.emptyMap(), + "data".getBytes(StandardCharsets.UTF_16BE), + StandardCharsets.UTF_16BE, + null); + + Response response = Response.builder() + .status(400) + .body("response".getBytes(StandardCharsets.UTF_16BE)) + .headers(map) + .request(request) + .build(); + + FeignException exception = FeignException.errorStatus("methodKey", response); + assertThat(exception.getMessage()).isEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); + } + @Test(expected = NullPointerException.class) public void nullRequestShouldThrowNPEwThrowable() { new Derived(404, "message", null, new Throwable()); From 93f63aa9b8f07c0f79cd85e5cff1089f7e640132 Mon Sep 17 00:00:00 2001 From: za-PanJing Date: Wed, 30 Dec 2020 20:25:57 +0800 Subject: [PATCH 07/12] Add more test for (Fix bug for FeignException cannot get the correct charset) (#1325) --- .../test/java/feign/FeignExceptionTest.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/core/src/test/java/feign/FeignExceptionTest.java b/core/src/test/java/feign/FeignExceptionTest.java index 402ca673d..a68df3d67 100644 --- a/core/src/test/java/feign/FeignExceptionTest.java +++ b/core/src/test/java/feign/FeignExceptionTest.java @@ -61,7 +61,7 @@ public void canCreateWithRequestOnly() { } @Test - public void canCreateWithOtherCharsetResponse() { + public void createFeignExceptionWithCorrectCharsetResponse() { Map> map = new HashMap<>(); map.put("connection", new ArrayList<>(Collections.singletonList("keep-alive"))); map.put("content-length", new ArrayList<>(Collections.singletonList("100"))); @@ -84,6 +84,30 @@ public void canCreateWithOtherCharsetResponse() { assertThat(exception.getMessage()).isEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); } + @Test + public void createFeignExceptionWithErrorCharsetResponse() { + Map> map = new HashMap<>(); + map.put("connection", new ArrayList<>(Collections.singletonList("keep-alive"))); + map.put("content-length", new ArrayList<>(Collections.singletonList("100"))); + map.put("content-type", new ArrayList<>(Collections.singletonList("application/json;charset=UTF-8"))); + + Request request = Request.create(Request.HttpMethod.GET, + "/home", Collections.emptyMap(), + "data".getBytes(StandardCharsets.UTF_16BE), + StandardCharsets.UTF_16BE, + null); + + Response response = Response.builder() + .status(400) + .body("response".getBytes(StandardCharsets.UTF_16BE)) + .headers(map) + .request(request) + .build(); + + FeignException exception = FeignException.errorStatus("methodKey", response); + assertThat(exception.getMessage()).isNotEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); + } + @Test(expected = NullPointerException.class) public void nullRequestShouldThrowNPEwThrowable() { new Derived(404, "message", null, new Throwable()); From 35c802eb4ab4296f023f9e76f2e903e73bb35275 Mon Sep 17 00:00:00 2001 From: za-panjing Date: Mon, 4 Jan 2021 10:07:01 +0800 Subject: [PATCH 08/12] Format test for (Fix bug for FeignException cannot get the correct charset) (#1325) --- .../test/java/feign/FeignExceptionTest.java | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/core/src/test/java/feign/FeignExceptionTest.java b/core/src/test/java/feign/FeignExceptionTest.java index a68df3d67..e2608e165 100644 --- a/core/src/test/java/feign/FeignExceptionTest.java +++ b/core/src/test/java/feign/FeignExceptionTest.java @@ -14,11 +14,9 @@ package feign; import org.junit.Test; - import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.*; - import static org.assertj.core.api.Assertions.assertThat; public class FeignExceptionTest { @@ -65,23 +63,25 @@ public void createFeignExceptionWithCorrectCharsetResponse() { Map> map = new HashMap<>(); map.put("connection", new ArrayList<>(Collections.singletonList("keep-alive"))); map.put("content-length", new ArrayList<>(Collections.singletonList("100"))); - map.put("content-type", new ArrayList<>(Collections.singletonList("application/json;charset=UTF-16BE"))); + map.put("content-type", + new ArrayList<>(Collections.singletonList("application/json;charset=UTF-16BE"))); Request request = Request.create(Request.HttpMethod.GET, - "/home", Collections.emptyMap(), - "data".getBytes(StandardCharsets.UTF_16BE), - StandardCharsets.UTF_16BE, - null); + "/home", Collections.emptyMap(), + "data".getBytes(StandardCharsets.UTF_16BE), + StandardCharsets.UTF_16BE, + null); Response response = Response.builder() - .status(400) - .body("response".getBytes(StandardCharsets.UTF_16BE)) - .headers(map) - .request(request) - .build(); + .status(400) + .body("response".getBytes(StandardCharsets.UTF_16BE)) + .headers(map) + .request(request) + .build(); FeignException exception = FeignException.errorStatus("methodKey", response); - assertThat(exception.getMessage()).isEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); + assertThat(exception.getMessage()) + .isEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); } @Test @@ -89,23 +89,25 @@ public void createFeignExceptionWithErrorCharsetResponse() { Map> map = new HashMap<>(); map.put("connection", new ArrayList<>(Collections.singletonList("keep-alive"))); map.put("content-length", new ArrayList<>(Collections.singletonList("100"))); - map.put("content-type", new ArrayList<>(Collections.singletonList("application/json;charset=UTF-8"))); + map.put("content-type", + new ArrayList<>(Collections.singletonList("application/json;charset=UTF-8"))); Request request = Request.create(Request.HttpMethod.GET, - "/home", Collections.emptyMap(), - "data".getBytes(StandardCharsets.UTF_16BE), - StandardCharsets.UTF_16BE, - null); + "/home", Collections.emptyMap(), + "data".getBytes(StandardCharsets.UTF_16BE), + StandardCharsets.UTF_16BE, + null); Response response = Response.builder() - .status(400) - .body("response".getBytes(StandardCharsets.UTF_16BE)) - .headers(map) - .request(request) - .build(); + .status(400) + .body("response".getBytes(StandardCharsets.UTF_16BE)) + .headers(map) + .request(request) + .build(); FeignException exception = FeignException.errorStatus("methodKey", response); - assertThat(exception.getMessage()).isNotEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); + assertThat(exception.getMessage()) + .isNotEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); } @Test(expected = NullPointerException.class) From 4c1e01ef61a2986ad275786e8ffe6a1b03110fd3 Mon Sep 17 00:00:00 2001 From: za-PanJing Date: Wed, 30 Dec 2020 20:19:31 +0800 Subject: [PATCH 09/12] Add test for (Fix bug for FeignException cannot get the correct charset) (#1325) --- .../test/java/feign/FeignExceptionTest.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/core/src/test/java/feign/FeignExceptionTest.java b/core/src/test/java/feign/FeignExceptionTest.java index e2608e165..6db7b038a 100644 --- a/core/src/test/java/feign/FeignExceptionTest.java +++ b/core/src/test/java/feign/FeignExceptionTest.java @@ -14,9 +14,11 @@ package feign; import org.junit.Test; + import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.*; + import static org.assertj.core.api.Assertions.assertThat; public class FeignExceptionTest { @@ -58,6 +60,30 @@ public void canCreateWithRequestOnly() { assertThat(exception.request()).isNotNull(); } + @Test + public void canCreateWithOtherCharsetResponse() { + Map> map = new HashMap<>(); + map.put("connection", new ArrayList<>(Collections.singletonList("keep-alive"))); + map.put("content-length", new ArrayList<>(Collections.singletonList("100"))); + map.put("content-type", new ArrayList<>(Collections.singletonList("application/json;charset=UTF-16BE"))); + + Request request = Request.create(Request.HttpMethod.GET, + "/home", Collections.emptyMap(), + "data".getBytes(StandardCharsets.UTF_16BE), + StandardCharsets.UTF_16BE, + null); + + Response response = Response.builder() + .status(400) + .body("response".getBytes(StandardCharsets.UTF_16BE)) + .headers(map) + .request(request) + .build(); + + FeignException exception = FeignException.errorStatus("methodKey", response); + assertThat(exception.getMessage()).isEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); + } + @Test public void createFeignExceptionWithCorrectCharsetResponse() { Map> map = new HashMap<>(); From ac315eb7a3afeac28df719146bc46a07145c7173 Mon Sep 17 00:00:00 2001 From: za-PanJing Date: Wed, 30 Dec 2020 20:25:57 +0800 Subject: [PATCH 10/12] Add more test for (Fix bug for FeignException cannot get the correct charset) (#1325) --- .../test/java/feign/FeignExceptionTest.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/core/src/test/java/feign/FeignExceptionTest.java b/core/src/test/java/feign/FeignExceptionTest.java index 6db7b038a..6e42c023e 100644 --- a/core/src/test/java/feign/FeignExceptionTest.java +++ b/core/src/test/java/feign/FeignExceptionTest.java @@ -116,24 +116,24 @@ public void createFeignExceptionWithErrorCharsetResponse() { map.put("connection", new ArrayList<>(Collections.singletonList("keep-alive"))); map.put("content-length", new ArrayList<>(Collections.singletonList("100"))); map.put("content-type", - new ArrayList<>(Collections.singletonList("application/json;charset=UTF-8"))); + new ArrayList<>(Collections.singletonList("application/json;charset=UTF-8"))); Request request = Request.create(Request.HttpMethod.GET, - "/home", Collections.emptyMap(), - "data".getBytes(StandardCharsets.UTF_16BE), - StandardCharsets.UTF_16BE, - null); + "/home", Collections.emptyMap(), + "data".getBytes(StandardCharsets.UTF_16BE), + StandardCharsets.UTF_16BE, + null); Response response = Response.builder() - .status(400) - .body("response".getBytes(StandardCharsets.UTF_16BE)) - .headers(map) - .request(request) - .build(); + .status(400) + .body("response".getBytes(StandardCharsets.UTF_16BE)) + .headers(map) + .request(request) + .build(); FeignException exception = FeignException.errorStatus("methodKey", response); assertThat(exception.getMessage()) - .isNotEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); + .isNotEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); } @Test(expected = NullPointerException.class) From 7f2e7c9999540d42bca0275bce9c8310ae276f93 Mon Sep 17 00:00:00 2001 From: za-panjing Date: Mon, 4 Jan 2021 10:07:01 +0800 Subject: [PATCH 11/12] Format test for (Fix bug for FeignException cannot get the correct charset) (#1325) --- .../test/java/feign/FeignExceptionTest.java | 48 +++++-------------- 1 file changed, 11 insertions(+), 37 deletions(-) diff --git a/core/src/test/java/feign/FeignExceptionTest.java b/core/src/test/java/feign/FeignExceptionTest.java index 6e42c023e..e2608e165 100644 --- a/core/src/test/java/feign/FeignExceptionTest.java +++ b/core/src/test/java/feign/FeignExceptionTest.java @@ -14,11 +14,9 @@ package feign; import org.junit.Test; - import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.*; - import static org.assertj.core.api.Assertions.assertThat; public class FeignExceptionTest { @@ -60,30 +58,6 @@ public void canCreateWithRequestOnly() { assertThat(exception.request()).isNotNull(); } - @Test - public void canCreateWithOtherCharsetResponse() { - Map> map = new HashMap<>(); - map.put("connection", new ArrayList<>(Collections.singletonList("keep-alive"))); - map.put("content-length", new ArrayList<>(Collections.singletonList("100"))); - map.put("content-type", new ArrayList<>(Collections.singletonList("application/json;charset=UTF-16BE"))); - - Request request = Request.create(Request.HttpMethod.GET, - "/home", Collections.emptyMap(), - "data".getBytes(StandardCharsets.UTF_16BE), - StandardCharsets.UTF_16BE, - null); - - Response response = Response.builder() - .status(400) - .body("response".getBytes(StandardCharsets.UTF_16BE)) - .headers(map) - .request(request) - .build(); - - FeignException exception = FeignException.errorStatus("methodKey", response); - assertThat(exception.getMessage()).isEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); - } - @Test public void createFeignExceptionWithCorrectCharsetResponse() { Map> map = new HashMap<>(); @@ -116,24 +90,24 @@ public void createFeignExceptionWithErrorCharsetResponse() { map.put("connection", new ArrayList<>(Collections.singletonList("keep-alive"))); map.put("content-length", new ArrayList<>(Collections.singletonList("100"))); map.put("content-type", - new ArrayList<>(Collections.singletonList("application/json;charset=UTF-8"))); + new ArrayList<>(Collections.singletonList("application/json;charset=UTF-8"))); Request request = Request.create(Request.HttpMethod.GET, - "/home", Collections.emptyMap(), - "data".getBytes(StandardCharsets.UTF_16BE), - StandardCharsets.UTF_16BE, - null); + "/home", Collections.emptyMap(), + "data".getBytes(StandardCharsets.UTF_16BE), + StandardCharsets.UTF_16BE, + null); Response response = Response.builder() - .status(400) - .body("response".getBytes(StandardCharsets.UTF_16BE)) - .headers(map) - .request(request) - .build(); + .status(400) + .body("response".getBytes(StandardCharsets.UTF_16BE)) + .headers(map) + .request(request) + .build(); FeignException exception = FeignException.errorStatus("methodKey", response); assertThat(exception.getMessage()) - .isNotEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); + .isNotEqualTo("[400] during [GET] to [/home] [methodKey]: [response]"); } @Test(expected = NullPointerException.class) From a3fcf37b5dc5b3748dee8b4046fb0b965c34aa89 Mon Sep 17 00:00:00 2001 From: "Davis, Kevin" Date: Sun, 7 Mar 2021 11:52:14 -0500 Subject: [PATCH 12/12] Correcting License Headers for 2021 --- core/src/test/java/feign/FeignExceptionTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/test/java/feign/FeignExceptionTest.java b/core/src/test/java/feign/FeignExceptionTest.java index e2608e165..81b16c847 100644 --- a/core/src/test/java/feign/FeignExceptionTest.java +++ b/core/src/test/java/feign/FeignExceptionTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2020 The Feign Authors + * Copyright 2012-2021 The Feign 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