- Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Closed
Copy link
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)theme: aotAn issue related to Ahead-of-time processingAn issue related to Ahead-of-time processingtype: bugA general bugA general bug
Milestone
Description
Now that #31495 has been resolved, loading the AOT-optimized ApplicationContext for Spr9799XmlConfigTests fails with the following cause.
java.lang.IllegalArgumentException: ValueHolder must not be null at org.springframework.util.Assert.notNull(Assert.java:172) ~[?:?] at org.springframework.beans.factory.config.ConstructorArgumentValues.addIndexedArgumentValue(ConstructorArgumentValues.java:111) ~[?:?] at org.springframework.web.servlet.handler.MappedInterceptor__TestContext001_BeanDefinitions.getMappedInterceptorBeanDefinition(MappedInterceptor__TestContext001_BeanDefinitions.java:27) ~[?:?] at org.springframework.test.context.junit4.spr9799.Spr9799XmlConfigTests__TestContext001_BeanFactoryRegistrations.registerBeanDefinitions(Spr9799XmlConfigTests__TestContext001_BeanFactoryRegistrations.java:57) ~[?:?] at org.springframework.test.context.junit4.spr9799.Spr9799XmlConfigTests__TestContext001_ApplicationContextInitializer.initialize(Spr9799XmlConfigTests__TestContext001_ApplicationContextInitializer.java:19) ~[?:?] at org.springframework.test.context.junit4.spr9799.Spr9799XmlConfigTests__TestContext001_ApplicationContextInitializer.initialize(Spr9799XmlConfigTests__TestContext001_ApplicationContextInitializer.java:13) ~[?:?] at org.springframework.test.context.support.AbstractGenericContextLoader.loadContextForAotRuntime(AbstractGenericContextLoader.java:170) ~[main/:?] at org.springframework.test.context.support.AbstractGenericContextLoader.loadContextForAotRuntime(AbstractGenericContextLoader.java:1) ~[main/:?] at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContextForAotRuntime(AbstractDelegatingSmartContextLoader.java:263) ~[main/:?] at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInAotMode(DefaultCacheAwareContextLoaderDelegate.java:255) ~[main/:?] at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:149) ~[main/:?] Generated Code:
package org.springframework.web.servlet.handler; import java.lang.String; import org.springframework.beans.factory.aot.BeanInstanceSupplier; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.web.servlet.HandlerInterceptor; /** * Bean definitions for {@link MappedInterceptor}. */ public class MappedInterceptor__TestContext001_BeanDefinitions { // other methods /** * Get the bean definition for 'mappedInterceptor#0'. */ public static BeanDefinition getMappedInterceptorBeanDefinition() { RootBeanDefinition beanDefinition = new RootBeanDefinition(MappedInterceptor.class); beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(0, null); beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(1, ConversionServiceExposingInterceptor__TestContext001_BeanDefinitions.getMappedInterceptorInnerBeanBeanDefinition()); beanDefinition.setInstanceSupplier(getMappedInterceptorInstanceSupplier()); return beanDefinition; } }This line is the source of the exception:
beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(0, null);Since addIndexedArgumentValue(...) is overloaded, the compiler picks the variant that accepts a ValueHolder when the second argument is null, and that variant has a notNull check for the ValueHolder.
Updating the code generator so that it generates the following seems to be one way to address this issue.
beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(0, (Object) null);Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)theme: aotAn issue related to Ahead-of-time processingAn issue related to Ahead-of-time processingtype: bugA general bugA general bug