From 560239a92b7169b8147eb66c0186de91f132d39a Mon Sep 17 00:00:00 2001 From: Artem Gorshkov <47691597+gorshik@users.noreply.github.com> Date: Thu, 28 Apr 2022 12:36:53 +0300 Subject: [PATCH] Delete '/' at the end of url In situation when we create FeignClient in this way: @FeignClient(url = "https://localhost/", path = "api/v2") We will get an error because of adding '/' in the beginning of the path in FeignClientsRegistrar.getPath, result will: https://localhost//api/v2 To escape this situation we need to delete '/' at the end of url in FeignClientsRegistrar.getUrl --- .../springframework/cloud/openfeign/FeignClientsRegistrar.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsRegistrar.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsRegistrar.java index 03149a51..00fe8f19 100644 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsRegistrar.java +++ b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsRegistrar.java @@ -118,6 +118,9 @@ class FeignClientsRegistrar implements ImportBeanDefinitionRegistrar, ResourceLo if (!url.contains("://")) { url = "http://" + url; } + if (url.endsWith("/")) { + url = url.substring(0, url.length() - 1); + } try { new URL(url); }