Currently, our backend project (Web Flux+Kotlin Coroutines/R2dbc/PostgreSQL) worked well when upgraded to Spring Boot 4 with Java 21/Kotlin 2.3, when recently we were trying to upgrade Java to 25, about 100 test cases are failed with the famous Out Of Memory error.
Added -XX:+HeapDumpOnOutOfMemoryError to the JVM parameters in the Gradle properties, and got a lot of similar error like this.
...XXXRepositoryTest
✘ testRepositoryExisted()
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException:
Failed to read candidate component class:
file [.../build/classes/kotlin/test/.../rest/external/XXXXnControllerV2Test$a test name$1$4.class]
Caused by: java.lang.OutOfMemoryError: Java heap space
The test itself for testing repository, but the root cause of OOM is reading candidate component from a controller/rest API test.
Also tried to add -XX:HeapDumpPath=./heapdump.hprof to the JVM option, but it did not generate such a file on local machine or GitHub actions.
The Spring Boot 3.x to 4.0 upgrade only includes a new bean metadata reader implementation via Class-File API in Spring 7 that is related to the new Java 25.
I am really confused here about the logging info, and can not determine the real root cause of these OOM errors.