You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "AlbumenJ (via GitHub)" <gi...@apache.org> on 2023/02/14 02:47:55 UTC

[GitHub] [dubbo] AlbumenJ commented on a diff in pull request #11533: Perfect some code

AlbumenJ commented on code in PR #11533:
URL: https://github.com/apache/dubbo/pull/11533#discussion_r1105232573


##########
dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ApplicationModel.java:
##########
@@ -251,7 +250,7 @@ protected void onDestroy() {
         frameworkModel.tryDestroyProtocols();
 
         // 4. destroy application resources
-        for (ModuleModel moduleModel : new ArrayList<>(moduleModels)) {
+        for (ModuleModel moduleModel : moduleModels) {

Review Comment:
   Do not change this line. Prevent ConcurrentModificationException here.



##########
dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java:
##########
@@ -230,9 +230,8 @@ private void registerShutdownHook() {
     private void initModuleDeployers() {
         // make sure created default module
         applicationModel.getDefaultModule();
-        // copy modules and initialize avoid ConcurrentModificationException if add new module
-        List<ModuleModel> moduleModels = new ArrayList<>(applicationModel.getModuleModels());
-        for (ModuleModel moduleModel : moduleModels) {
+        // deployer initialize
+        for (ModuleModel moduleModel : applicationModel.getModuleModels()) {

Review Comment:
   Also for here.



##########
dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ApplicationModel.java:
##########
@@ -251,7 +250,7 @@ protected void onDestroy() {
         frameworkModel.tryDestroyProtocols();
 
         // 4. destroy application resources
-        for (ModuleModel moduleModel : new ArrayList<>(moduleModels)) {
+        for (ModuleModel moduleModel : moduleModels) {

Review Comment:
   `moduleModel.destroy` will remove itself in `moduleModels`



-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org