You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by de...@apache.org on 2022/10/09 11:53:54 UTC

[shenyu] branch master updated: [type: refactor] refactor some code (#4051)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new c986aad3a [type: refactor] refactor some code (#4051)
c986aad3a is described below

commit c986aad3a31f051a374f0d60adac643d3ec36c55
Author: xiaoyu <xi...@apache.org>
AuthorDate: Sun Oct 9 19:53:44 2022 +0800

    [type: refactor] refactor some code (#4051)
---
 .../java/org/apache/shenyu/plugin/base/AbstractShenyuPlugin.java    | 5 +----
 .../java/org/apache/shenyu/sdk/core/common/RequestTemplate.java     | 3 +--
 .../src/main/java/org/apache/shenyu/sdk/core/util/Util.java         | 3 ++-
 shenyu-sdk/shenyu-sdk-spring/pom.xml                                | 3 +--
 .../apache/shenyu/sync/data/zookeeper/ZookeeperSyncDataService.java | 6 +-----
 5 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/AbstractShenyuPlugin.java b/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/AbstractShenyuPlugin.java
index 06488341d..3e30dd691 100644
--- a/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/AbstractShenyuPlugin.java
+++ b/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/AbstractShenyuPlugin.java
@@ -158,10 +158,7 @@ public abstract class AbstractShenyuPlugin implements ShenyuPlugin {
     }
 
     private SelectorData obtainSelectorDataCacheIfEnabled(final ServerWebExchange exchange) {
-        if (matchCacheConfig.getEnabled()) {
-            return MatchDataCache.getInstance().obtainSelectorData(named(), exchange.getRequest().getURI().getPath());
-        }
-        return null;
+        return matchCacheConfig.getEnabled() ? MatchDataCache.getInstance().obtainSelectorData(named(), exchange.getRequest().getURI().getPath()) : null;
     }
     
     protected RuleData defaultRuleData(final SelectorData selectorData) {
diff --git a/shenyu-sdk/shenyu-sdk-core/src/main/java/org/apache/shenyu/sdk/core/common/RequestTemplate.java b/shenyu-sdk/shenyu-sdk-core/src/main/java/org/apache/shenyu/sdk/core/common/RequestTemplate.java
index 3dfaa14aa..ebee97605 100644
--- a/shenyu-sdk/shenyu-sdk-core/src/main/java/org/apache/shenyu/sdk/core/common/RequestTemplate.java
+++ b/shenyu-sdk/shenyu-sdk-core/src/main/java/org/apache/shenyu/sdk/core/common/RequestTemplate.java
@@ -19,7 +19,6 @@ package org.apache.shenyu.sdk.core.common;
 
 import org.apache.shenyu.sdk.core.ShenyuRequest;
 
-import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.util.Collection;
@@ -34,7 +33,7 @@ import java.util.Map;
  * information also support template expressions.
  * </p>
  */
-public final class RequestTemplate implements Serializable {
+public final class RequestTemplate {
 
     private transient Class<?> returnType;
 
diff --git a/shenyu-sdk/shenyu-sdk-core/src/main/java/org/apache/shenyu/sdk/core/util/Util.java b/shenyu-sdk/shenyu-sdk-core/src/main/java/org/apache/shenyu/sdk/core/util/Util.java
index 498c9c8e8..62be898cf 100644
--- a/shenyu-sdk/shenyu-sdk-core/src/main/java/org/apache/shenyu/sdk/core/util/Util.java
+++ b/shenyu-sdk/shenyu-sdk-core/src/main/java/org/apache/shenyu/sdk/core/util/Util.java
@@ -20,6 +20,7 @@ package org.apache.shenyu.sdk.core.util;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import static java.lang.String.format;
 
@@ -31,7 +32,7 @@ public final class Util {
     /**
      * UTF-8: eight-bit UCS Transformation Format.
      */
-    public static final Charset UTF_8 = Charset.forName("UTF-8");
+    public static final Charset UTF_8 = StandardCharsets.UTF_8;
 
     /**
      * checkArgument.
diff --git a/shenyu-sdk/shenyu-sdk-spring/pom.xml b/shenyu-sdk/shenyu-sdk-spring/pom.xml
index 68987a227..e8b69ad7d 100644
--- a/shenyu-sdk/shenyu-sdk-spring/pom.xml
+++ b/shenyu-sdk/shenyu-sdk-spring/pom.xml
@@ -25,8 +25,7 @@
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>shenyu-sdk-spring</artifactId>
-
-
+    
     <dependencies>
         <dependency>
             <groupId>org.apache.shenyu</groupId>
diff --git a/shenyu-sync-data-center/shenyu-sync-data-zookeeper/src/main/java/org/apache/shenyu/sync/data/zookeeper/ZookeeperSyncDataService.java b/shenyu-sync-data-center/shenyu-sync-data-zookeeper/src/main/java/org/apache/shenyu/sync/data/zookeeper/ZookeeperSyncDataService.java
index 2443481ec..a0875eec9 100644
--- a/shenyu-sync-data-center/shenyu-sync-data-zookeeper/src/main/java/org/apache/shenyu/sync/data/zookeeper/ZookeeperSyncDataService.java
+++ b/shenyu-sync-data-center/shenyu-sync-data-zookeeper/src/main/java/org/apache/shenyu/sync/data/zookeeper/ZookeeperSyncDataService.java
@@ -37,8 +37,6 @@ import org.apache.shenyu.sync.data.api.AuthDataSubscriber;
 import org.apache.shenyu.sync.data.api.MetaDataSubscriber;
 import org.apache.shenyu.sync.data.api.PluginDataSubscriber;
 import org.apache.shenyu.sync.data.api.SyncDataService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
@@ -52,8 +50,6 @@ import java.util.Optional;
  */
 public class ZookeeperSyncDataService implements SyncDataService {
 
-    private static final Logger LOGGER = LoggerFactory.getLogger(ZookeeperSyncDataService.class);
-
     private final ZookeeperClient zkClient;
 
     private final PluginDataSubscriber pluginDataSubscriber;
@@ -171,7 +167,7 @@ public class ZookeeperSyncDataService implements SyncDataService {
         }
     }
 
-    abstract class AbstractDataSyncListener implements TreeCacheListener {
+    abstract static class AbstractDataSyncListener implements TreeCacheListener {
         @Override
         public final void childEvent(final CuratorFramework client, final TreeCacheEvent event) {
             ChildData childData = event.getData();