Skip to content

Commit e51d723

Browse files
pjfanningcowtowncoder
authored andcommitted
CSV: fix issue in setSchema (#481)
1 parent ff5d1d6 commit e51d723

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

csv/src/main/java/com/fasterxml/jackson/dataformat/csv/CsvParser.java

+5-9
Original file line numberDiff line numberDiff line change
@@ -509,14 +509,13 @@ public void setCodec(ObjectCodec c) {
509509
}
510510

511511
@Override
512-
public void setSchema(FormatSchema schema)
512+
public void setSchema(final FormatSchema schema)
513513
{
514514
if (schema instanceof CsvSchema) {
515515
_schema = (CsvSchema) schema;
516-
String str = _schema.getNullValueString();
517-
_nullValue = str;
516+
_nullValue = _schema.getNullValueString();
518517
} else if (schema == null) {
519-
schema = EMPTY_SCHEMA;
518+
_schema = EMPTY_SCHEMA;
520519
} else {
521520
super.setSchema(schema);
522521
}
@@ -931,7 +930,7 @@ protected void _readHeaderLine() throws IOException {
931930
int newColumnCount = newSchema.size();
932931
if (newColumnCount < 2) { // 1 just because we may get 'empty' header name
933932
String first = (newColumnCount == 0) ? "" : newSchema.columnName(0).trim();
934-
if (first.length() == 0) {
933+
if (first.isEmpty()) {
935934
_reportCsvMappingError("Empty header line: can not bind data");
936935
}
937936
}
@@ -1475,9 +1474,6 @@ protected boolean _isNullValue(String value) {
14751474
if (_cfgEmptyStringAsNull && value.isEmpty()) {
14761475
return true;
14771476
}
1478-
if (_cfgEmptyUnquotedStringAsNull && value.isEmpty() && !_reader.isCurrentTokenQuoted()) {
1479-
return true;
1480-
}
1481-
return false;
1477+
return _cfgEmptyUnquotedStringAsNull && value.isEmpty() && !_reader.isCurrentTokenQuoted();
14821478
}
14831479
}

0 commit comments

Comments
 (0)