Source:
private Headers createHeaders() throws IOException { Map<String, Integer> hdrMap = null; List<String> headerNames = null; final String[] formatHeader = this.format.getHeader(); if (formatHeader != null) { hdrMap = createEmptyHeaderMap(); String[] headerRecord = null; if (formatHeader.length == 0) { final CSVRecord nextRecord = this.nextRecord(); if (nextRecord != null) { headerRecord = nextRecord.values(); } } else { if (this.format.getSkipHeaderRecord()) { this.nextRecord(); } headerRecord = formatHeader; } if (headerRecord != null) { for (int i = 0; i < headerRecord.length; i++) { final String header = headerRecord[i]; final boolean containsHeader = header != null && hdrMap.containsKey(header); final boolean emptyHeader = header == null || header.trim().isEmpty(); if (containsHeader) { if (!emptyHeader && !this.format.getAllowDuplicateHeaderNames()) { throw new IllegalArgumentException( String.format( "The header contains a duplicate name: \"%s\" in %s. " + "If this is valid then use CSVFormat.withAllowDuplicateHeaderNames().", header, Arrays.toString(headerRecord))); } if (emptyHeader && !this.format.getAllowMissingColumnNames()) { throw new IllegalArgumentException( "A header name is missing in " + Arrays.toString(headerRecord)); } } if (header != null) { hdrMap.put(header, Integer.valueOf(i)); if (headerNames == null) { headerNames = new ArrayList<>(headerRecord.length); } headerNames.add(header); } } } } if (headerNames == null) { headerNames = Collections.emptyList(); } else { headerNames = Collections.unmodifiableList(headerNames); } return new Headers(hdrMap, headerNames); }

Target:
private Headers createHeaders() throws IOException { Map<String, Integer> hdrMap = null; List<String> headerNames = null; final String[] formatHeader = this.format.getHeader(); if (formatHeader != null) { hdrMap = createEmptyHeaderMap(); String[] headerRecord = null; if (formatHeader.length == 0) { final CSVRecord nextRecord = this.nextRecord(); if (nextRecord != null) { headerRecord = nextRecord.values(); } } else { if (this.format.getSkipHeaderRecord()) { this.nextRecord(); } headerRecord = formatHeader; } if (headerRecord != null) { for (int i = 0; i < headerRecord.length; i++) { final String header = headerRecord[i]; final boolean containsHeader = header != null && hdrMap.containsKey(header); final boolean emptyHeader = header == null || header.trim().isEmpty(); if (containsHeader) { if (!emptyHeader && !this.format.getAllowDuplicateHeaderNames()) { throw new IllegalArgumentException( String.format( "The header contains a duplicate name: \"%s\" in %s. If this is valid then use CSVFormat.withAllowDuplicateHeaderNames().", header, Arrays.toString(headerRecord))); } if (emptyHeader && !this.format.getAllowMissingColumnNames()) { throw new IllegalArgumentException( "A header name is missing in " + Arrays.toString(headerRecord)); } } if (header != null) { hdrMap.put(header, Integer.valueOf(i)); if (headerNames == null) { headerNames = new ArrayList<>(headerRecord.length); } headerNames.add(header); } } } } if (headerNames == null) { headerNames = Collections.emptyList(); } else { headerNames = Collections.unmodifiableList(headerNames); } return new Headers(hdrMap, headerNames); }