Skip to content

Commit 320bfa3

Browse files
interceptor methods should be private
This should fix the failing JDK8 joint build test. The issue is that since these methods were public they were being configured as controller actions. This happened to work ok with JDK7 and not work with JDK8 because of a difference in the ordering of AST transformation classes at compile time. When a controller is compiled with JDK7, the getRequest method that we add to that controller looks like this... public HttpServletRequest getRequest() { return this.instanceControllerTagLibraryApi.getRequest(this); } When that same controller is compiled with JDK8 that method looks like this... public HttpServletRequest getRequest() { return this.instanceControllersRestApi.getRequest(this); } instanceControllerTagLibraryApi is initialized in the constructor. instanceControllersRestApi is not, at least not directly. I think it relies on injection from the app context and that bean doesn't exist when that particular failing test is run. Since these methods were being configured as controller action methods code was being added to them to access the request in order to do allowedMethods checking. Because instanceControllersRestApi is used when the controller is compiled with JDK8 and that property is null for this particular test, the test was failing.
1 parent cab2242 commit 320bfa3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

grails-test-suite-uber/src/test/groovy/org/codehaus/groovy/grails/commons/DefaultGrailsControllerClass2Tests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public void testInterceptors() throws Exception {
143143
GroovyClassLoader cl = new GrailsAwareClassLoader();
144144
Class<?> clazz = cl.parseClass("@grails.artefact.Artefact(\"Controller\") class TestController { \n" +
145145
"def beforeInterceptor = [action:this.&before,only:'list']\n" +
146-
"def before() { return 'success' }\n" +
146+
"private before() { return 'success' }\n" +
147147
"def list = { return 'test' }\n " +
148148
"} ");
149149
GrailsControllerClass grailsClass = new DefaultGrailsControllerClass(clazz);
@@ -159,7 +159,7 @@ public void testInterceptors() throws Exception {
159159

160160
clazz = cl.parseClass("@grails.artefact.Artefact(\"Controller\") class AfterController { \n" +
161161
"def afterInterceptor = [action:this.&before,except:'list']\n" +
162-
"def after() { return 'success' }\n" +
162+
"private after() { return 'success' }\n" +
163163
"def list = { return 'test' }\n " +
164164
"def save = { return 'test' }\n " +
165165
"} ");
@@ -175,7 +175,7 @@ public void testBeforeInterceptorWithNoExcept() {
175175
GroovyClassLoader cl = new GrailsAwareClassLoader();
176176
Class<?> clazz = cl.parseClass("@grails.artefact.Artefact(\"Controller\") class TestController { \n" +
177177
"def beforeInterceptor = [action:this.&before]\n" +
178-
"def before() { return 'success' }\n" +
178+
"private before() { return 'success' }\n" +
179179
"def list = { return 'test' }\n " +
180180
"def show = { return 'test' }\n " +
181181
"} ");

0 commit comments

Comments
 (0)