This is an automated email from the ASF dual-hosted git repository.
Aias00 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 c5c865a2bb fix: precompute default modules in context decorators
(#6969)
c5c865a2bb is described below
commit c5c865a2bba264ce274a5414456b916f5ba909a3
Author: Limbo <[email protected]>
AuthorDate: Sat Sep 5 21:01:26 2026 +0800
fix: precompute default modules in context decorators (#6969)
Co-authored-by: aias00 <[email protected]>
---
.../shenyu/plugin/divide/context/DivideShenyuContextDecorator.java | 4 +++-
.../plugin/divide/context/DivideShenyuContextDecoratorTest.java | 2 ++
.../plugin/websocket/context/WebSocketShenyuContextDecorator.java | 4 +++-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-divide/src/main/java/org/apache/shenyu/plugin/divide/context/DivideShenyuContextDecorator.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-divide/src/main/java/org/apache/shenyu/plugin/divide/context/DivideShenyuContextDecorator.java
index 199548c508..727854aba0 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-divide/src/main/java/org/apache/shenyu/plugin/divide/context/DivideShenyuContextDecorator.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-divide/src/main/java/org/apache/shenyu/plugin/divide/context/DivideShenyuContextDecorator.java
@@ -30,6 +30,8 @@ import java.util.Optional;
*/
public class DivideShenyuContextDecorator implements ShenyuContextDecorator {
+ private static final String DEFAULT_MODULE = PluginEnum.DIVIDE.getName() +
"-" + RpcTypeEnum.HTTP.getName();
+
@Override
public ShenyuContext decorator(final ShenyuContext shenyuContext, final
MetaData metaData) {
String path = shenyuContext.getPath();
@@ -37,7 +39,7 @@ public class DivideShenyuContextDecorator implements
ShenyuContextDecorator {
shenyuContext.setRealUrl(path);
shenyuContext.setRpcType(RpcTypeEnum.HTTP.getName());
shenyuContext.setModule(Optional.ofNullable(metaData).map(MetaData::getAppName)
- .orElse(String.format("%s-%s", PluginEnum.DIVIDE.getName(),
shenyuContext.getRpcType())));
+ .orElse(DEFAULT_MODULE));
return shenyuContext;
}
}
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-divide/src/test/java/org/apache/shenyu/plugin/divide/context/DivideShenyuContextDecoratorTest.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-divide/src/test/java/org/apache/shenyu/plugin/divide/context/DivideShenyuContextDecoratorTest.java
index f609f52ae9..31dbf40361 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-divide/src/test/java/org/apache/shenyu/plugin/divide/context/DivideShenyuContextDecoratorTest.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-divide/src/test/java/org/apache/shenyu/plugin/divide/context/DivideShenyuContextDecoratorTest.java
@@ -19,6 +19,7 @@ package org.apache.shenyu.plugin.divide.context;
import org.apache.shenyu.common.dto.MetaData;
import org.apache.shenyu.plugin.api.context.ShenyuContext;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -54,5 +55,6 @@ public final class DivideShenyuContextDecoratorTest {
ShenyuContext decorator =
divideShenyuContextDecorator.decorator(shenyuContext, metaData);
assert MOCK_CONTEXT_PATH.equals(decorator.getMethod());
assert MOCK_CONTEXT_PATH.equals(decorator.getRealUrl());
+ Assertions.assertEquals("divide-http", decorator.getModule());
}
}
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-websocket/src/main/java/org/apache/shenyu/plugin/websocket/context/WebSocketShenyuContextDecorator.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-websocket/src/main/java/org/apache/shenyu/plugin/websocket/context/WebSocketShenyuContextDecorator.java
index 910f1c5e44..3ec64cab5b 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-websocket/src/main/java/org/apache/shenyu/plugin/websocket/context/WebSocketShenyuContextDecorator.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-websocket/src/main/java/org/apache/shenyu/plugin/websocket/context/WebSocketShenyuContextDecorator.java
@@ -29,6 +29,8 @@ import java.util.Optional;
* The type WebSocket shenyu context decorator.
*/
public class WebSocketShenyuContextDecorator implements ShenyuContextDecorator
{
+
+ private static final String DEFAULT_MODULE =
PluginEnum.WEB_SOCKET.getName() + "-" + RpcTypeEnum.WEB_SOCKET.getName();
@Override
public ShenyuContext decorator(final ShenyuContext shenyuContext, final
MetaData metaData) {
@@ -37,7 +39,7 @@ public class WebSocketShenyuContextDecorator implements
ShenyuContextDecorator {
shenyuContext.setRealUrl(path);
shenyuContext.setRpcType(RpcTypeEnum.WEB_SOCKET.getName());
shenyuContext.setModule(Optional.ofNullable(metaData).map(MetaData::getAppName)
- .orElse(String.format("%s-%s",
PluginEnum.WEB_SOCKET.getName(), shenyuContext.getRpcType())));
+ .orElse(DEFAULT_MODULE));
return shenyuContext;
}