Skip to content

Commit

Permalink
Fix bug for FeignException cannot get the correct charset (OpenFeign#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Linda-pan committed Jan 18, 2021
1 parent 4cf1a54 commit b8a6b65
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/feign/FeignException.java
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,11 @@ private static String getResponseBodyPreview(byte[] body, Charset charset) {
private static Charset getResponseCharset(Map<String, Collection<String>> headers) {

Collection<String> 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;
Expand Down

0 comments on commit b8a6b65

Please sign in to comment.