spring-projects / spring-projects/spring-batch

LineCallbackHandlers being aware of which Resource they are handling lines for

Open
#3,883 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

has: votes in: infrastructure status: waiting-for-reporter type: feature
Dominant language
Java
Stars
3k
Forks
2.5k
Avg merge
6d 53m
Merged PRs (30d)
3

Description

My issue is explained in detail in Stackoverflow here

Expected Behavior
I use a LineCallbackHandler to skip header lines in my file. I need to know which file resource the handler is currently skipping lines for. This used to be able to be achieved through MultiResourceItemReader.getCurrentResource() but this directly couples the MultiResourceItemReader to the LineCallbackHandler and recently that method has been deprecated.

Current Behavior
As suggested by @fmbenhassine in the Stackoverflow question there is a way to get this information by directly coupling the FlatFileItemReader itself to the LineCallbackHandler but this is just a workaround that essentially replicates the coupling in a different place.

As confirmed by @fmbenhassine Spring Batch offers no out of the box way to implement what I am trying to achieve without coupling.
An approach suggested by @fmbenhassine is to create a new interface ResourceAwareLineCallbackHandler that the FlatFileItemReader can make use of.
As also suggested by @fmbenhassine there may be other use cases for what I am trying to achieve such as lines considered as comment and knowing the source file of each comment line

This feature request is to discuss different options for implementing desired behaviour.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Stack Overflow discussion, then inspect MultiResourceItemReader, FlatFileItemReader, and LineCallbackHandler to understand the current coupling and deprecated access path. The issue needs a decided API approach, documented behavior for resource-aware callbacks, and corresponding verification before implementation is complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.