BeanValidationFactory.validate() infinite recursion with MappedCollectionDataTypePrimitive
Description
(Yes this is almost idiot protection because I ran into this, but the stackoverflow error is extremely hard to diagnose once the mistake has been made).
When bean-validation: jakarta is enabled and a schema property uses format: byte (or format: binary) with a type mapping to byte[], code generation fails with a StackOverflowError.
Root Cause
MappedCollectionDataTypePrimitive implements CollectionDataType and its item property returns this:
override val item: DataType
get() = this
BeanValidationFactory.validate() checks dataType is CollectionDataType and recurses into validate(dataType.item). Since item points back to itself, this creates infinite recursion.
Steps to Reproduce
- Create a schema with a
string property using format: byte:
MyRequest:
type: object
properties:
payload:
type: string
format: byte
- Add a type mapping:
string:byte => byte[]
- Enable
bean-validation: jakarta
- Run the processor
Expected Behaviour
Either:
BeanValidationFactory.validate() detects the self-referential item and breaks the recursion (e.g. if (dataType.item === dataType) return), or
- A clear error message is produced explaining the incompatibility
Actual Behaviour
StackOverflowError with no indication of which schema or property caused it.
Version
openapi-processor-spring 2026.1
BeanValidationFactory.validate() infinite recursion with MappedCollectionDataTypePrimitive
Description
(Yes this is almost idiot protection because I ran into this, but the stackoverflow error is extremely hard to diagnose once the mistake has been made).
When
bean-validation: jakartais enabled and a schema property usesformat: byte(orformat: binary) with a type mapping tobyte[], code generation fails with aStackOverflowError.Root Cause
MappedCollectionDataTypePrimitiveimplementsCollectionDataTypeand itsitemproperty returnsthis:override val item: DataType
get() = this
BeanValidationFactory.validate()checksdataType is CollectionDataTypeand recurses intovalidate(dataType.item). Sinceitempoints back to itself, this creates infinite recursion.Steps to Reproduce
stringproperty usingformat: byte:MyRequest:
type: object
properties:
payload:
type: string
format: byte
string:byte => byte[]bean-validation: jakartaExpected Behaviour
Either:
BeanValidationFactory.validate()detects the self-referentialitemand breaks the recursion (e.g.if (dataType.item === dataType) return), orActual Behaviour
StackOverflowErrorwith no indication of which schema or property caused it.Version
openapi-processor-spring 2026.1