Copilot commented on code in PR #7073:
URL: https://github.com/apache/shenyu/pull/7073#discussion_r4032853479


##########
shenyu-plugin/shenyu-plugin-security/shenyu-plugin-sign/src/main/java/org/apache/shenyu/plugin/sign/service/ComposableSignService.java:
##########
@@ -231,8 +231,19 @@ private void handleExchange(final ServerWebExchange 
exchange,
     }
 
     private boolean skipSignExchange(final ShenyuContext context) {
-        return StringUtils.equals(String.format("%s-%s", 
PluginEnum.SPRING_CLOUD.getName(), context.getRpcType()), context.getModule())
-                || StringUtils.equals(String.format("%s-%s", 
PluginEnum.DIVIDE.getName(), context.getRpcType()), context.getModule())
-                || StringUtils.equals(String.format("%s-%s", 
PluginEnum.WEB_SOCKET.getName(), context.getRpcType()), context.getModule());
+        return matchesDefaultModule(context.getModule(), context.getRpcType(), 
PluginEnum.SPRING_CLOUD.getName())
+                || matchesDefaultModule(context.getModule(), 
context.getRpcType(), PluginEnum.DIVIDE.getName())
+                || matchesDefaultModule(context.getModule(), 
context.getRpcType(), PluginEnum.WEB_SOCKET.getName());
+    }
+
+    static boolean matchesDefaultModule(final String module, final String 
rpcType, final String pluginName) {
+        if (StringUtils.isEmpty(module) || StringUtils.isEmpty(rpcType)) {
+            return false;
+        }
+        int separatorIndex = pluginName.length();
+        return module.length() == separatorIndex + rpcType.length() + 1
+                && module.startsWith(pluginName)
+                && module.charAt(separatorIndex) == '-'
+                && module.regionMatches(separatorIndex + 1, rpcType, 0, 
rpcType.length());

Review Comment:
   This changes the prior matching semantics for empty or null `rpcType` 
values: `String.format` produced `"plugin-"` and `"plugin-null"`, respectively, 
while this guard now rejects both. Since the PR explicitly promises to preserve 
matching semantics and `ShenyuContext` does not enforce a nonempty RPC type, 
normalize only null to the literal `"null"` and let the same length/content 
checks handle empty values.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to