This is an automated email from the ASF dual-hosted git repository.
DaanHoogland pushed a commit to branch 4.22
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.22 by this push:
new f49ab6b394d API rule regex optimization (#13109)
f49ab6b394d is described below
commit f49ab6b394d8685ef6555adac2afbf52e5cb963f
Author: Suresh Kumar Anaparti <[email protected]>
AuthorDate: Thu Jun 25 20:48:05 2026 +0530
API rule regex optimization (#13109)
Co-authored-by: Aaron Chung <[email protected]>
---
api/src/main/java/org/apache/cloudstack/acl/Rule.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/api/src/main/java/org/apache/cloudstack/acl/Rule.java
b/api/src/main/java/org/apache/cloudstack/acl/Rule.java
index a4ef7773f67..de64d855ccc 100644
--- a/api/src/main/java/org/apache/cloudstack/acl/Rule.java
+++ b/api/src/main/java/org/apache/cloudstack/acl/Rule.java
@@ -25,16 +25,18 @@ import org.apache.commons.lang3.StringUtils;
public final class Rule {
private final String rule;
+ private final Pattern compiledPattern;
private final static Pattern ALLOWED_PATTERN =
Pattern.compile("^[a-zA-Z0-9*]+$");
public Rule(final String rule) {
validate(rule);
this.rule = rule;
+ this.compiledPattern = Pattern.compile(rule.replace("*", "\\w*"),
Pattern.CASE_INSENSITIVE);
}
public boolean matches(final String commandName) {
return StringUtils.isNotEmpty(commandName)
- &&
commandName.toLowerCase().matches(rule.toLowerCase().replace("*", "\\w*"));
+ && compiledPattern.matcher(commandName).matches();
}
public String getRuleString() {