A team flips spring.threads.virtual.enabled: true on a Spring Boot 4 service running Java 21. Their existing spring.task.execution.pool.max-size: 32 stays right there in application.yml, keeping a rate-limited downstream payment partner safe from bursts, or so everyone assumes.

Startup is green. Zero errors. Zero warnings. Under Friday peak traffic, @Async spawns thousands of concurrent virtual threads at once and saturates the downstream connection limit. Spring Boot did not break; it obeyed spring.threads.virtual.enabled=true by swapping ThreadPoolTaskExecutor for SimpleAsyncTaskExecutor with UNBOUNDED_CONCURRENCY (-1), leaving spring.task.execution.pool.max-size bound cleanly in memory and completely unread.

Across Part 1, Part 2, and Part 3, we built three layers of defense against silent Spring Boot 4 wiring failures: understanding the structural gap between property binding and @Conditional, diffing /actuator/conditions during Boot 3-to-4 upgrades, and running ApplicationContextRunner plus OrphanedPropertyGuard in CI.

Yet one blind spot remains even when every condition report looks tidy: ConditionEvaluationReport tells you which auto-configuration matched, not what values actually landed on the live bean.

Where Condition Reports Stop (And Live Beans Diverge)

OrphanedPropertyGuard (even with the BeanFactory parse-phase cross-check from Part 3) answers a structural question: did the expected auto-configuration class or @Bean method register its bean?

In production Spring Boot 4 services, three real scenarios still break past that check:

  1. Competing feature toggles swap bean implementations: Turning on Virtual Threads intentionally activates one auto-configured bean (applicationTaskExecutorVirtualThreads) while retiring another (applicationTaskExecutor), silently invalidating legacy pool-sizing properties still sitting in application.yml.
  2. Intentional custom beans bypass YAML binding: A team defines a custom HikariDataSource or ConcurrentKafkaListenerContainerFactory, silences the orphaned-property rule via ignoringRules(...), and forgets to bind one tuning property (connection-timeout or the virtual-thread executor) onto the custom instance.
  3. Fallback registries hide inside composite wrappers: When an observability starter is missing in Boot 4, Actuator still boots a healthy MeterRegistry, except it is an in-memory SimpleMeterRegistry (often wrapped inside a CompositeMeterRegistry) exporting zero metrics to Grafana or Datadog.

Closing that gap requires inspecting the live instantiated Spring beans once the ApplicationContext finishes wiring.

Four High-Impact Spring Boot 4 Traps Where Live Bean State Matters Most

All four traps below are verified against Spring Boot 4.0.10 with executable ApplicationContextRunner proofs in the open-source companion repository github.com/grupavii/boot-truth (v0.3.0).

Trap 1: Virtual Threads Silently Erasing spring.task.execution.pool.* (and Custom Executor Back-Off)

Inside TaskExecutionAutoConfiguration, TaskExecutorConfigurations$TaskExecutorConfiguration defines two mutually exclusive primary applicationTaskExecutor @Bean methods gated on @ConditionalOnThreading:

  • applicationTaskExecutor (ThreadPoolTaskExecutor) consumes spring.task.execution.pool.core-size, max-size, and queue-capacity when Threading.PLATFORM is active.
  • applicationTaskExecutorVirtualThreads (SimpleAsyncTaskExecutor with virtual threads enabled) activates when spring.threads.virtual.enabled=true and consumes spring.task.execution.simple.concurrency-limit instead.

That split creates two mirror-image silent traps:

spring:
  threads:
    virtual:
      enabled: true
  task:
    execution:
      pool:
        core-size: 8
        max-size: 32   # Silently ignored! Live SimpleAsyncTaskExecutor runs UNBOUNDED (-1)
  1. Unbounded concurrency bomb (BT-TASK-001 / LIVE-TASK-001): Flipping spring.threads.virtual.enabled=true on an existing service leaves spring.task.execution.pool.* orphaned. The live applicationTaskExecutor bean is a SimpleAsyncTaskExecutor with concurrencyLimit == -1 (SimpleAsyncTaskExecutor.UNBOUNDED_CONCURRENCY). Any @Async workload that previously relied on max-size: 32 as a bulkhead against a database or third-party API suddenly runs without a ceiling.
  2. Silent reversion to platform threads (BT-VTHREADS-001 / LIVE-VTHREADS-001): Conversely, if a developer adds any custom Executor or TaskExecutor @Bean (say, for a background report job), @ConditionalOnMissingBean(Executor.class) backs off applicationTaskExecutorVirtualThreads. Startup stays green while @Async quietly reverts to a platform ThreadPoolTaskExecutor.

The deterministic fix: When adopting Virtual Threads, migrate concurrency caps from spring.task.execution.pool.* to spring.task.execution.simple.concurrency-limit, and mark any auxiliary Executor bean @Bean(defaultCandidate = false) so primary virtual-thread auto-configuration stays active.

Trap 2: OTLP and Prometheus Metrics Silently Falling Back to SimpleMeterRegistry

Spring Boot 4’s modularization hit observability hard. Configuring OTLP metrics export in application.yml used to work once micrometer-registry-otlp was on the classpath:

management:
  otlp:
    metrics:
      export:
        url: http://otel-collector:4318/v1/metrics
        step: 30s

In Spring Boot 4.0, OtlpMetricsExportAutoConfiguration requires both io.micrometer:micrometer-registry-otlp and org.springframework.boot:spring-boot-starter-opentelemetry (specifically OpenTelemetryProperties on the classpath). Drop either module (or omit io.micrometer:micrometer-registry-prometheus when configuring management.prometheus.metrics.export.*), and Spring Boot does not fail startup.

Instead, SimpleMetricsExportAutoConfiguration quietly fills the gap with an in-memory SimpleMeterRegistry. Health checks return 200 OK, Actuator boots cleanly, and your production dashboards flatline because nothing is actually exporting metrics (BT-OBS-001, BT-OBS-002, LIVE-OBS-001).

The deterministic fix: Add both spring-boot-starter-opentelemetry and micrometer-registry-otlp (or micrometer-registry-prometheus) alongside spring-boot-starter-actuator, and assert on the live MeterRegistry tree (flattening any CompositeMeterRegistry) that a real OtlpMeterRegistry or PrometheusMeterRegistry bean is active.

Trap 3: Reactive R2DBC Silently Running Unpooled Under Load

Everything looks fine in staging until a reactive service hits real concurrency and PostgreSQL starts rejecting queries with too many clients, even though spring.r2dbc.pool.max-size: 20 sits right in application.yml:

spring:
  r2dbc:
    url: r2dbc:postgresql://db.internal:5432/payments
    pool:
      initial-size: 5
      max-size: 20

In Spring Boot 4.0, R2DBC pooling is wired by ConnectionFactoryConfigurations$PoolConfiguration$PooledConnectionFactoryConfiguration, which requires io.r2dbc.pool.ConnectionPool on the classpath and @ConditionalOnMissingBean(ConnectionFactory.class).

If io.r2dbc:r2dbc-pool is omitted during a dependency cleanup, or if someone defines a custom ConnectionFactory bean for custom SSL or credential rotation, PooledConnectionFactoryConfiguration quietly backs off (BT-R2DBC-001 / LIVE-R2DBC-001). Your spring.r2dbc.pool.* settings sit untouched while every reactive query opens a raw, unpooled ConnectionFactory connection.

The deterministic fix: Keep io.r2dbc:r2dbc-pool explicit in build.gradle.kts, mark auxiliary ConnectionFactory beans @Bean(defaultCandidate = false), and verify at startup that the primary ConnectionFactory is an instance of io.r2dbc.pool.ConnectionPool (unless spring.r2dbc.pool.enabled=false is explicitly set).

Trap 4: Custom RabbitMQ Listener Factories Dropping Concurrency and Prefetch

AMQP queue depth starts climbing during peak hours while your pods sit at low CPU, despite spring.rabbitmq.listener.simple.concurrency: 4 and prefetch: 25 sitting right in config. The culprit is usually a bare factory bean carried over from an earlier migration:

@Bean
fun rabbitListenerContainerFactory(
    connectionFactory: ConnectionFactory,
): SimpleRabbitListenerContainerFactory =
    SimpleRabbitListenerContainerFactory().apply {
        setConnectionFactory(connectionFactory)
    }

The moment that bare bean exists, RabbitAnnotationDrivenConfiguration#simpleRabbitListenerContainerFactory backs off (BT-AMQP-001). RabbitProperties still binds spring.rabbitmq.listener.simple.concurrency=4, max-concurrency=10, and prefetch=25 without a peep, while live consumers run single-threaded with default prefetch and no Virtual Threads wiring.

The deterministic fix: Inject SimpleRabbitListenerContainerFactoryConfigurer (or DirectRabbitListenerContainerFactoryConfigurer) and call configurer.configure(factory, connectionFactory) before applying custom error handlers or message converters.

Quick Reference: The Four New Boot 4 Traps

TrapCondition RuleLive CheckSilent Runtime SymptomDeterministic Fix
Virtual Threads / PoolBT-TASK-001, BT-VTHREADS-001LIVE-TASK-001, LIVE-VTHREADS-001pool.max-size ignored (UNBOUNDED_CONCURRENCY) or custom Executor reverts to platform threadsUse spring.task.execution.simple.concurrency-limit; mark auxiliary executors defaultCandidate = false
OTLP / PrometheusBT-OBS-001, BT-OBS-002LIVE-OBS-001Missing Boot 4 starter silently falls back to in-memory SimpleMeterRegistryAdd spring-boot-starter-opentelemetry + micrometer-registry-otlp (or Prometheus) and verify leaf registries
R2DBC PoolBT-R2DBC-001LIVE-R2DBC-001Missing r2dbc-pool or custom ConnectionFactory serves unpooled connectionsKeep io.r2dbc:r2dbc-pool; assert live ConnectionPool bean
RabbitMQ ListenerBT-AMQP-001Method-level BeanFactory checkCustom factory silently drops concurrency, prefetch, and Virtual ThreadsInject SimpleRabbitListenerContainerFactoryConfigurer

Rule of thumb: Whenever you flip a runtime-wide toggle like spring.threads.virtual.enabled=true or upgrade an observability stack in Spring Boot 4, inspect the live bean class and effective field values, not just the YAML or the condition report.

Architecture of LivePropertyVerifier: Zero-Bloat Live Bean Checks

Three-layer BootTruth verification architecture across a Spring Boot 4 lifecycle: Layer 1 (boot-truth-diff via CLI, GitHub Action, Gradle, and Maven plugins) compares /actuator/conditions snapshots across Boot 3-to-4 upgrades; Layer 2 (OrphanedPropertyGuard) cross-checks Environment prefixes against ConditionEvaluationReport and BeanFactory definitions; Layer 3 (LivePropertyVerifier via SmartInitializingSingleton and LivePropertyCheck SPI) inspects live instantiated beans such as HikariDataSource, SimpleAsyncTaskExecutor, ConnectionPool, and flattened MeterRegistry trees

In boot-truth v0.3.0, we paired OrphanedPropertyGuard with a dedicated second verification engine: LivePropertyVerifier. Both engines run inside BootTruthAutoConfiguration via a SmartInitializingSingleton, meaning live checks execute only after every singleton bean, @ConfigurationProperties binding pass, and Customizer has finished initializing.

Two design constraints mattered most so teams could drop boot-truth-starter into any service without fear:

  1. Zero transitive dependency bloat: boot-truth-core never forces Hikari, Kafka, R2DBC, Spring Security, or Micrometer onto a service’s classpath. Every check in BuiltInLiveChecks guards optional types with ClassUtils.isPresent(...) and isolates technology-specific imports in private helper objects loaded only when that class exists at runtime.
  2. Strict zero-false-positive invariant: Every check reads ConfigurableEnvironment property sources first and exits immediately unless the operator explicitly configured the relevant property. It also honors explicit disable flags like spring.r2dbc.pool.enabled=false or management.otlp.metrics.export.enabled=false.

Out of the box, BuiltInLiveChecks.defaults() ships eight live checks:

Check IDWhat It Verifies on the Live Bean
LIVE-JDBC-001Compares spring.datasource.hikari.maximum-pool-size and connection-timeout directly against the live primary HikariDataSource.
LIVE-CACHE-001Fails when Caffeine, Redis, or an explicit non-simple spring.cache.type is configured yet a live ConcurrentMapCacheManager booted.
LIVE-VTHREADS-001Verifies applicationTaskExecutor is a SimpleAsyncTaskExecutor (and applies spring.task.execution.simple.concurrency-limit) when spring.threads.virtual.enabled=true.
LIVE-TASK-001Verifies spring.task.execution.pool.core-size and max-size actually took effect on a live ThreadPoolTaskExecutor, catching the Virtual Threads unbounded-concurrency bomb immediately.
LIVE-KAFKA-001Verifies kafkaListenerContainerFactory wired a SimpleAsyncTaskExecutor when both spring.threads.virtual.enabled=true and spring.kafka.listener.* are set.
LIVE-SEC-001Verifies at least one live SecurityFilterChain or SecurityWebFilterChain bean exists when spring.security.* is configured.
LIVE-R2DBC-001Verifies the live R2DBC ConnectionFactory is wrapped in io.r2dbc.pool.ConnectionPool.
LIVE-OBS-001Flattens CompositeMeterRegistry trees and verifies an active OtlpMeterRegistry or PrometheusMeterRegistry exists instead of SimpleMeterRegistry.

When a service flips Virtual Threads on while leaving spring.task.execution.pool.max-size=32 behind, LivePropertyVerifier fails CI (or startup in FAIL mode) with an exact diff between intent and reality:

[ERROR] LIVE-TASK-001: spring.task.execution.pool.* is configured, but live TaskExecutor 'applicationTaskExecutor' is SimpleAsyncTaskExecutor (pool sizing is silently ignored).
  Configured property   : spring.task.execution.pool.max-size
  Expected live value   : ThreadPoolTaskExecutor (pool-configured)
  Observed live value   : org.springframework.core.task.SimpleAsyncTaskExecutor
  Inspected bean        : applicationTaskExecutor
  Remediation           : If spring.threads.virtual.enabled=true is active, migrate pool caps to spring.task.execution.simple.concurrency-limit; otherwise verify no custom Executor overrode ThreadPoolTaskExecutor.

Enabling Live Verification in CI and Startup

In your service’s InfrastructureContractTest, turning on all eight live checks is a single fluent call alongside assertNoOrphanedProperties():

BootTruthAssertions.verify(context)
    .assertNoOrphanedProperties()
    .assertLivePropertiesApplied()

In boot-truth-starter, live verification is opt-in so legacy services can adopt it deliberately without unexpected boot failures:

boot-truth:
  mode: FAIL # Start with WARN locally, enforce FAIL in CI and staging
  live-verification:
    enabled: true
    disabled-checks: [] # Opt out of specific LIVE-* IDs if intentionally overridden

Extending to Company-Specific Invariants via LivePropertyCheck SPI

Built-in rules cover common Spring Boot infrastructure, yet every regulated fintech or enterprise platform has its own high-blast-radius properties: outbound payment client timeouts, TLS/mTLS truststores, tenant context propagation, or custom RSocket frame limits.

Because BootTruthAutoConfiguration injects ObjectProvider<LivePropertyCheck>, adding a custom live invariant inside your internal platform starter takes one @Bean:

@Bean
fun paymentClientTimeoutLiveCheck(): LivePropertyCheck = object : LivePropertyCheck {
    override val id: String = "LIVE-PAY-001"

    override fun verify(context: ConfigurableApplicationContext): List<LiveVerificationViolation> {
        val expectedMs = context.environment
            .getProperty("app.payments.client.read-timeout-ms", Long::class.java)
            ?: return emptyList() // Zero false positives when unconfigured

        val client = context.getBeanProvider(PaymentGatewayClient::class.java).ifAvailable
            ?: return emptyList()

        if (client.readTimeout.toMillis() == expectedMs) return emptyList()

        return listOf(
            LiveVerificationViolation(
                checkId = id,
                propertyKey = "app.payments.client.read-timeout-ms",
                expectedValue = "${expectedMs}ms",
                actualValue = "${client.readTimeout.toMillis()}ms",
                beanName = "paymentGatewayClient",
                description = "Live PaymentGatewayClient readTimeout does not match configured property.",
                remediation = "Bind PaymentClientProperties onto PaymentGatewayClientBuilder instead of constructing a bare client.",
            ),
        )
    }
}

Drop that bean into your organization’s shared platform starter, and every service inheriting the starter automatically verifies the contract at boot and in tests.

What to check: Pick one internal starter your platform team maintains (HTTP client, messaging envelope, security, or audit logging). If a service team writes a custom @Bean that overrides it, would anything in CI notice that your default timeouts or security headers silently vanished?

Honest Trade-Offs: Condition Guards vs. Live Bean Verification

Each layer in the four-part toolkit catches a distinct failure mode, and none of them replaces the others:

  • boot-truth-diff (CLI, GitHub Action, Gradle & Maven plugins): best for catching upgrade and environment drift (Boot 3 → 4 cutovers, staging vs. prod) before merging or promoting.
  • OrphanedPropertyGuard (ConditionEvaluationReport + BeanFactory): best for explaining why a subsystem backed off, even when zero beans were created or a nested @Import produced a parse-phase ghost match.
  • LivePropertyVerifier: best for proving what actually booted on live bean instances, catching toggle collisions (Virtual Threads vs. thread pools), silent fallbacks (SimpleMeterRegistry, ConcurrentMapCacheManager), and half-bound custom beans.

Live bean inspection has real edges you should design around consciously:

  • Decorators and proxies: Libraries like datasource-proxy, P6Spy, or Micrometer wrappers can wrap a HikariDataSource inside a delegating DataSource. Live checks must either unwrap cleanly or degrade gracefully without throwing false positives.
  • Lazy initialization (@Lazy): Inspecting a bean inside SmartInitializingSingleton intentionally instantiates non-lazy infrastructure singletons. Keep live checks focused on core infrastructure beans that should always boot eagerly anyway, and avoid touching private reflection internals that break across minor Spring upgrades.
  • Opt-in rollout: That is why boot-truth.live-verification.enabled defaults to false in boot-truth-starter. Teams turn on condition guards first, clean up existing drift in WARN mode, and then flip live verification on in CI and staging.

What Platform Leads and CTOs Should Standardize Across a Spring Boot 4 Fleet

Across this four-part series, the pattern stays consistent: Spring Boot 4 is cleaner and more modular than Boot 3, yet modularity turns missing dependencies and toggle interactions into silent runtime regressions instead of loud compile errors.

To make that failure class boring across ten or fifty microservices, standardize three final practices on top of your Part 1–3 gates:

  • Pair every Virtual Threads rollout with an explicit concurrency ceiling: Treat spring.threads.virtual.enabled=true without spring.task.execution.simple.concurrency-limit (where spring.task.execution.pool.* previously protected downstream systems) as a CI failure via BT-TASK-001 and LIVE-TASK-001.
  • Verify live observability exporters before production cutover: Never assume a 200 OK Actuator endpoint means metrics are leaving the pod. Enforce LIVE-OBS-001 so missing Boot 4 OpenTelemetry or Prometheus starters fail the build instead of silently falling back to SimpleMeterRegistry.
  • Encode company-specific invariants as LivePropertyCheck beans in internal starters: Move tribal knowledge (“remember to call the configurer”, “never leave raw unpooled R2DBC”) out of Confluence checklists and into executable startup checks that run on every PR.

With those live checks wired into CI, flipping spring.threads.virtual.enabled: true next to pool.max-size: 32 stops on the pull request instead of saturating your payment partner during Friday peak traffic. Good trackers never trust a fresh set of prints just because the trail starts in the right direction. Follow it all the way to the live bean in memory, and Spring Boot 4 stops keeping secrets from your production cluster.


Rolling out Java 21 Virtual Threads, OpenTelemetry, or a Spring Boot 4 migration across business-critical JVM services? A fixed-scope 2-Week Architecture Review audits your system architecture, runtime bean contracts, and silent reliability risks directly in code, or share one production bottleneck via the contact form for three candid observations within 48 hours.