This document outlines the changes made during the upgrade to Spring Boot v4.0.0-M3, focusing on the resolution of tracing integration test failures and code refactoring improvements.
- Spring Boot version: Upgraded from
3.5.6to4.0.0-M3 - SpringDoc OpenAPI: Updated from
2.8.13to3.0.0-M1for Spring Boot v4 compatibility - Repository configuration: Added Spring milestone repository for Boot 4 milestones
- Updated Gradle build script formatting and indentation
- Added Spring milestone repository:
maven { url = "https://repo.spring.io/milestone" } - Updated CycloneDX configuration to exclude additional test configurations
- Enhanced JAR creation with better CHANGELOG.md handling
- Jackson Databind: Removed explicit version (
2.20.0) to use Spring Boot managed version - Micrometer Tracing BOM: Removed platform BOM dependency
- Spring Boot Starter AOP: Replaced with
spring-boot-starter-aspectj - Spring Boot Starter JSON: Removed (now included by default)
- SpringDoc OpenAPI:
2.8.13→3.0.0-M1 - Log4J dependencies: Removed explicit versions to use Spring Boot managed versions
- Spring Boot Test: Updated to use Spring Boot managed version without explicit versioning
- Micrometer Tracing Test: Added
io.micrometer:micrometer-tracing-testfor integration tests - Lombok integration test support: Added
apiTestCompileOnlyandapiTestAnnotationProcessor
BaseIntegrationTest: Created base class for integration tests with proper configurationIntegrationTestConfiguration: Excludes OpenTelemetry tracing auto-configurationTracingIntegrationTestConfiguration: Provides SimpleTracer and ObservationRegistry for tracing tests
CourtScheduleControllerIntegrationTest: Now extendsBaseIntegrationTestHealthCheckIntegrationTest: Now extendsBaseIntegrationTestJWTFilterDisabledIntegrationTest: Now extendsBaseIntegrationTestJWTFilterIntegrationTest: Now extendsBaseIntegrationTestSpringLoggingIntegrationTest: Moved fromsrc/testtosrc/integrationTestand extendsBaseIntegrationTest
The original TracingIntegrationTest was failing due to configuration conflicts between the OpenTelemetry tracing auto-configuration and the test requirements.
- The
IntegrationTestConfigurationwas excluding OpenTelemetry tracing auto-configuration - Tests expected
traceIdandspanIdto be present in JSON log output - Tracing wasn't properly configured to populate the MDC (Mapped Diagnostic Context)
- Original test was located in
src/testinstead ofsrc/integrationTest
- Completely rewrote the test from scratch with proper Spring Boot v4 compatibility
- Created separate test configuration (
TracingIntegrationTestConfiguration) specifically for tracing tests - Manually populated MDC with trace information in test setup, similar to how
TracingFilterworks - Updated test logic to handle multiple log lines and find specific log messages from
RootController - Applied comprehensive refactoring to eliminate code duplication
- Moved test to proper location (
src/integrationTest)
src/integrationTest/java/uk/gov/hmcts/cp/testconfig/TracingIntegrationTestConfiguration.java(new)src/integrationTest/java/uk/gov/hmcts/cp/logging/TracingIntegrationTest.java(rewritten)src/integrationTest/java/uk/gov/hmcts/cp/controllers/HealthCheckIntegrationTest.javasrc/integrationTest/java/uk/gov/hmcts/cp/controllers/CourtScheduleControllerIntegrationTest.java
- Moved from
src/testtosrc/integrationTest: Proper test location for integration tests - Updated to extend
BaseIntegrationTest: Consistent configuration with other integration tests - Updated imports: Reorganized imports for better readability
- Fixed timestamp field assertion: Changed from
timestampto@timestampto match actual log output - Added debug output: Added console output for troubleshooting log format
// Before:
@SpringBootTest
public class SpringLoggingIntegrationTest {
// After:
public class SpringLoggingIntegrationTest extends BaseIntegrationTest {- All integration tests pass:
./gradlew integration
- When adding new tracing tests, use the
TracingIntegrationTestConfiguration - For other integration tests, extend
BaseIntegrationTestto ensure proper configuration
- OpenTelemetry auto-configuration is excluded for integration tests
- Tracing tests use
SimpleTracerfor consistent behavior - MDC is manually populated in tests to simulate real-world tracing behavior
- Spring Boot upgraded to v4.0.0-M3
- All related Spring dependencies updated accordingly
- Micrometer tracing dependencies maintained for compatibility