This is an automated email from the ASF dual-hosted git repository.

xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 9c0ff5208 code polish. (#3361)
9c0ff5208 is described below

commit 9c0ff5208a0728ed113d2508b5c145c79fb460d0
Author: Kevin Clair <[email protected]>
AuthorDate: Tue May 3 12:12:51 2022 +0800

    code polish. (#3361)
---
 .../org/apache/shenyu/plugin/dubbo/common/AbstractDubboPlugin.java | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git 
a/shenyu-plugin/shenyu-plugin-dubbo/shenyu-plugin-dubbo-common/src/main/java/org/apache/shenyu/plugin/dubbo/common/AbstractDubboPlugin.java
 
b/shenyu-plugin/shenyu-plugin-dubbo/shenyu-plugin-dubbo-common/src/main/java/org/apache/shenyu/plugin/dubbo/common/AbstractDubboPlugin.java
index 8acb76988..5c6546dde 100644
--- 
a/shenyu-plugin/shenyu-plugin-dubbo/shenyu-plugin-dubbo-common/src/main/java/org/apache/shenyu/plugin/dubbo/common/AbstractDubboPlugin.java
+++ 
b/shenyu-plugin/shenyu-plugin-dubbo/shenyu-plugin-dubbo-common/src/main/java/org/apache/shenyu/plugin/dubbo/common/AbstractDubboPlugin.java
@@ -38,6 +38,7 @@ import reactor.core.publisher.Mono;
 
 import java.util.Map;
 import java.util.Objects;
+import java.util.Optional;
 
 /**
  * AbstractDubboPlugin.
@@ -141,9 +142,9 @@ public abstract class AbstractDubboPlugin extends 
AbstractShenyuPlugin {
 
     private void rpcContext(final ServerWebExchange exchange) {
         Map<String, Map<String, String>> rpcContext = 
exchange.getAttribute(Constants.GENERAL_CONTEXT);
-        if (Objects.nonNull(rpcContext) && 
Objects.nonNull(rpcContext.get(PluginEnum.DUBBO.getName()))) {
-            
this.transmitRpcContext(rpcContext.get(PluginEnum.DUBBO.getName()));
-        }
+        Optional.ofNullable(rpcContext)
+                .map(context -> context.get(PluginEnum.DUBBO.getName()))
+                .ifPresent(this::transmitRpcContext);
     }
 
     private boolean checkMetaData(final MetaData metaData) {

Reply via email to