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)

Commits related to this issue

Most upvoted comments

When I get home later tonight I’ll attach the file to the issue. Sorry for the delay.

On Aug 18, 2016, at 1:04 PM, Spencer Gibb notifications@github.com wrote:

You can attach zip files to this issue, put a link to a github project or public dropbox.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

I’ll go ahead and create a sample app to repro then submit it. I’ll be able to do that tomorrow night.

On Aug 16, 2016, at 17:32, Ryan Baxter notifications@github.com wrote:

@russTbaker https://github.com/russTbaker doesnt sound like I reproduced it, the app never even starts for me, and I don’t see an NPE being thrown

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/spring-cloud/spring-cloud-netflix/issues/1257#issuecomment-240271249, or mute the thread https://github.com/notifications/unsubscribe-auth/ABnfrXVWZ9xBnsjruTHXJ4RjdTANikA8ks5qgkiogaJpZM4JjmCa.