diff options
author | Jon Marius Venstad <jonmv@gmail.com> | 2022-04-08 08:00:17 +0200 |
---|---|---|
committer | Jon Marius Venstad <jonmv@gmail.com> | 2022-04-08 08:00:17 +0200 |
commit | 5e317721430b7c6d849d93cfef5323795fa7a524 (patch) | |
tree | 51c5494b9494fea1093f96dd4c0e49ebe3a5d956 /vespajlib/src | |
parent | 091cc4ee3f1075f42c04798b9359d11b5126a4d2 (diff) |
Return "this" when no removal occurs
Diffstat (limited to 'vespajlib/src')
-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); } /** |