diff options
-rw-r--r-- | vespajlib/src/main/java/ai/vespa/http/HttpURL.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/vespajlib/src/main/java/ai/vespa/http/HttpURL.java b/vespajlib/src/main/java/ai/vespa/http/HttpURL.java index 211ce52f7ab..22fe4adff27 100644 --- a/vespajlib/src/main/java/ai/vespa/http/HttpURL.java +++ b/vespajlib/src/main/java/ai/vespa/http/HttpURL.java @@ -426,7 +426,8 @@ public class HttpURL { /** Returns a copy of this without any key-value pair with the <em>decoded</em> key. */ public Query remove(String key) { - return new Query(without(key::equals, head), validator); + Node node = without(key::equals, head); + return node == head ? this : new Query(node, validator); } private static Node without(Predicate<String> filter, Node node) { @@ -460,7 +461,8 @@ public class HttpURL { /** Returns a copy of this with all given keys removed. */ public Query remove(Collection<String> keys) { - return new Query(without(keys::contains, head), validator); + Node node = without(keys::contains, head); + return node == head ? this : new Query(node, validator); } /** |