-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Description
Hi There,
I have encountered an issue with Integration Tests with Spring Boot.
For some background my application is using Bouncy Castle FIPS libraries for Certificate operations and to ensure they are initialised before the application starts, we have a static block in the Application class (ie. the class annotated with SpringBootApplication) which programmatically sets some of the security properties. We have some Integration Tests to test the functionality. All was working fine with Spring Boot Version 3.4.3.
Since uplifting to Spring Boot 3.5.0 the ITs stopped working. After some debugging it seemed that the Static Block was now executing midway through the Application Startup, specifically in our case part way through configuring the protocolHandlers, which caused issues with loading the TLS certificates.
I have a workaround because I can initialise these properties in another class which I have as an IT Initialiser which I know executes first, but the change in behaviour was strange to me. I assume this means for ITs the Main Application class is no longer the first thing to initialise.
Note - the Actual Application works fine once built - the static block is the very first thing executed in those cases.
Versions:
Spring Boot: 3.5.0
Java: Amazon Corretto 17.0.16
Unfortunately I do not have a code sample to replicate but it should be simple enough to reproduce by simply adding a static block with a Logger to the main class along with a simple Integration Test and verifying when it executes, Although if the application is small enough it may be harder to see.
Apologies if there are any problems with this issue as I am new to GitHub (in fact I created this account specifically to report this as I can imagine it could cause hard to diagnose issues, like the one I encountered!). This also may be to do with the underlying Spring Framework version but I had no way to fully confirm which is why I have raised here