Adds a check for an empty URI in updateToHttpsIfNeeded. Fixes #1690.
This commit is contained in:
@@ -71,7 +71,7 @@ public class RibbonUtils {
|
||||
public static URI updateToHttpsIfNeeded(URI uri, IClientConfig config, ServerIntrospector serverIntrospector,
|
||||
Server server) {
|
||||
String scheme = uri.getScheme();
|
||||
if (!"https".equals(scheme) && isSecure(config, serverIntrospector, server)) {
|
||||
if (!"".equals(uri.toString()) && !"https".equals(scheme) && isSecure(config, serverIntrospector, server)) {
|
||||
UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUri(uri).scheme("https");
|
||||
if (uri.getRawQuery() != null) {
|
||||
// When building the URI, UriComponentsBuilder verify the allowed characters and does not
|
||||
|
||||
@@ -110,6 +110,14 @@ public class RibbonUtilsTests {
|
||||
"https://foo/%20bar?hello=1%202")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyStringUri() throws URISyntaxException {
|
||||
URI original = new URI("");
|
||||
URI updated = updateToHttpsIfNeeded(original, SECURE_CONFIG, SECURE_INTROSPECTOR, SERVER);
|
||||
Assert.assertThat("URI should be the emptry string", updated, is(new URI(
|
||||
"")));
|
||||
}
|
||||
|
||||
static DefaultClientConfigImpl getConfig(boolean value) {
|
||||
DefaultClientConfigImpl config = new DefaultClientConfigImpl();
|
||||
config.setProperty(CommonClientConfigKey.IsSecure, value);
|
||||
|
||||
Reference in New Issue
Block a user