-
-
Notifications
You must be signed in to change notification settings - Fork 253
Closed
Description
Hello,
It seems that containsColumn throws an ArrayIndexOutOfBoundsException, when used in combination with selectFields. The following test fails because of that:
import com.univocity.parsers.csv.CsvParser;
import com.univocity.parsers.csv.CsvParserSettings;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
class CsvParserTest {
@Test
void testContainColumns() {
var settings = new CsvParserSettings();
settings.setHeaderExtractionEnabled(true);
settings.selectFields("AAA", "BBB", "CCC");
var parser = new CsvParser(settings);
var inputStream = new ByteArrayInputStream("AAA,BBB\na,b".getBytes());
parser.beginParsing(inputStream);
Assertions.assertFalse(parser.getRecordMetadata().containsColumn("CCC"));
}
}java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 2
at com.univocity.parsers.common.ColumnMap.indexOf(ColumnMap.java:69)
at com.univocity.parsers.common.DefaultContext.indexOf(DefaultContext.java:82)
at com.univocity.parsers.common.record.RecordMetaDataImpl.containsColumn(RecordMetaDataImpl.java:481)
Thanks
Reactions are currently unavailable