When running a Spring Boot 3.2.0 project in intellij (with Settings > Build, Execution, Deployment > Build tools > Gradle : Build and run with Intellij IDEA) it cannot read method signature from JoinPoint
issue only happens in spring boot 3.2.0 (3.1.5 works fine) also using 3.2.0 and "Build and run with Gradle" settings works fine
java.lang.NullPointerException: Cannot read the array length because "parameterNames" is null
at com.example.demo.aop.MyAspect.checkEventIp(MyAspect.java:21) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:637) ~[spring-aop-6.1.1.jar:6.1.1]
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:627) ~[spring-aop-6.1.1.jar:6.1.1]
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:71) ~[spring-aop-6.1.1.jar:6.1.1]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:173) ~[spring-aop-6.1.1.jar:6.1.1]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:765) ~[spring-aop-6.1.1.jar:6.1.1]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) ~[spring-aop-6.1.1.jar:6.1.1]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184) ~[spring-aop-6.1.1.jar:6.1.1]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:765) ~[spring-aop-6.1.1.jar:6.1.1]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:717) ~[spring-aop-6.1.1.jar:6.1.1]
at com.example.demo.TestService$$SpringCGLIB$$0.hello(<generated>) ~[classes/:na]
Comment From: bclozel
I think this is due to https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.2-Release-Notes#parameter-name-discovery
You should have gotten WARN logs with Spring Boot 3.1.x about this. Please compile your code with the -parameters compiler option. See also https://github.com/spring-projects/spring-framework/issues/31675
Comment From: benestr
Does anyone know why does might only happen in some rare cases?
We had getParameterNames return null once after an app restart in production, and only for one of several methods where we call getParameterNames.
While this does fit the description of a missing -parameters option, I wonder why it does not happen every time and we can not reproduce it.
Comment From: gykk16
when using intellij with Build and run with Intellij IDEA option i had to delete the out folder generated by intellij