Skip to content

CGLIB code generation failure for cross-@Bean FactoryBean call [SPR-13095] #17686

@spring-projects-issues

Description

@spring-projects-issues

Gabriele Del Prete opened SPR-13095 and commented

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.concurrent.ExecutorService]: Factory method 'casCheckExecutor' threw exception; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.IllegalArgumentException-->Protected method: getDefaultThreadNamePrefix()Ljava/lang/String;
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
	... 67 more
Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.IllegalArgumentException-->Protected method: getDefaultThreadNamePrefix()Ljava/lang/String;
	at org.springframework.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:235)
	at org.springframework.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:220)
	at org.springframework.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:216)
	at org.springframework.cglib.proxy.Enhancer.createUsingReflection(Enhancer.java:643)
	at org.springframework.cglib.proxy.Enhancer.firstInstance(Enhancer.java:538)
	at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:225)
	at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
	at org.springframework.cglib.proxy.Enhancer.create(Enhancer.java:285)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.enhanceFactoryBean(ConfigurationClassEnhancer.java:402)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:295)
	at com.marketnews.scrollers.security.SecurityConfig$$EnhancerBySpringCGLIB$$4d2a9eb1.casCheckExecutorFactoryBean(<generated>)
	at com.marketnews.dbsso.spring.AbstractCASWebSecurityConfigurerAdapter.casCheckExecutor(AbstractCASWebSecurityConfigurerAdapter.java:318)
	at com.marketnews.scrollers.security.SecurityConfig$$EnhancerBySpringCGLIB$$4d2a9eb1.CGLIB$casCheckExecutor$17(<generated>)
	at com.marketnews.scrollers.security.SecurityConfig$$EnhancerBySpringCGLIB$$4d2a9eb1$$FastClassBySpringCGLIB$$433a316a.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:312)
	at com.marketnews.scrollers.security.SecurityConfig$$EnhancerBySpringCGLIB$$4d2a9eb1.casCheckExecutor(<generated>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
	... 68 more
Caused by: java.lang.IllegalArgumentException: Protected method: getDefaultThreadNamePrefix()Ljava/lang/String;
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:209)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor$1.intercept(ConfigurationClassEnhancer.java:399)
	at org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean$$EnhancerBySpringCGLIB$$93e65b95.getDefaultThreadNamePrefix(<generated>)
	at org.springframework.util.CustomizableThreadCreator.<init>(CustomizableThreadCreator.java:51)
	at org.springframework.scheduling.concurrent.CustomizableThreadFactory.<init>(CustomizableThreadFactory.java:42)
	at org.springframework.scheduling.concurrent.ExecutorConfigurationSupport.<init>(ExecutorConfigurationSupport.java:45)
	at org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean.<init>(ThreadPoolExecutorFactoryBean.java:53)
	at org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean$$EnhancerBySpringCGLIB$$93e65b95.<init>(<generated>)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at org.springframework.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:228)
	... 89 more

Related code is this:

	@Bean
	public ThreadPoolExecutorFactoryBean casCheckExecutorFactoryBean() throws Exception {
		ThreadPoolExecutorFactoryBean threadPoolExecutorFactoryBean = new ThreadPoolExecutorFactoryBean();
		threadPoolExecutorFactoryBean.setCorePoolSize(Runtime.getRuntime().availableProcessors() * 2);
		threadPoolExecutorFactoryBean.setQueueCapacity(Integer.MAX_VALUE);
		threadPoolExecutorFactoryBean.setThreadNamePrefix("casCheckExecutor-");
		return threadPoolExecutorFactoryBean;
	}

	@Bean(name="casCheckExecutor")
	public ExecutorService casCheckExecutor() throws Exception {
		return casCheckExecutorFactoryBean().getObject();
	}

Affects: 4.2 RC1

Issue Links:

Referenced from: commits 869b0bc, 063a720

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions