Aryan Ganjoo created CSV-330:
--------------------------------
Summary: CSVRecord.isConsistent miscounts records with duplicate
or empty headers
Key: CSV-330
URL: https://issues.apache.org/jira/browse/CSV-330
Project: Commons CSV
Issue Type: Bug
Reporter: Aryan Ganjoo
On current Commons CSV master, CSVRecord.isConsistent() compares the record
value count with the number of distinct entries in the header map. When
DuplicateHeaderMode.ALLOW_ALL or ALLOW_EMPTY permits repeated names, that map
is smaller than the actual header column count.
Reproduction: parse "a,b,a\n1,2,3\n1,2\n" with setHeader() and
DuplicateHeaderMode.ALLOW_ALL. The three-value record reports false even though
it matches the three header columns; the two-value record reports true even
though it is short. The same problem occurs with repeated empty header names
when missing names are allowed.
The expected behavior is to compare with the number of header columns,
including repeated or empty names. A minimal local fix and regression tests are
available. On the patched candidate, CSVRecordTest passed 35/35 and the Maven
test suite passed 987 tests with 11 skipped on JDK 17. I checked existing
CSV-82 and CSV-164; they concern different header behavior.
AI Assistance used.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)