aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@gmail.com>2022-04-08 08:00:17 +0200
committerJon Marius Venstad <jonmv@gmail.com>2022-04-08 08:00:17 +0200
commit5e317721430b7c6d849d93cfef5323795fa7a524 (patch)
tree51c5494b9494fea1093f96dd4c0e49ebe3a5d956
parent091cc4ee3f1075f42c04798b9359d11b5126a4d2 (diff)
Return "this" when no removal occurs
-rw-r--r--vespajlib/src/main/java/ai/vespa/http/HttpURL.java6
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);
}
/**