Skip to content

Deprecate MultiResourceItemReader#getCurrentResource #3776

Closed
@fmbenhassine

Description

@fmbenhassine

According to Robert. K, MultiResourceItemReader#getCurrentResource was never meant to be public and is an accidentally leaked implementation detail. Dr D. Syer never liked that getter.

I agree with both of them, this getter is confusing because in order to use it, one needs to inject the item reader in the item processor or line mapper to get the current resource (which is obviously a bad design as it couples batch artefacts), here are a few examples:

The correct way to get the current resource is by using the ResourceAware interface which was typically designed for this use case, here is an excerpt from its Javadoc:

Marker interface indicating that an item should have the Spring Resource in which it was read from, set on it.
The canonical example is within MultiResourceItemReader, which will set the current resource on any items
that implement this interface.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions