-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Description
It seems that there is a memory leak with Spring Boot 2.4.1 on my Debian 10.5 with Java 11.0.1 when using @PreAuthorize("hasRole('ROLE')")
annotation on controller's endpoint. As you can see in the first image, there is constant grow in old generation memory of G1 garbage collector when running tests. The grow stops at max heap size which is 512 MB. I prepared a sample project where you can reproduce the problem.
After importing the project just run this command:
./gradlew clean test
Tests will fail because they assume that HTTP response will be 200, but it is 401, but it shouldn't matter.
If you remove @PreAuthorize
from DummyController or prePostEnabled = true
from SecurityConfig then memory usage seems to be ok.
The project uses dummy controller with one endpoint which has @PreAuthorize("hasRole('ROLE')")
annotation. It has also basic SecurityConfig
to enable @PreAuthorize
annotation. Controller uses some dummy services to make sure that for each test Spring will recreate the context. I also set spring.test.context.cache.maxSize=1
in build.gradle to make sure that the grow of memory does not come from cache.
If you have any more questions about my configuration or anything else, let me know.