WHATS WRONG:
Some external apis can send header Content-Type: text/xml;charset="utf-8" in response. Problem is with quotes.
Method Charset.isSupported throws exception when quotes are part of input string as it checks valid characters.
So building FeignException throws exception in this case.
EXPECTED BEHAVIOUR:
IF statement does not throw exception. It returns true or null in this case. We can't change external api and preprocess response headers is impossible as they are unmodifiable.
SOLUTION:
A. If you want to return true just sanitize String input group and remove for example quotes. Or change regexp to extract it without quotes.
group.replaceAll("\"", "");
B. Catch llegalCharsetNameException and return null from IF statement.
WHERE: In this class https://github.com/OpenFeign/feign/blob/master/core/src/main/java/feign/FeignException.java is piece of code:
WHATS WRONG: Some external apis can send header Content-Type: text/xml;charset="utf-8" in response. Problem is with quotes. Method Charset.isSupported throws exception when quotes are part of input string as it checks valid characters. So building FeignException throws exception in this case.
EXPECTED BEHAVIOUR: IF statement does not throw exception. It returns true or null in this case. We can't change external api and preprocess response headers is impossible as they are unmodifiable.
SOLUTION: A. If you want to return true just sanitize String input group and remove for example quotes. Or change regexp to extract it without quotes.
group.replaceAll("\"", "");
B. Catch llegalCharsetNameException and return null from IF statement.