Why do I see this error "org.springframework.core.task.TaskRejectedException" when using Spring Framework 5.3.2?

22 Views Asked by At

I recently upgraded my spring framework core library version. Old version : 5.2.8.RELEASE New version : 5.3.2

As long as I was on 5.2.8 release, the code works fine. If I switch to 5.3.2, I am getting "org.springframework.core.task.TaskRejectedException" exception. There are no other code changes or upstream changes. I researched differences in these library versions and found nothing related to the executor framework. I need some insight into what could be wrong.

    @Bean
    fun asyncExecutor(): Executor {
        val executor = ThreadPoolTaskExecutor()
        executor.setCorePoolSize(5)
        executor.setMaxPoolSize(10)
         executor.setQueueCapacity(50)
        executor.setThreadNamePrefix("MyThread-")
        executor.initialize()
        return executor
    }

Something which i noticed (not sure if it makes any difference), I see in the logs while the code is executed is, with 5.2.8 release I see the following text in the logs

"INFO SimpleAsyncTaskExecutor-1 -  - Hello World"

If I use 5.3.2 release, I see the following text in the logs

"INFO MyThread-1 - - Hello World"
0

There are 0 best solutions below