@@ -304,7 +304,7 @@ private void put(final String name, final Integer index) {
304304 }
305305
306306 public boolean isEmpty () {
307- return this .headerMap == null || this . headerMap .isEmpty ();
307+ return this .headerMap .isEmpty ();
308308 }
309309 }
310310
@@ -619,7 +619,7 @@ private Headers createHeaders() throws IOException {
619619 final Headers headers = new Headers (format );
620620 final String [] formatHeader = format .getHeader ();
621621 if (formatHeader != null ) {
622- final String [] headerRecord = getHeaderRecord ();
622+ final String [] headerRecord = getHeaderRecord (formatHeader );
623623 // build the name to index mappings
624624 if (headerRecord != null ) {
625625 // Track an occurrence of a null, empty or blank header.
@@ -657,26 +657,23 @@ private Headers createHeaders() throws IOException {
657657 * If the format does not contain header record, the header record from the first line of the file
658658 * @throws IOException if there is a problem reading the header or skipping the first record
659659 */
660- private String [] getHeaderRecord () throws IOException {
660+ private String [] getHeaderRecord (final String [] formatHeader ) throws IOException {
661661 String [] headerRecord = null ;
662- final String [] formatHeader = format .getHeader ();
663- if (formatHeader != null ) {
664- if (formatHeader .length == 0 ) {
665- // read the header from the first line of the file
662+ if (formatHeader .length == 0 ) {
663+ // read the header from the first line of the file
664+ final CSVRecord nextRecord = nextRecord ();
665+ if (nextRecord != null ) {
666+ headerRecord = nextRecord .values ();
667+ headerComment = nextRecord .getComment ();
668+ }
669+ } else {
670+ if (format .getSkipHeaderRecord ()) {
666671 final CSVRecord nextRecord = nextRecord ();
667672 if (nextRecord != null ) {
668- headerRecord = nextRecord .values ();
669673 headerComment = nextRecord .getComment ();
670674 }
671- } else {
672- if (format .getSkipHeaderRecord ()) {
673- final CSVRecord nextRecord = nextRecord ();
674- if (nextRecord != null ) {
675- headerComment = nextRecord .getComment ();
676- }
677- }
678- headerRecord = formatHeader ;
679675 }
676+ headerRecord = formatHeader ;
680677 }
681678 return headerRecord ;
682679 }
0 commit comments