You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by xi...@apache.org on 2023/01/10 02:37:35 UTC

[shenyu] branch master updated: [type:feat] add trie test (#4305)

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/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 092084b46 [type:feat] add trie test (#4305)
092084b46 is described below

commit 092084b46583a0741eea821c44c4085d35ce00ab
Author: moremind <he...@hotmail.com>
AuthorDate: Tue Jan 10 10:37:29 2023 +0800

    [type:feat] add trie test (#4305)
    
    * [type:feat] add trie test
    
    * [type:feat] add trie test
---
 .../src/main/resources/application.yml             |   3 +-
 .../apache/shenyu/common/config/ShenyuConfig.java  |  34 +++-
 .../apache/shenyu/plugin/base/trie/ShenyuTrie.java |  31 ++--
 .../shenyu/plugin/base/trie/ShenyuTrieNode.java    |   8 +-
 .../plugin/base/AbstractShenyuPluginTest.java      |   2 +-
 .../base/cache/CommonPluginDataSubscriberTest.java |   2 +-
 .../shenyu/plugin/base/trie/ShenyuTrieTest.java    | 197 +++++++++++++++++++++
 .../starter/gateway/ShenyuConfiguration.java       |   4 +-
 .../web/controller/LocalPluginControllerTest.java  |   2 +-
 9 files changed, 252 insertions(+), 31 deletions(-)

diff --git a/shenyu-bootstrap/src/main/resources/application.yml b/shenyu-bootstrap/src/main/resources/application.yml
index 08dcbadbb..030c40151 100644
--- a/shenyu-bootstrap/src/main/resources/application.yml
+++ b/shenyu-bootstrap/src/main/resources/application.yml
@@ -67,7 +67,8 @@ management:
 
 shenyu:
   trie:
-    trieChildrenSize: 10000
+    childrenSize: 10000
+    pathVariableSize: 1000
     pathRuleCacheSize: 1000
     matchMode: antPathMatch
   matchCache:
diff --git a/shenyu-common/src/main/java/org/apache/shenyu/common/config/ShenyuConfig.java b/shenyu-common/src/main/java/org/apache/shenyu/common/config/ShenyuConfig.java
index 7d319ecae..f0d3631da 100644
--- a/shenyu-common/src/main/java/org/apache/shenyu/common/config/ShenyuConfig.java
+++ b/shenyu-common/src/main/java/org/apache/shenyu/common/config/ShenyuConfig.java
@@ -1693,9 +1693,11 @@ public class ShenyuConfig {
      * shenyu trie config.
      */
     public static class ShenyuTrieConfig {
-        private Long trieChildrenSize = 10000L;
+        private Long childrenSize = 10000L;
 
         private Long pathRuleCacheSize = 1000L;
+        
+        private Long pathVariableSize = 1000L;
 
         /**
          * match mode.
@@ -1708,17 +1710,17 @@ public class ShenyuConfig {
          *
          * @return trie children size
          */
-        public Long getTrieChildrenSize() {
-            return trieChildrenSize;
+        public Long getChildrenSize() {
+            return childrenSize;
         }
 
         /**
          * set trie children size.
          *
-         * @param trieChildrenSize trie children size
+         * @param childrenSize trie children size
          */
-        public void setTrieChildrenSize(final Long trieChildrenSize) {
-            this.trieChildrenSize = trieChildrenSize;
+        public void setChildrenSize(final Long childrenSize) {
+            this.childrenSize = childrenSize;
         }
 
         /**
@@ -1738,7 +1740,25 @@ public class ShenyuConfig {
         public void setPathRuleCacheSize(final Long pathRuleCacheSize) {
             this.pathRuleCacheSize = pathRuleCacheSize;
         }
-
+        
+        /**
+         * get path variable node size.
+         *
+         * @return path variable node size
+         */
+        public Long getPathVariableSize() {
+            return pathVariableSize;
+        }
+    
+        /**
+         * set path variable node size.
+         *
+         * @param pathVariableSize path variable node size
+         */
+        public void setPathVariableSize(final Long pathVariableSize) {
+            this.pathVariableSize = pathVariableSize;
+        }
+    
         /**
          * get match mode.
          *
diff --git a/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/trie/ShenyuTrie.java b/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/trie/ShenyuTrie.java
index 9ca3a3959..08f84055e 100644
--- a/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/trie/ShenyuTrie.java
+++ b/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/trie/ShenyuTrie.java
@@ -43,6 +43,8 @@ public class ShenyuTrie {
 
     private final Long pathRuleCacheSize;
     
+    private final Long pathVariableSize;
+    
     private final Object lock = new Object();
 
     /**
@@ -51,10 +53,11 @@ public class ShenyuTrie {
      */
     private final String matchMode;
 
-    public ShenyuTrie(final Long pathRuleCacheSize, final Long childrenSize, final String matchMode) {
-        this.root = new ShenyuTrieNode("/", "/", false, pathRuleCacheSize);
+    public ShenyuTrie(final Long childrenSize, final Long pathRuleCacheSize, final Long pathVariableSize, final String matchMode) {
+        this.root = new ShenyuTrieNode("/", "/", false, childrenSize, pathRuleCacheSize, pathVariableSize);
         this.childrenSize = childrenSize;
         this.pathRuleCacheSize = pathRuleCacheSize;
+        this.pathVariableSize = pathVariableSize;
         this.matchMode = matchMode;
     }
 
@@ -71,11 +74,12 @@ public class ShenyuTrie {
     /**
      * judge the trie is empty.
      *
-     * @param shenyuTrie trie
      * @return status
      */
-    public boolean isEmpty(final ShenyuTrie shenyuTrie) {
-        return shenyuTrie.root.getChildren().estimatedSize() == 0 && "/".equals(shenyuTrie.root.getMatchStr());
+    public boolean isEmpty() {
+        return this.root.getChildren().estimatedSize() == 0
+                && this.root.getPathVariablesSet().estimatedSize() == 0
+                && Objects.isNull(this.root.getPathVariableNode());
     }
 
     /**
@@ -161,7 +165,7 @@ public class ShenyuTrie {
                 childNode.setMatchStr(segment);
                 childNode.setEndOfPath(false);
                 if (Objects.isNull(shenyuTrieNode.getPathVariablesSet())) {
-                    shenyuTrieNode.setPathVariablesSet(Caffeine.newBuilder().maximumSize(childrenSize).build());
+                    shenyuTrieNode.setPathVariablesSet(Caffeine.newBuilder().maximumSize(pathVariableSize).build());
                 }
                 shenyuTrieNode.getPathVariablesSet().put(segment, childNode);
                 shenyuTrieNode.setPathVariableNode(childNode);
@@ -221,21 +225,18 @@ public class ShenyuTrie {
                         // include path variable node, general node, wildcard node
                         if (endPath && checkPathRuleNotNull(currentNode)
                                 && CollectionUtils.isNotEmpty(getVal(currentNode.getPathRuleCache(), selectorId))) {
-                            break;
+                            return currentNode;
                         }
                         // path is end and the match str is **, means match all
                         if (isMatchAll(currentNode.getMatchStr()) && currentNode.getEndOfPath()
                                 && checkPathRuleNotNull(currentNode)
                                 && CollectionUtils.isNotEmpty(getVal(currentNode.getPathRuleCache(), selectorId))) {
-                            break;
+                            return currentNode;
                         }
                     } else {
                         return null;
                     }
                 }
-                if (currentNode.getEndOfPath() || (Objects.nonNull(currentNode.getPathVariableNode()) && currentNode.getPathVariableNode().getEndOfPath())) {
-                    return currentNode;
-                }
             }
         }
         return null;
@@ -290,7 +291,8 @@ public class ShenyuTrie {
             if (Objects.nonNull(currentNode) && Objects.nonNull(currentNode.getPathRuleCache())) {
                 // check current mapping
                 currentNode.getPathRuleCache().cleanUp();
-                if (currentNode.getPathRuleCache().estimatedSize() == 1 && Objects.isNull(currentNode.getChildren())) {
+                List<RuleData> ruleDataList = getVal(currentNode.getPathRuleCache(), selectorId);
+                if (CollectionUtils.isNotEmpty(ruleDataList) && ruleDataList.size() == 1 && Objects.isNull(currentNode.getChildren())) {
                     // remove current node from parent node
                     String[] parentPathArray = Arrays.copyOfRange(pathParts, 0, pathParts.length - 1);
                     String parentPath = String.join("/", parentPathArray);
@@ -321,8 +323,7 @@ public class ShenyuTrie {
             String strippedPath = StringUtils.strip(uriPath, "/");
             String[] pathParts = StringUtils.split(strippedPath, "/");
             if (pathParts.length > 0) {
-                ShenyuTrieNode currentNode = root;
-                return getNode0(currentNode, pathParts);
+                return getNode0(root, pathParts);
             } else {
                 return null;
             }
@@ -350,7 +351,7 @@ public class ShenyuTrie {
                 }
                 return node.getPathVariableNode();
             } else if (isMatchAllOrWildcard(key)) {
-                return node;
+                return getVal(node.getChildren(), key);
             } else {
                 if (Objects.isNull(node) || !checkChildrenNotNull(node)) {
                     return null;
diff --git a/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/trie/ShenyuTrieNode.java b/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/trie/ShenyuTrieNode.java
index b88fb825e..fcec43d97 100644
--- a/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/trie/ShenyuTrieNode.java
+++ b/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/trie/ShenyuTrieNode.java
@@ -80,12 +80,14 @@ public class ShenyuTrieNode implements Serializable {
     public ShenyuTrieNode() {
     }
 
-    public ShenyuTrieNode(final String matchStr, final String fullPath, final boolean endOfPath, final Long size) {
+    public ShenyuTrieNode(final String matchStr, final String fullPath, final boolean endOfPath,
+                          final Long childrenSize, final Long pathRuleCacheSize, final Long pathVariableSize) {
         this.matchStr = matchStr;
         this.fullPath = fullPath;
         this.endOfPath = endOfPath;
-        this.pathRuleCache = Caffeine.newBuilder().maximumSize(size).build();
-        this.pathVariablesSet = Caffeine.newBuilder().maximumSize(size).build();
+        this.children = Caffeine.newBuilder().maximumSize(childrenSize).build();
+        this.pathRuleCache = Caffeine.newBuilder().maximumSize(pathRuleCacheSize).build();
+        this.pathVariablesSet = Caffeine.newBuilder().maximumSize(pathVariableSize).build();
     }
 
     /**
diff --git a/shenyu-plugin/shenyu-plugin-base/src/test/java/org/apache/shenyu/plugin/base/AbstractShenyuPluginTest.java b/shenyu-plugin/shenyu-plugin-base/src/test/java/org/apache/shenyu/plugin/base/AbstractShenyuPluginTest.java
index a23680cf6..b00e5729d 100644
--- a/shenyu-plugin/shenyu-plugin-base/src/test/java/org/apache/shenyu/plugin/base/AbstractShenyuPluginTest.java
+++ b/shenyu-plugin/shenyu-plugin-base/src/test/java/org/apache/shenyu/plugin/base/AbstractShenyuPluginTest.java
@@ -171,7 +171,7 @@ public final class AbstractShenyuPluginTest {
     private void mockShenyuConfig() {
         ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class);
         when(context.getBean(ShenyuConfig.class)).thenReturn(new ShenyuConfig());
-        when(context.getBean(ShenyuTrie.class)).thenReturn(new ShenyuTrie(100L, 100L, TrieMatchModeEvent.ANT_PATH_MATCH.getMatchMode()));
+        when(context.getBean(ShenyuTrie.class)).thenReturn(new ShenyuTrie(100L, 100L, 100L, TrieMatchModeEvent.ANT_PATH_MATCH.getMatchMode()));
         SpringBeanUtils.getInstance().setApplicationContext(context);
     }
 
diff --git a/shenyu-plugin/shenyu-plugin-base/src/test/java/org/apache/shenyu/plugin/base/cache/CommonPluginDataSubscriberTest.java b/shenyu-plugin/shenyu-plugin-base/src/test/java/org/apache/shenyu/plugin/base/cache/CommonPluginDataSubscriberTest.java
index b15599223..62b6163c0 100644
--- a/shenyu-plugin/shenyu-plugin-base/src/test/java/org/apache/shenyu/plugin/base/cache/CommonPluginDataSubscriberTest.java
+++ b/shenyu-plugin/shenyu-plugin-base/src/test/java/org/apache/shenyu/plugin/base/cache/CommonPluginDataSubscriberTest.java
@@ -233,7 +233,7 @@ public final class CommonPluginDataSubscriberTest {
 
     private void mockShenyuTrieConfig() {
         ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class);
-        when(context.getBean(ShenyuTrie.class)).thenReturn(new ShenyuTrie(100L, 100L, TrieMatchModeEvent.ANT_PATH_MATCH.getMatchMode()));
+        when(context.getBean(ShenyuTrie.class)).thenReturn(new ShenyuTrie(100L, 100L, 100L, TrieMatchModeEvent.ANT_PATH_MATCH.getMatchMode()));
         SpringBeanUtils.getInstance().setApplicationContext(context);
     }
 }
diff --git a/shenyu-plugin/shenyu-plugin-base/src/test/java/org/apache/shenyu/plugin/base/trie/ShenyuTrieTest.java b/shenyu-plugin/shenyu-plugin-base/src/test/java/org/apache/shenyu/plugin/base/trie/ShenyuTrieTest.java
new file mode 100644
index 000000000..7cf508b29
--- /dev/null
+++ b/shenyu-plugin/shenyu-plugin-base/src/test/java/org/apache/shenyu/plugin/base/trie/ShenyuTrieTest.java
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.plugin.base.trie;
+
+import org.apache.shenyu.common.dto.ConditionData;
+import org.apache.shenyu.common.dto.RuleData;
+import org.apache.shenyu.common.enums.OperatorEnum;
+import org.apache.shenyu.common.enums.ParamTypeEnum;
+import org.apache.shenyu.common.enums.TrieMatchModeEvent;
+import org.apache.shenyu.plugin.api.utils.SpringBeanUtils;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.springframework.context.ConfigurableApplicationContext;
+
+import java.util.Collections;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class ShenyuTrieTest {
+    
+    @Test
+    public void clear() {
+        this.mockAntPathShenyuTrie();
+        SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).clear();
+        Assertions.assertTrue(SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).isEmpty());
+    }
+    
+    @Test
+    public void isEmpty() {
+        this.mockAntPathShenyuTrie();
+        Assertions.assertTrue(SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).isEmpty());
+    }
+    
+    @Test
+    public void putNode() {
+        this.mockAntPathShenyuTrie();
+        ConditionData conditionData = new ConditionData();
+        conditionData.setParamType(ParamTypeEnum.URI.getName());
+        conditionData.setOperator(OperatorEnum.MATCH.getAlias());
+        conditionData.setParamName("/");
+        conditionData.setParamValue("/a/b/c/**");
+        RuleData ruleData = RuleData.builder()
+                .id("1")
+                .pluginName("test")
+                .selectorId("1")
+                .name("test-plugin-rule")
+                .enabled(true)
+                .conditionDataList(Collections.singletonList(conditionData))
+                .build();
+        SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).putNode("/a/b/c/**", ruleData, null);
+        Assertions.assertNotNull(SpringBeanUtils.getInstance().getBean(ShenyuTrie.class));
+    }
+    
+    @Test
+    public void match() {
+        this.mockAntPathShenyuTrie();
+        ConditionData conditionData = new ConditionData();
+        conditionData.setParamType(ParamTypeEnum.URI.getName());
+        conditionData.setOperator(OperatorEnum.MATCH.getAlias());
+        conditionData.setParamName("/");
+        conditionData.setParamValue("/a/b/c/**");
+        RuleData ruleData = RuleData.builder()
+                .id("1")
+                .pluginName("test")
+                .selectorId("1")
+                .name("test-plugin-rule")
+                .enabled(true)
+                .conditionDataList(Collections.singletonList(conditionData))
+                .build();
+        SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).putNode("/a/b/c/**", ruleData, null);
+        Assertions.assertNotNull(SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).match("/a/b/c/d/e/f", "1"));
+    
+        RuleData ruleData2 = RuleData.builder()
+                .id("2")
+                .pluginName("test2")
+                .selectorId("2")
+                .name("test-plugin-rule")
+                .enabled(true)
+                .conditionDataList(Collections.singletonList(conditionData))
+                .build();
+        SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).putNode("/a/*/b/c", ruleData2, null);
+        Assertions.assertNull(SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).match("/a/m/b/c", "1"));
+        Assertions.assertNotNull(SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).match("/a/m/b/c", "2"));
+        
+        SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).putNode("/path1/{name}/{age}", ruleData, null);
+        Assertions.assertNotNull(SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).match("/path1/111/222", "1"));
+        Assertions.assertNull(SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).match("/path1/111/222/333", "1"));
+        
+        SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).putNode("path1/name/age", ruleData, null);
+        Assertions.assertNotNull(SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).match("path1/name/age", "1"));
+        Assertions.assertEquals(SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).match("path1/name/age", "1").getFullPath(), "path1/name/age");
+    }
+    
+    @Test
+    public void remove() {
+        this.mockAntPathShenyuTrie();
+        ConditionData conditionData = new ConditionData();
+        conditionData.setParamType(ParamTypeEnum.URI.getName());
+        conditionData.setOperator(OperatorEnum.MATCH.getAlias());
+        conditionData.setParamName("/");
+        conditionData.setParamValue("/a/b/c/**");
+        RuleData ruleData = RuleData.builder()
+                .id("1")
+                .pluginName("test")
+                .selectorId("2")
+                .name("test-plugin-rule")
+                .enabled(true)
+                .sort(1)
+                .conditionDataList(Collections.singletonList(conditionData))
+                .build();
+        RuleData ruleData2 = RuleData.builder()
+                .id("2")
+                .pluginName("test")
+                .selectorId("2")
+                .name("test-plugin-rule2")
+                .enabled(true)
+                .sort(2)
+                .conditionDataList(Collections.singletonList(conditionData))
+                .build();
+        SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).putNode("/a/b/c/**", ruleData, null);
+        SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).putNode("/a/b/c/**", ruleData2, null);
+        SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).remove("/a/b/c/**", "2", "2");
+        Assertions.assertNotNull(SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).getNode("/a/b/c/**"));
+    
+        RuleData ruleData3 = RuleData.builder()
+                .id("3")
+                .pluginName("test")
+                .selectorId("3")
+                .name("test-plugin-rule3")
+                .enabled(true)
+                .sort(2)
+                .conditionDataList(Collections.singletonList(conditionData))
+                .build();
+        SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).putNode("/path1/path2", ruleData3, null);
+        SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).remove("/path1/path2", "3", "3");
+        Assertions.assertNull(SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).getNode("/path1/path2"));
+    }
+    
+    @Test
+    public void getNode() {
+        this.mockAntPathShenyuTrie();
+        ConditionData conditionData = new ConditionData();
+        conditionData.setParamType(ParamTypeEnum.URI.getName());
+        conditionData.setOperator(OperatorEnum.MATCH.getAlias());
+        conditionData.setParamName("/");
+        conditionData.setParamValue("/a/b/c/**");
+        RuleData ruleData = RuleData.builder()
+                .id("1")
+                .pluginName("test")
+                .selectorId("2")
+                .name("test-plugin-rule")
+                .enabled(true)
+                .sort(1)
+                .conditionDataList(Collections.singletonList(conditionData))
+                .build();
+        RuleData ruleData2 = RuleData.builder()
+                .id("2")
+                .pluginName("test2")
+                .selectorId("2")
+                .name("test-plugin-rule2")
+                .enabled(true)
+                .sort(2)
+                .conditionDataList(Collections.singletonList(conditionData))
+                .build();
+        SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).putNode("/a/b/c/**", ruleData, null);
+        SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).putNode("/a/b/c/**", ruleData2, null);
+        Assertions.assertNotNull(SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).getNode("/a/b/c/**"));
+        SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).putNode("/path1/{age}/{name}", ruleData2, null);
+        Assertions.assertNotNull(SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).getNode("/path1/{age}/{name}"));
+        SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).putNode("/aaa/bbb/ccc", ruleData2, null);
+        Assertions.assertNotNull(SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).getNode("/aaa/bbb/ccc"));
+        SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).putNode("/aa/*/cc", ruleData2, null);
+        Assertions.assertNotNull(SpringBeanUtils.getInstance().getBean(ShenyuTrie.class).getNode("/aa/*/cc"));
+    }
+    
+    private void mockAntPathShenyuTrie() {
+        ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class);
+        when(context.getBean(ShenyuTrie.class)).thenReturn(new ShenyuTrie(100L, 100L, 100L, TrieMatchModeEvent.ANT_PATH_MATCH.getMatchMode()));
+        SpringBeanUtils.getInstance().setApplicationContext(context);
+    }
+}
diff --git a/shenyu-spring-boot-starter/shenyu-spring-boot-starter-gateway/src/main/java/org/apache/shenyu/springboot/starter/gateway/ShenyuConfiguration.java b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-gateway/src/main/java/org/apache/shenyu/springboot/starter/gateway/ShenyuConfiguration.java
index 2cf34b8c2..a5fb0fa25 100644
--- a/shenyu-spring-boot-starter/shenyu-spring-boot-starter-gateway/src/main/java/org/apache/shenyu/springboot/starter/gateway/ShenyuConfiguration.java
+++ b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-gateway/src/main/java/org/apache/shenyu/springboot/starter/gateway/ShenyuConfiguration.java
@@ -267,8 +267,8 @@ public class ShenyuConfiguration {
      */
     @Bean
     public ShenyuTrie shenyuTrie(final ShenyuConfig shenyuConfig) {
-        return new ShenyuTrie(shenyuConfig.getTrie().getPathRuleCacheSize(), shenyuConfig.getTrie().getTrieChildrenSize(),
-                shenyuConfig.getTrie().getMatchMode());
+        return new ShenyuTrie(shenyuConfig.getTrie().getChildrenSize(), shenyuConfig.getTrie().getPathRuleCacheSize(),
+                shenyuConfig.getTrie().getPathVariableSize(), shenyuConfig.getTrie().getMatchMode());
     }
 
     /**
diff --git a/shenyu-web/src/test/java/org/apache/shenyu/web/controller/LocalPluginControllerTest.java b/shenyu-web/src/test/java/org/apache/shenyu/web/controller/LocalPluginControllerTest.java
index 29d79f1a6..c684371e4 100644
--- a/shenyu-web/src/test/java/org/apache/shenyu/web/controller/LocalPluginControllerTest.java
+++ b/shenyu-web/src/test/java/org/apache/shenyu/web/controller/LocalPluginControllerTest.java
@@ -490,7 +490,7 @@ public final class LocalPluginControllerTest {
 
     private void mockShenyuTrieConfig() {
         ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class);
-        when(context.getBean(ShenyuTrie.class)).thenReturn(new ShenyuTrie(100L, 100L, TrieMatchModeEvent.ANT_PATH_MATCH.getMatchMode()));
+        when(context.getBean(ShenyuTrie.class)).thenReturn(new ShenyuTrie(100L, 100L, 100L, TrieMatchModeEvent.ANT_PATH_MATCH.getMatchMode()));
         SpringBeanUtils.getInstance().setApplicationContext(context);
     }
 }