Reputation: 38
My application is running in Grails 3.2.10 using Java 1.8.0_72.
I have an interceptor where I am specifying uri exclude patterns on the interceptor's matchAll:
matchAll().excludes(uri:'/myController/test')
However, to make this work without using wildcards (this interceptor is in a plugin so we'd like to keep the uri exclusion patterns fairly specific), I also had to add an additional exclude pattern with the same uri but with the app name included:
.excludes(uri:'/myApp/myController/test')
In looking at the Grails code, I see that the grails.artefact.Interceptor.groovy:doesMatch(request) method is called to calculate the match. The following is a code snippet from the doesMatch method:
for(Matcher matcher in allMatchers) {
if(matcher.doesMatch(uri, grailsMappingInfo, req.method) ||
(checkNoCtxUri && matcher.doesMatch(noCtxUri, grailsMappingInfo, req.method))) {
return true // true results in my interceptor executing
}
}
return false // false results in skipping my interceptor
doesMatch in turn calls UrlMappingMatcher:isExcluded where it loops over 'uriExcludePatterns'. And, since doesMatch is called with both the 'uri' and 'noCtxUri', this appears to be why I have to specify both uris in my excludes patterns.
I'm sure there's a good reason why doesMatch is called on both the 'uri' and 'noCtxUri'. If anyone has an explanation, I'm curious to know why.
Upvotes: 1
Views: 1210
Reputation: 3037
This was a bug and fixed in Grails 3.3.3 if you haven't updated the version yet. You can refer this https://github.com/grails/grails-core/pull/10912
Upvotes: 1