frictionlessdata / datapackage-java

A Java library for working with Frictionless Data Data Packages.
MIT License
20 stars 7 forks source link

NPE when creating Dialect from CSVFormat #33

Closed ShadowZone closed 4 years ago

ShadowZone commented 4 years ago

Overview

I get a NullPointerException when trying this:

Dialect.fromCsvFormat(CSVFormat.Predefined.DEFAULT.getFormat());

The error comes from https://github.com/frictionlessdata/datapackage-java/blob/66f3f82793616cc768f97214c8ac5ff4aa825552/src/main/java/io/frictionlessdata/datapackage/Dialect.java#L140

As

format.getQuoteMode()

returns null for some CSVFormats (e.g. DEFAULT or EXCEL because the value will not be set).


Please preserve this line to notify @iSnow (lead of this repository)

iSnow commented 4 years ago

Thanks for bringing this to our attention. It's fixed, and we have a new test for validating the fix (in DialectTest.java):

@Test
@DisplayName("test for https://github.com/frictionlessdata/datapackage-java/issues/33, NPE creating Dialect")
void testIssue33(){
    Dialect dia = Dialect.fromCsvFormat(CSVFormat.DEFAULT);
}