kylixs commented on a change in pull request #9381:
URL: https://github.com/apache/dubbo/pull/9381#discussion_r773570510



##########
File path: 
dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java
##########
@@ -184,14 +183,8 @@ public ReferenceCache getReferenceCache() {
      */
     @Override
     public void initialize() {
-        if (initialized.get()) {
-            return;
-        }
         // Ensure that the initialization is completed when concurrent calls
-        synchronized (startLock) {
-            if (initialized.get()) {
-                return;
-            }
+        if (initialized.compareAndSet(false, true)) {
             // register shutdown hook

Review comment:
       The purpose of the `startLock` is:
   > Ensure that the initialization is completed when concurrent calls
   
   If change to `compareAndSet`, it will not block until the 
`DefaultApplicationDeployer` was initialized, it is unsafe.
   
   Possible case:
   1. The first call, start to initialize, but not complete
   2. In the second call, check that it has been initialized, skip it, and 
proceed  the following startup. At this time, the initialization may not be 
completed, resulting in an error




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