Skip to content

Commit 45dec89

Browse files
committed
[CSV-239] Cannot get headers in column order from CSVRecord.
* fix exception messages
1 parent 8e9c6e7 commit 45dec89

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

src/main/java/org/apache/commons/csv/CSVParser.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,11 +490,10 @@ private Headers createHeaderMapAndHeaderNames() throws IOException {
490490
final boolean emptyHeader = header == null || header.trim().isEmpty();
491491
if (containsHeader && !emptyHeader && !this.format.getAllowDuplicateHeaderNames()) {
492492
throw new IllegalArgumentException("The header contains a duplicate name: \"" + header
493-
+ "\" in " + Arrays.toString(headerRecord) + ". If your data is valid then use CSVFormat.withAllowDuplicateHeaderNames().");
493+
+ "\" in " + Arrays.toString(headerRecord) + ". If this is valid then use CSVFormat.withAllowDuplicateHeaderNames().");
494494
}
495-
if (containsHeader && (emptyHeader && !this.format.getAllowMissingColumnNames())) {
496-
throw new IllegalArgumentException("The header contains a duplicate name: \"" + header
497-
+ "\" in " + Arrays.toString(headerRecord));
495+
if (containsHeader && emptyHeader && !this.format.getAllowMissingColumnNames()) {
496+
throw new IllegalArgumentException("A header name is missing in " + Arrays.toString(headerRecord));
498497
}
499498
if (header != null) {
500499
hdrMap.put(header, Integer.valueOf(i));

0 commit comments

Comments
 (0)