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

ASF GitHub Bot logged work on CSV-302:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 20/Oct/22 14:44
            Start Date: 20/Oct/22 14:44
    Worklog Time Spent: 10m 
      Work Description: garydgregory commented on code in PR #276:
URL: https://github.com/apache/commons-csv/pull/276#discussion_r1000733851


##########
src/main/java/org/apache/commons/csv/CSVFormat.java:
##########
@@ -356,11 +356,11 @@ public Builder setDelimiter(final String delimiter) {
         /**
          * Sets the duplicate header names behavior.
          *
-         * @param duplicateHeaderMode the duplicate header names behavior
+         * @param duplicateHeaderMode the duplicate header names behavior, may 
not be null
          * @return This instance.
          */
         public Builder setDuplicateHeaderMode(final DuplicateHeaderMode 
duplicateHeaderMode) {
-          this.duplicateHeaderMode = duplicateHeaderMode;
+          this.duplicateHeaderMode = 
Objects.requireNonNull(duplicateHeaderMode, "Mode required");

Review Comment:
   Why not use the `validate()` method like all other checks?





Issue Time Tracking
-------------------

    Worklog Id:     (was: 818821)
    Time Spent: 2h 10m  (was: 2h)

> 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: 2h 10m
>  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