-
-
Notifications
You must be signed in to change notification settings - Fork 970
Description
Task List
- Steps to reproduce provided
- Stacktrace (if present) provided
- Example that reproduces the problem uploaded to Github
- Full description of the issue provided (see below)
Steps to Reproduce
- Download TestGrails3App-bug-report-08022019.zip
run-app- set debug Breakpoint at
de.testapp.servletfilter.MyServletFilter#doFilterline 16 - call http://localhost:8080/foo
Expected Behaviour
I have defined a ServletFilter (javax.servlet.Filter) which is defined in resources.groovy. In the doFilter() method I use the groovy DSL to set an attribute to the request object (HttpServletRequest):
httpReq.filter3 = "filter3-value"
This doesn't cause any problems. Then I use the request object to create a de.testapp.servletfilter.MyServletFilter.CleanServletRequest object which extends the HttpServletRequestWrapper. This class does nothing but extending its super class. After that I want to set another attribute to the request but this time I use the cleanRequest object since this will be the one I'm going to feed the filter chain with for further processing:
cleanRequest.setAttribute("filter1", "filter1-value")
No problems when using the setter setAttribute(). When I want to do this using groovy DSL though an groovy.lang.MissingPropertyException gets thrown:
cleanRequest.filter2 = "filter2-value" // throws exception!
Please note: This used to work in Grails 2.5.6.
I use this servlet filter to create a derived HttpServletRequestWrapper just like in my example. By overriding the getParameter() method I can process the parameters before handing them to the application layer.
Actual Behaviour
2019-02-08 14:31:23.432 ERROR --- [nio-8080-exec-9] .a.c.c.C.[.[.[.[grailsDispatcherServlet] : Servlet.service() for servlet [grailsDispatcherServlet] in context with path [] threw exception
groovy.lang.MissingPropertyException: No such property: filter2 for class: de.testapp.servletfilter.MyServletFilter
at groovy.lang.MetaClassImpl.invokeStaticMissingProperty(MetaClassImpl.java:1014)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2749)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3785)
at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:215)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:497)
at de.testapp.servletfilter.MyServletFilter$CleanServletRequest.propertyMissing(MyServletFilter.groovy)
at sun.reflect.GeneratedMethodAccessor255.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1427)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaClassImpl.invokeMissingProperty(MetaClassImpl.java:894)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2751)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3785)
at de.testapp.servletfilter.MyServletFilter$CleanServletRequest.setProperty(MyServletFilter.groovy)
at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:213)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:497)
at de.testapp.servletfilter.MyServletFilter.doFilter(MyServletFilter.groovy:20)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:111)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:77)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
Environment Information
- Operating System: any, in my case Windows 10 1809
- Grails Version: 3.3.9
- JDK Version:
jdk8u202-b08-adoptopenjdk