From 70e0302c02ace3c013df132b8ea5e5dcc81e85ff Mon Sep 17 00:00:00 2001 From: Bowen Liang Date: Tue, 15 Oct 2024 17:02:13 +0800 Subject: [PATCH] [KYUUBI #6727] replace immutable empty list and map in BatchRequest initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # :mag: Description ## Issue References ๐Ÿ”— This pull request fixes # ## Describe Your Solution ๐Ÿ”ง - replace immutable empty list and map with mutable one for BatchRequest initialization, for easier BatchRequest construction for rest-client use ## Types of changes :bookmark: - [ ] Bugfix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Test Plan ๐Ÿงช #### Behavior Without This Pull Request :coffin: #### Behavior With This Pull Request :tada: #### Related Unit Tests --- # Checklist ๐Ÿ“ - [ ] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html) **Be nice. Be informative.** Closes #6727 from bowenliang123/batchapi-emptylist. Closes #6727 9d6a04c8a [Bowen Liang] update Authored-by: Bowen Liang Signed-off-by: Bowen Liang --- .../kyuubi/client/api/v1/dto/BatchRequest.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/BatchRequest.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/BatchRequest.java index ac9850498de..2e6da91611b 100644 --- a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/BatchRequest.java +++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/BatchRequest.java @@ -17,10 +17,7 @@ package org.apache.kyuubi.client.api.v1.dto; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -29,9 +26,9 @@ public class BatchRequest { private String resource; private String className; private String name; - private Map conf = Collections.emptyMap(); - private List args = Collections.emptyList(); - private Map extraResourcesMap = Collections.emptyMap(); + private Map conf = new HashMap<>(0); + private List args = new ArrayList<>(0); + private Map extraResourcesMap = new HashMap<>(0); public BatchRequest() {} @@ -91,7 +88,7 @@ public void setName(String name) { public Map getConf() { if (null == conf) { - return Collections.emptyMap(); + return new HashMap<>(0); } return conf; } @@ -102,7 +99,7 @@ public void setConf(Map conf) { public List getArgs() { if (null == args) { - return Collections.emptyList(); + return new ArrayList<>(0); } return args; }