[ 
https://issues.apache.org/jira/browse/CSV-302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17625644#comment-17625644
 ] 

Seth Falco edited comment on CSV-302 at 10/28/22 11:56 AM:
-----------------------------------------------------------

Based on my findings in this PR:
https://github.com/apache/commons-csv/pull/114

While by the names, it sounds like the default should be `DISALLOW`. If we look 
at the old code, the default value should actually be `ALLOW_EMPTY`.
When `allowDuplicateHeaderNames` was set to `false`, it still allowed duplicate 
empty headers.

> // Note: This will always allow a duplicate header if the header is empty
> 
> — 
> https://github.com/apache/commons-csv/pull/114/files#diff-4274bff7e18158d8230b2c46e6ab7ae5af153bcd9aa69961d1fbf1faa87fbbfbL500

Edit: Sorry for introducing not considering that meanwhile! It seems I only 
tested cases where it was explicitly set, and not the default behavior.


was (Author: sethi):
Based on my findings in this PR:
https://github.com/apache/commons-csv/pull/114

While by the names, it sounds like the default should be `DISALLOW`. If we look 
at the old code, the default value should actually be `ALLOW_EMPTY`.
When `allowDuplicateHeaderNames` was set to `false`, it still allowed duplicate 
empty headers.

> // Note: This will always allow a duplicate header if the header is empty
> 
> — 
> https://github.com/apache/commons-csv/pull/114/files#diff-4274bff7e18158d8230b2c46e6ab7ae5af153bcd9aa69961d1fbf1faa87fbbfbL500

> CSVFormat.duplicateHeaderMode requires default for backward compatibility
> -------------------------------------------------------------------------
>
>                 Key: CSV-302
>                 URL: https://issues.apache.org/jira/browse/CSV-302
>             Project: Commons CSV
>          Issue Type: Bug
>          Components: Parser
>    Affects Versions: 1.x
>            Reporter: Markus Spann
>            Priority: Minor
>          Time Spent: 2.5h
>  Remaining Estimate: 0h
>
> The member in class {{CSVFormat}}
> {code:java}
> boolean allowDuplicateHeaderNames{code}
>  was recently replaced by 
> {code:java}
> DuplicateHeaderMode duplicateHeaderMode{code}
> The boolean defaults to {{{}false{}}}, while the member of type 
> {{DuplicateHeaderMode}} defaults to {{{}null{}}}.
> {{duplicateHeaderMode}} must be initialized with {{DISALLOW}} for backward 
> compatibility.
> The change is also problematic with regards to serialization. The class is 
> serializable and {{serialVersionUID}} is unchanged between versions. The 
> boolean setting {{allowDuplicateHeaderNames}} in an object serialized in 
> version 1.9.0 or earlier would always be de-serialized to 
> {{duplicateHeaderMode = null}} in the current head.
> To handle the code changes correctly, customized de-serialization would need 
> to be implemented.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to