spring-cloud-netflix: NullPointerException thrown if illegal characters are used in URI
If illegal characters are used in the @FeignClient(“<service_name>”) annotation, then the org.springframework.cloud.netflix.feign.ribbon.LoadBalancerFeignClient will throw a NullPointerException. The execute method uses the following code to create the URI which is then passed down to the cleanUri method:
URI asUri = URI.create(request.url());
String clientName = asUri.getHost();
URI uriWithoutHost = cleanUrl(request.url(), clientName);
static URI cleanUrl(String originalUrl, String host) {
return URI.create(originalUrl.replaceFirst(host, ""));
}
if the URI has an illegal character, then the “host” is null, which results in a NullPointerException.
If there was a check using a regular expression prior to creating the URI, then the user can be notified that the URL that is being passed in is invalid instead of throwing an NPE.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 19 (10 by maintainers)
When I get home later tonight I’ll attach the file to the issue. Sorry for the delay.
I’ll go ahead and create a sample app to repro then submit it. I’ll be able to do that tomorrow night.