spring-projects / spring-projects/spring-batch

lineNumber in FlatFileItemReader not threadsafe

Open
#3,632 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: documentation type: enhancement
Dominant language
Java
Stars
3k
Forks
2.5k
Avg merge
6d 53m
Merged PRs (30d)
3

Description

If multiple threads are configured in a step using a FlatFileItemReader, the lineNumber issued to the linemapper is compromised.

As a simple possible solution, the readline-Method must be synchronized. The lineMapper itself does not need sync.

BTW: In doc of the ItemReader the statement
" Implementations need not be thread-safe and clients of a {@link ItemReader}
need to be aware that this is the case.
"

is deeply misleading.

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 FlatFileItemReader and its readline method, then review the ItemReader documentation quoted in the issue. Reproduce a multi-threaded step using the reader and inspect how lineNumber reaches the lineMapper. Done means concurrent reads provide correct line numbers without requiring synchronization in the lineMapper.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.