Skip to content

[CSV-332] Keep the current line number at zero for empty input - #646

Open
hutiefang76 wants to merge 1 commit into
apache:masterfrom
hutiefang76:frank/fix-csv332-empty-line-number-20261203
Open

hutiefang76 wants to merge 1 commit into
apache:masterfrom
hutiefang76:frank/fix-csv332-empty-line-number-20261203

Conversation

@hutiefang76

Copy link
Copy Markdown

Jira: https://issues.apache.org/jira/browse/CSV-332, reported by Sergi Parpal.

After an empty CSV input reaches EOF, CSVParser.getCurrentLineNumber() changes from 0 to 1 even though no character was read. Exclude the initial UNDEFINED state from the EOF line-count increment in ExtendedBufferedReader.read().

Extend the existing empty-reader, empty-file and empty-string tests to check that the line number remains zero after reaching EOF, including repeated parser reads. All three tests fail on the original production code and pass with the fix. Existing CR, LF, CRLF and CSV-149 nonempty final-line regressions also execute successfully.

The default mvn -B -ntp build passed on Java 17 with Java 8 release: 978 tests executed, 11 existing disabled tests skipped, no failures or errors. This includes RAT, binary compatibility, SpotBugs, PMD/CPD, Javadoc, coverage and Checkstyle checks. The reader/parser classes also passed on an actual Java 8 runtime: 184 tests executed, four existing disabled tests skipped; all three changed empty-input tests executed.

  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance.
  • AI assistance: DeepSeek deepseek-v4-pro prepared the code, regressions and first-pass review; OpenAI Codex coordinated verification, formatting and this PR text.
  • Run a successful build using the default Maven goal.
  • Write unit tests that fail without the runtime fix.
  • Describe the problem, approach and validation.
  • Use a meaningful commit message with Assisted-By trailers.

Do not count the initial EOF as a line when no character has been read.
Extend the existing empty-input regressions for the reader and parser.

Assisted-By: DeepSeek V4 Pro
Assisted-By: OpenAI Codex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant