xwm1992 commented on code in PR #3243:
URL: 
https://github.com/apache/incubator-eventmesh/pull/3243#discussion_r1116432318


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/producer/EventMeshProducer.java:
##########
@@ -83,32 +86,24 @@ public synchronized void init(EventMeshHTTPConfiguration 
eventMeshHttpConfigurat
         keyValue.put("eventMeshIDC", 
eventMeshHttpConfiguration.getEventMeshIDC());
         mqProducerWrapper = new 
MQProducerWrapper(eventMeshHttpConfiguration.getEventMeshConnectorPluginType());
         mqProducerWrapper.init(keyValue);
-        inited.compareAndSet(false, true);
         log.info("EventMeshProducer [{}] inited.............", 
producerGroupConfig.getGroupName());
     }
 
 
-    public synchronized void start() throws Exception {
-        if (started.get()) {
+    public void start() throws Exception {
+
+        if (!started.compareAndSet(false, true)) {
             return;
         }
-
         mqProducerWrapper.start();
-        started.compareAndSet(false, true);
         log.info("EventMeshProducer [{}] started.............", 
producerGroupConfig.getGroupName());
     }
 
-    public synchronized void shutdown() throws Exception {
-        if (!inited.get()) {
-            return;
-        }
-
-        if (!started.get()) {
+    public void shutdown() throws Exception {
+        if (!inited.compareAndSet(true, false && !started.compareAndSet(true, 
false))) {

Review Comment:
   the code logic of this paragraph is easy to make people confused, may be you 
use `if(!inited.compareAndSet(true, false) {...}`, 
`if(!started.compareAndSet(true, false) {...}` much better.



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