Skip to content

Inconsistent state validation rules between RepositoryItemReader and RepositoryItemReaderBuilder #4276

Closed
@ghusta

Description

@ghusta

Bug description
Depending on whether you create an instance of RepositoryItemReader via :

  • bean factory using RepositoryItemReader's afterPropertiesSet()
  • or RepositoryItemReaderBuilder

The validation won't be the same in the case of we set these 3 parameters : repository + methodName + sorts

  • if we make an instance via RepositoryItemReader, calling afterPropertiesSet() at the send, it's 🆗
  • if we make an instance via RepositoryItemReaderBuilder, it's ❌ with this exception : java.lang.IllegalStateException: A name is required when saveState is set to true.

Environment
Spring Batch 4.3 / 5.0

Minimal Complete Reproducible example
Failing unit test : org.example.ReaderInitializerTest#init_reader_via_builder,
that can be found in this project : https://github.com/ghusta/test-spring-batch-repository-item-reader-builder

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions