FINERACT-2449: Replace unbounded SimpleAsyncTaskExecutor with ThreadPoolTaskExecutor#5432
Conversation
|
I think there is a need to address this... but (having best practices in mind): let's first have a look here https://docs.spring.io/spring-boot/reference/features/task-execution-and-scheduling.html ... there are already (auto) configuration properties available, so why invent our own and create more Java configuration when they are not really necessary. I only cross-read that documentation quickly, but I think everything that is done here can be achieved with adding the proper "spring" prefixed properties to application.properties (with environment variable placeholders, sure); I think no extra/custom Java configuration would be needed. |
|
Hi @vidakovic, thanks for the review. I investigated using 1. Synchronous by default
Unless 2. Security context propagation Because of this, a properties-only solution isn't sufficient. That said, I'm happy to Does that approach work for you? |
Description
This PR addresses FINERACT-2449.
Background
The current
SimpleAsyncTaskExecutorcreates a new thread for every task. While effective for light loads, this unbounded behavior poses a theoretical risk of thread exhaustion (OutOfMemoryError: unable to create native thread) under specific high-concurrency scenarios.Motivation
Relying on an unbounded executor is contrary to Spring Boot best practices for production-grade financial systems. This change proactively addresses the risk before it manifests in production.
Solution
SimpleAsyncTaskExecutorwithThreadPoolTaskExecutoreventTaskExecutorCorePoolSizeandeventTaskExecutorMaxPoolSizeTesting
SpringConfigTest.java (Added 8 unit tests proving bounded behavior)
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!