There is an observed testing issue when updating to Spring Boot 3.2.4 also present in 3.3.0 milestones.

Project and tests have been running for years.

Tests still pass individually so potentially contamination/stale cache in the test context?

Looking at release notes maybe this is related?

https://github.com/spring-projects/spring-data-commons/issues/2974

java.lang.IllegalStateException: Failed to load ApplicationContext for [MergedContextConfiguration@30653ef3 testClass = org.redacted.RepositoryIntegrationTest, locations = [], classes = [org.redacted.Application], contextInitializerClasses = [], activeProfiles = [], propertySourceDescriptors = [], propertySourceProperties = ["spring.profiles.include=NO_CACHE", "org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper=true"], contextCustomizers = [org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory$DisableAutoConfigurationContextCustomizer@5e8df0ac, org.springframework.boot.test.autoconfigure.actuate.observability.ObservabilityContextCustomizerFactory$DisableObservabilityContextCustomizer@1f, org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer@34be3d80, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@4af2beb5, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizer@399a5a52, [ImportsContextCustomizer@6c7ff05e key = [org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration, org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManagerAutoConfiguration, org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration, org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration, org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration, org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.JdbcClientAutoConfiguration, org.redacted.junit5.cfg.H2DatabaseConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.redacted.junit5.cfg.TestDataServiceHelperConfiguration, org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration, org.redacted.junit5.cfg.DataServiceRepositoryAuditTestConfiguration]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@3eadfbbb, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@67eabe02, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.context.SpringBootTestAnnotation@84319d6b], contextLoader = org.springframework.boot.test.context.SpringBootContextLoader, parent = null]
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:180)
    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:130)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:142)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:98)
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:260)
    at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:163)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
    at java.base/java.util.Optional.orElseGet(Optional.java:364)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'allInviteRepository' defined in org.redacted.AllInviteRepository defined in @EnableJpaRepositories declared on Application: null
    at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1786)
    at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:600)
    at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
    at app//org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
    at app//org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    at app//org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
    at app//org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
    at app//org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:969)
    at app//org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:962)
    at app//org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:624)
    at app//org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
    at app//org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
    at app//org.springframework.boot.SpringApplication.run(SpringApplication.java:334)
    at app//org.springframework.boot.test.context.SpringBootContextLoader.lambda$loadContext$3(SpringBootContextLoader.java:137)
    at app//org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58)
    at app//org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46)
    at app//org.springframework.boot.SpringApplication.withHook(SpringApplication.java:1454)
    at app//org.springframework.boot.test.context.SpringBootContextLoader$ContextLoaderHook.run(SpringBootContextLoader.java:553)
    at app//org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:137)
    at app//org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:108)
    at app//org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:225)
    at app//org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:152)
    ... 17 more
Caused by: java.lang.StackOverflowError
    at java.base/java.util.ArrayList.equals(ArrayList.java:529)
    at org.springframework.util.ObjectUtils.nullSafeEquals(ObjectUtils.java:341)
    at org.springframework.data.util.TypeDiscoverer.equals(TypeDiscoverer.java:334)
    at java.base/java.util.Objects.equals(Objects.java:64)
    at java.base/java.util.ArrayList.equalsArrayList(ArrayList.java:561)
    at java.base/java.util.ArrayList.equals(ArrayList.java:529)
    at org.springframework.util.ObjectUtils.nullSafeEquals(ObjectUtils.java:341)
    at org.springframework.data.util.TypeDiscoverer.equals(TypeDiscoverer.java:334)
    at java.base/java.util.Objects.equals(Objects.java:64)
    at java.base/java.util.ArrayList.equalsArrayList(ArrayList.java:561)
    at java.base/java.util.ArrayList.equals(ArrayList.java:529)
    at org.springframework.util.ObjectUtils.nullSafeEquals(ObjectUtils.java:341)
    at org.springframework.data.util.TypeDiscoverer.equals(TypeDiscoverer.java:334)
    at java.base/java.util.Objects.equals(Objects.java:64)
    at java.base/java.util.ArrayList.equalsArrayList(ArrayList.java:561)
    at java.base/java.util.ArrayList.equals(ArrayList.java:529)
    at org.springframework.util.ObjectUtils.nullSafeEquals(ObjectUtils.java:341)
    at org.springframework.data.util.TypeDiscoverer.equals(TypeDiscoverer.java:334)
    at java.base/java.util.Objects.equals(Objects.java:64)
    at java.base/java.util.ArrayList.equalsArrayList(ArrayList.java:561)
    at java.base/java.util.ArrayList.equals(ArrayList.java:529)
    at org.springframework.util.ObjectUtils.nullSafeEquals(ObjectUtils.java:341)
    at org.springframework.data.util.TypeDiscoverer.equals(TypeDiscoverer.java:334)
    at java.base/java.util.Objects.equals(Objects.java:64)
    at java.base/java.util.ArrayList.equalsArrayList(ArrayList.java:561)

Comment From: wilkinsona

Yes, this would appear to be a problem in Spring Data's TypeDiscoverer that is causing the stack to overflow. Please create a minimal sample that reproduces the problem and then report it in the Spring Data Commons repository.