Skip to content
AITroveRead. Build. Understand.
Make this comfortable

Spring Boot environment validation: fail before a worker starts

Last updated: 30 Sept 20264 min read
tutorial
IntermediateBy AITrove Editorial

An invalid environment-provided batch size stops the checked Boot process before it prints a bound value.

Download Spring source kit

Reject the effective value

The probe binds relay.batch-size to an integer constrained from 1 through 100. With RELAY_BATCHSIZE=0, the child exits nonzero and never emits BOUND_BATCH. This tests validation after the environment source has been selected. The typed startup rule is the reason the worker should not quietly run with zero rows per tick.

A default of 8 is present, yet the explicit zero still fails. The default does not rescue an invalid higher-priority setting. This is different from a missing variable, which can legitimately leave the default in place under this fixture. A production requirement might reject absence too.

Failure is not an operational rollout test

The process test checks an exit code and lack of successful output. It does not prove that a load balancer removed the instance, that a retrying orchestrator backed off, or that no work was already in flight. The health boundary and the drain contract cover separate release behavior.

Checked source

bash
RELAY_BATCHSIZE=0 java -cp "$CLASSPATH" in.aitrove.contracts.RelaySettingsProcessProbe
# Nonzero exit; no BOUND_BATCH line

Verification boundary

RelaySettingsProcessTest.invalidEnvironmentValuePreventsStartup. The source kit contains the full test and entry point.

Common Mistakes

  • Do not validate only the programmatic default.
  • Do not treat absence and an explicitly invalid value as the same case.
  • Do not claim a failing probe proves deployment traffic was drained.

Read next

Spring Boot environment binding: prove the value in a child JVM, Spring Boot configuration validation: reject an unusable relay before work starts, Spring Boot configuration sources: test each deployment path, not a guessed order, Spring Boot liveness versus readiness: do not restart on every dependency outage.

spring
configuration
testing
Storage details