From 5e317721430b7c6d849d93cfef5323795fa7a524 Mon Sep 17 00:00:00 2001 From: Jon Marius Venstad Date: Fri, 8 Apr 2022 08:00:17 +0200 Subject: Return "this" when no removal occurs --- vespajlib/src/main/java/ai/vespa/http/HttpURL.java | 6 ++++-- 1 file 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 decoded 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 filter, Node node) { @@ -460,7 +461,8 @@ public class HttpURL { /** Returns a copy of this with all given keys removed. */ public Query remove(Collection keys) { - return new Query(without(keys::contains, head), validator); + Node node = without(keys::contains, head); + return node == head ? this : new Query(node, validator); } /** -- cgit v1.2.3