Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Blocker
-
Resolution: Not A Bug
-
Affects Version/s: 1.2 final
-
Fix Version/s: 1.2.1
-
Component/s: None
-
Labels:None
-
Environment:XPSP2,JDK 1.6_17
Description
If you define a filter like this:
class StorefrontFilters {
def filters = {
handleSomething(controller: '*', action: '*') {
before = {
log.info "handleSomething executed"
}
}
handleSomething2(controller: '*', action: '*') {
before = {
log.info "handleSomething2 executed"
}
}
}
}
The each before-closure is executed 2 times on each request. If I define another filter
each before interceptor will be executed 3 times and so on.
This was working in grails 1.1.1
Output would be
handleSomething executed handleSomething2 executed handleSomething executed handleSomething2 executed
Attachments
-
$i18n.getText("admin.common.words.hide")
- filtertest.zip
- 06/Jan/10 12:15 PM
- 181 kB
- Jeff Brown
-
- filtertest/.classpath 0.7 kB
- filtertest/.project 0.5 kB
- filtertest/.../org.codehaus.groovy.eclipse.preferences.prefs 0.1 kB
- filtertest/application.properties 0.2 kB
- filtertest/grails-app/.../BootStrap.groovy 0.1 kB
- filtertest/grails-app/.../BuildConfig.groovy 1 kB
- filtertest/grails-app/conf/Config.groovy 3 kB
- filtertest/grails-app/.../DataSource.groovy 0.6 kB
- filtertest/grails-app/.../resources.groovy 0.0 kB
- filtertest/.../StoreFrontFilters.groovy 0.3 kB
- __MACOSX/.../._StoreFrontFilters.groovy 0.2 kB
- filtertest/grails-app/.../UrlMappings.groovy 0.2 kB
- filtertest/.../DemoController.groovy 0.1 kB
- filtertest/.../messages.properties 3 kB
- filtertest/.../messages_da.properties 3 kB
- filtertest/.../messages_de.properties 4 kB
- filtertest/.../messages_es.properties 3 kB
- filtertest/.../messages_fr.properties 2 kB
- filtertest/.../messages_it.properties 2 kB
- filtertest/.../messages_ja.properties 2 kB
- filtertest/.../messages_nl.properties 3 kB
- filtertest/.../messages_pt_BR.properties 3 kB
- filtertest/.../messages_pt_PT.properties 3 kB
- filtertest/.../messages_ru.properties 4 kB
- filtertest/.../messages_th.properties 5 kB
- filtertest/.../messages_zh_CN.properties 2 kB
- filtertest/grails-app/views/error.gsp 2 kB
- filtertest/grails-app/views/index.gsp 2 kB
- __MACOSX/filtertest/.../views/._index.gsp 0.2 kB
- filtertest/grails-app/.../layouts/main.gsp 0.7 kB
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
Malte,
Can you attach a demonstrative sample application or describe some details that might help us reproduce the problem?
Hi Jeff,
thank you for your demo app. Until now I can not reproduce this with your app. But the bug is still existing
in my grails application. I have to figure out why this is happening. My current app is really complex and I cannot attach it.
Currently I am trying to reproduce the behaviour in "filtertest". I will post a comment when I finished testing.
Ok, I finally found the source for this issue. The title of this bugrepot must be "Filters are not executed one time for each request but for every g:include of a controller action".
I had 2 g:include expressions in my view - each of them render output from a controller action. So the filter was executed for the controller itself and for each of the g:includes.
Is this a wanted behaviour? In grails 1.1 and up (until 1.2) the filters where not executed for each g:include.
I just noticed that this is also a problem in 1.1.1. (if it is a problem at all).
I think filters should be applicable when controller actions are invoked via the include tag. For some scenarios, that may be important.
You may need to configure your filter selection criteria to not select actions that you intend to invoke with the include tag if you don't want your filters applied there.
Thanks for the input.
There may be something in your application that is triggering the behavior (possibly a redirect?). I have attached a Grails 1.2 project which uses filters defined just like yours and this app appears to behave as designed, the filters are only executed once per request.
If you can attach a project that demonstrates the behavior you are seeing, that would be helpful.