You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/09/26 12:07:42 UTC

[GitHub] [dubbo] DiegoKrupitza commented on a change in pull request #8927: [master] Fix #8240, on branch master, when provider and consumer stop cause NPE

DiegoKrupitza commented on a change in pull request #8927:
URL: https://github.com/apache/dubbo/pull/8927#discussion_r716194244



##########
File path: dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ApplicationModel.java
##########
@@ -119,7 +119,7 @@ public static String tryGetApplication() {
             return application;
         }
         Optional<ApplicationConfig> appCfgOptional = getConfigManager().getApplication();
-        return appCfgOptional.isPresent() ? appCfgOptional.get().getName() : null;
+        return appCfgOptional.map(ApplicationConfig::getName).orElse(null);

Review comment:
       Could be converted to a one liner. This will make it more readable and you do not really continue working with `appCfgOptional`.
   
   My advice replace it with 
   
   ```
   return getConfigManager().getApplication()
   .map(ApplicationConfig::getName)
   .orElse(null);
   ```
   




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