konrad-kaminski / spring-kotlin-coroutine

Kotlin coroutine support for Spring.
448 stars 69 forks source link

Bean post processing with null bean name #33

Open RLejolivet opened 5 years ago

RLejolivet commented 5 years ago

I am using spring-boot-starter-quartz for my scheduling-related needs, and adding spring-kotlin-coroutine to my projects make all Quartz Job creation fail with the following error:

org.quartz.SchedulerException: Job instantiation failed
    at org.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:47) ~[spring-context-support-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.quartz.core.JobRunShell.initialize(JobRunShell.java:127) ~[quartz-2.3.0.jar:na]
    at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:392) [quartz-2.3.0.jar:na]
Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method org.springframework.kotlin.experimental.coroutine.event.CoroutineApplicationEventPublisherAwareBeanPostProcessor.postProcessBeforeInitialization, parameter beanName
    at org.springframework.kotlin.experimental.coroutine.event.CoroutineApplicationEventPublisherAwareBeanPostProcessor.postProcessBeforeInitialization(CoroutineApplicationEventPublisherAwareBeanPostProcessor.kt) ~[spring-kotlin-coroutine-0.3.6.jar:na]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:416) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]

As Job beans are created by Spring+Quartz based on a classname, I do not have the option to name the beans.

Should CoroutineApplicationEventPublisherAwareBeanPostProcessor accept nullable parameters to fix this, or am I missing something?

konrad-kaminski commented 5 years ago

I see no reason why CoroutineApplicationEventPublisherAwareBeanPostProcessor wouldn't allow beanName to be null. I'll fix it in the next release.