yuluo-yx commented on code in PR #256:
URL: 
https://github.com/apache/apisix-java-plugin-runner/pull/256#discussion_r1288553159


##########
runner-plugin-sdk/src/main/java/org/apache/apisix/plugin/runner/PostResponse.java:
##########
@@ -116,7 +130,27 @@ public void setHeader(String headerKey, String 
headerValue) {
         if (Objects.isNull(headers)) {
             headers = new HashMap<>();
         }
-        headers.put(headerKey, headerValue);
+
+        headers.put(headerKey, new ArrayList<>());
+        headers.get(headerKey).add(headerValue);
+    }
+
+    public void addHeader(String headerKey, String headerValue) {

Review Comment:
   My suggestion here is to use the correct modifier type. If the method is 
only used in this class, it will be better to use private modification.



##########
runner-core/src/main/java/org/apache/apisix/plugin/runner/handler/RpcCallHandler.java:
##########
@@ -17,39 +17,22 @@
 
 package org.apache.apisix.plugin.runner.handler;
 
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Queue;
-import java.util.Set;
-
 import com.google.common.cache.Cache;
 import io.github.api7.A6.Err.Code;
 import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelFutureListener;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.SimpleChannelInboundHandler;
-import org.apache.apisix.plugin.runner.A6Conf;
-import org.apache.apisix.plugin.runner.A6ErrRequest;
-import org.apache.apisix.plugin.runner.A6ErrResponse;
-import org.apache.apisix.plugin.runner.A6Request;
-import org.apache.apisix.plugin.runner.ExtraInfoRequest;
-import org.apache.apisix.plugin.runner.ExtraInfoResponse;
-import org.apache.apisix.plugin.runner.HttpRequest;
-import org.apache.apisix.plugin.runner.HttpResponse;
-import org.apache.apisix.plugin.runner.PostRequest;
-import org.apache.apisix.plugin.runner.PostResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.util.CollectionUtils;
 import lombok.RequiredArgsConstructor;
-
+import org.apache.apisix.plugin.runner.*;
 import org.apache.apisix.plugin.runner.constants.Constants;
 import org.apache.apisix.plugin.runner.filter.PluginFilter;
 import org.apache.apisix.plugin.runner.filter.PluginFilterChain;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.CollectionUtils;
+
+import java.util.*;

Review Comment:
   It is not recommended to introduce all the java class libraries here. The 
introduction of redundant class libraries will slow down the compilation. Just 
import the required libraries.
   It is recommended to start optimized imports in idea and remove useless 
imports.



##########
runner-plugin-sdk/src/main/java/org/apache/apisix/plugin/runner/PostResponse.java:
##########
@@ -116,7 +130,27 @@ public void setHeader(String headerKey, String 
headerValue) {
         if (Objects.isNull(headers)) {
             headers = new HashMap<>();
         }
-        headers.put(headerKey, headerValue);
+
+        headers.put(headerKey, new ArrayList<>());
+        headers.get(headerKey).add(headerValue);
+    }
+
+    public void addHeader(String headerKey, String headerValue) {
+        if (headerKey == null) {
+            logger.warn("headerKey is null, ignore it");
+            return;
+        }
+
+        if (Objects.isNull(headers)) {
+            headers = new HashMap<>();
+        }
+
+        headers.putIfAbsent(headerKey, new ArrayList<>());
+        headers.get(headerKey).add(headerValue);
+    }
+
+    public Map<String, List<String>> headers() {

Review Comment:
   Ditto!
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to