Fix Quota rest rate limiter support
This fixes an issue where the url has a canonical url (eg /r/).
The fix is to change getRequestURI to getServletPath.
The difference between both those functions is the fact that
getRequestURI returns /r/ and getServletPath does not.
Bug: Issue 10644
Change-Id: I8f305d3c2797eeea31cb86df1ac0eb1d4dfaddba
diff --git a/src/main/java/com/googlesource/gerrit/plugins/quota/RestApiRateLimiter.java b/src/main/java/com/googlesource/gerrit/plugins/quota/RestApiRateLimiter.java
index ca59d8d..1a7fa98 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/quota/RestApiRateLimiter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/quota/RestApiRateLimiter.java
@@ -47,7 +47,7 @@
private final LoadingCache<Account.Id, Holder> limitsPerAccount;
private final LoadingCache<String, Holder> limitsPerRemoteHost;
- private final Pattern resturi =
+ private final Pattern servletPath =
Pattern.compile(
"^/(?:a/)?"
+ "(access|accounts|changes|config|groups|plugins|projects|Documentation|tools)/(.*)$");
@@ -110,6 +110,6 @@
boolean isRest(ServletRequest req) {
return req instanceof HttpServletRequest
- && resturi.matcher(((HttpServletRequest) req).getRequestURI()).matches();
+ && servletPath.matcher(((HttpServletRequest) req).getServletPath()).matches();
}
}