Skip to content

BeanValidationFactory StackOverflowError with MappedCollectionDataTypePrimitive #435

@TheRealGuru

Description

@TheRealGuru

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

  1. Create a schema with a string property using format: byte:
    MyRequest:
    type: object
    properties:
    payload:
    type: string
    format: byte
  2. Add a type mapping: string:byte => byte[]
  3. Enable bean-validation: jakarta
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions