File tree Expand file tree Collapse file tree
src/main/java/org/apache/commons/csv Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -488,12 +488,16 @@ private Headers createHeaderMapAndHeaderNames() throws IOException {
488488 final String header = headerRecord [i ];
489489 final boolean containsHeader = header == null ? false : hdrMap .containsKey (header );
490490 final boolean emptyHeader = header == null || header .trim ().isEmpty ();
491- if (containsHeader && !emptyHeader && !this .format .getAllowDuplicateHeaderNames ()) {
492- throw new IllegalArgumentException ("The header contains a duplicate name: \" " + header
493- + "\" in " + Arrays .toString (headerRecord ) + ". If this is valid then use CSVFormat.withAllowDuplicateHeaderNames()." );
494- }
495- if (containsHeader && emptyHeader && !this .format .getAllowMissingColumnNames ()) {
496- throw new IllegalArgumentException ("A header name is missing in " + Arrays .toString (headerRecord ));
491+ if (containsHeader ) {
492+ if (!emptyHeader && !this .format .getAllowDuplicateHeaderNames ()) {
493+ throw new IllegalArgumentException ("The header contains a duplicate name: \" " + header
494+ + "\" in " + Arrays .toString (headerRecord )
495+ + ". If this is valid then use CSVFormat.withAllowDuplicateHeaderNames()." );
496+ }
497+ if (emptyHeader && !this .format .getAllowMissingColumnNames ()) {
498+ throw new IllegalArgumentException (
499+ "A header name is missing in " + Arrays .toString (headerRecord ));
500+ }
497501 }
498502 if (header != null ) {
499503 hdrMap .put (header , Integer .valueOf (i ));
You can’t perform that action at this time.
0 commit comments