Copilot commented on code in PR #7082:
URL: https://github.com/apache/shenyu/pull/7082#discussion_r4032818857


##########
shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/disruptor/ShenyuClientRegisterEventPublisher.java:
##########
@@ -50,14 +52,18 @@ public static ShenyuClientRegisterEventPublisher 
getInstance() {
      *
      * @param shenyuClientRegisterRepository shenyuClientRegisterRepository
      */
-    public void start(final ShenyuClientRegisterRepository 
shenyuClientRegisterRepository) {
+    public synchronized void start(final ShenyuClientRegisterRepository 
shenyuClientRegisterRepository) {
+        if (Objects.nonNull(providerManage)) {
+            return;
+        }
         RegisterClientExecutorFactory factory = new 
RegisterClientExecutorFactory();
         factory.addSubscribers(new 
ShenyuClientMetadataExecutorSubscriber(shenyuClientRegisterRepository));
         factory.addSubscribers(new 
ShenyuClientURIExecutorSubscriber(shenyuClientRegisterRepository));
         factory.addSubscribers(new 
ShenyuClientApiDocExecutorSubscriber(shenyuClientRegisterRepository));
         factory.addSubscribers(new 
ShenyuClientMcpExecutorSubscriber(shenyuClientRegisterRepository));
-        providerManage = new DisruptorProviderManage<>(factory);
-        providerManage.startup();
+        DisruptorProviderManage<DataTypeParent> manage = new 
DisruptorProviderManage<>(factory);
+        manage.startup();

Review Comment:
   If `manage.startup()` throws, `providerManage` intentionally remains null, 
but the URI subscriber created above has already started its heartbeat 
scheduler. A later `start()` retry then creates another scheduler; because 
`URIS` is static, both schedulers send duplicate heartbeats, recreating the 
leak this change is meant to prevent. Please add failure cleanup for the 
constructed subscribers (and any partially started Disruptor resources) before 
allowing initialization to be retried.



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