SentinelEmptyListSerializer

open class SentinelEmptyListSerializer<T : Any>(base: KClass<T>, sentinel: String) : KSerializer<List<T>> (source)

Serializer for a list of polymorphic base configurations that additionally understands the scalar sentinel as an explicit spelling of the empty list, and emits sentinel whenever the list is empty.

This exists because Spring Boot cannot express an empty collection. Its YamlProcessor flattens both foo: [] and foo: {} into the empty string for the property foo, indistinguishable from an unresolved shell variable, a blank Helm value or an emptied CI secret. Coercing that blank back into an empty list would mean an accidentally empty environment variable silently switches a security control off, so a deliberate, greppable token is required instead:

attestation:
android:
revocation: DISABLED

Because the token is a plain scalar it survives every property source unchanged — YAML, properties files, command-line arguments and environment variables alike — and because it round-trips through serialize as well, canonical configuration written by toYamlString()/toJsonString() stays loadable by every format, Spring included.

Matching is case-insensitive on read; sentinel is emitted verbatim on write.

Constructors

Link copied to clipboard
constructor(base: KClass<T>, sentinel: String)

Types

Link copied to clipboard

Raised for a scalar that is neither a list nor sentinel — most importantly the empty string Spring Boot produces for [], {} and for any property whose value went missing upstream. The message has to name the token, because it is the only way to express "no entries" here.

Properties

Link copied to clipboard
open override val descriptor: SerialDescriptor

Functions

Link copied to clipboard
open override fun deserialize(decoder: Decoder): List<T>
Link copied to clipboard
open override fun serialize(encoder: Encoder, value: List<T>)