pandaapo commented on code in PR #4696:
URL: https://github.com/apache/eventmesh/pull/4696#discussion_r1438116397


##########
eventmesh-sdks/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/TcpClient.java:
##########
@@ -181,10 +181,12 @@ protected void send(Package msg) throws Exception {
     protected Package io(Package msg, long timeout) throws Exception {
         Object key = RequestContext.key(msg);
         RequestContext context = RequestContext.context(key, msg);
-        if (!contexts.containsValue(context)) {
-            contexts.put(key, context);
-        } else {
-            LogUtils.info(log, "duplicate key : {}", key);
+        synchronized (context) {

Review Comment:
   Using `context` as a lock object does not seem to achieve thread safety, as 
`context` will be different objects in concurrent situations.
   Perhaps ConcurrentHashMap#putIfAbsent() is one of the optional solutions.



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