maple525866 commented on code in PR #7684:
URL: https://github.com/apache/incubator-seata/pull/7684#discussion_r2432844813


##########
common/src/main/java/org/apache/seata/common/http/Http1HttpExecutor.java:
##########
@@ -54,6 +58,25 @@ public class HttpClientUtil {
 
     private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
 
+    public static volatile Http1HttpExecutor instance;
+
+    /**
+     * Gets instance.
+     *
+     * @return the instance
+     */
+    public static Http1HttpExecutor getInstance() {
+
+        if (instance == null) {
+            synchronized (Http1HttpExecutor.class) {
+                if (instance == null) {
+                    instance = new Http1HttpExecutor();
+                }
+            }
+        }
+        return instance;
+    }

Review Comment:
   I think some resources may need to be reused here, such as the connection 
pool here, and using a singleton can avoid the state inconsistency problems 
caused by multiple instances and the performance problems caused by frequent 
object creation.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to