Skip to content

FlatFileItemReader ignoring line starts with # #4337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tirtawn opened this issue Mar 27, 2023 · 2 comments
Closed

FlatFileItemReader ignoring line starts with # #4337

tirtawn opened this issue Mar 27, 2023 · 2 comments
Labels
status: waiting-for-triage Issues that we did not analyse yet type: bug

Comments

@tirtawn
Copy link

tirtawn commented Mar 27, 2023

Bug description
FlatFileIteamReader skip any lines if the line starts with #
Example:
email
hello
#hello2 --> this will be skipped
hello3
hello4

Environment
Spring Batch 2.7.10
Java 17
H2 Mem / Postgres/SQL Server

Steps to reproduce
I have attached 2 files
import.txt
springdemo2.zip

compile and run the jar. The program will import the import.txt and print the data to the console. (it will skip line #2) .

Expected behavior
All the lines inside the file will be read.

Minimal Complete Reproducible example
springdemo2.zip and import.txt is attached
just compile into jar file and put the import.txt inside the target directory.
Running the jar file should skip the line with the #
as shown below:
2023-03-26 23:25:58.171 INFO 30528 --- [ main] o.s.batch.core.job.SimpleStepHandler : Executing step: [Import Exception Step]
Email: ExceptionUserEntity(email=hello)
Email: ExceptionUserEntity(email=hello3)
Email: ExceptionUserEntity(email=hello4)

--> Notice: hello2 is skipped

Bug reports that are repr
springdemo2.zip
oducible will take priority in resolution over reports that are not reproducible.
import.txt

@tirtawn tirtawn added status: waiting-for-triage Issues that we did not analyse yet type: bug labels Mar 27, 2023
@hpoettker
Copy link
Contributor

Hi @tirtawn, this is actually a feature as comments usually start with #.

If this doesn't work for you, you can use FlatFileItemReader#setComments to set different comment prefixes. To disable this feature completely, you can pass an empty array to that method.

@tirtawn
Copy link
Author

tirtawn commented Mar 27, 2023

Got it. Thanks for the confirmation.

@tirtawn tirtawn closed this as completed Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage Issues that we did not analyse yet type: bug
Projects
None yet
Development

No branches or pull requests

2 participants