Skip to content

Commit 3712bec

Browse files
authored
CSV: fix issue in setSchema (#481)
1 parent 8dd8b53 commit 3712bec

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
@@ -498,14 +498,13 @@ public void setCodec(ObjectCodec c) {
498498
}
499499

500500
@Override
501-
public void setSchema(FormatSchema schema)
501+
public void setSchema(final FormatSchema schema)
502502
{
503503
if (schema instanceof CsvSchema) {
504504
_schema = (CsvSchema) schema;
505-
String str = _schema.getNullValueString();
506-
_nullValue = str;
505+
_nullValue = _schema.getNullValueString();
507506
} else if (schema == null) {
508-
schema = EMPTY_SCHEMA;
507+
_schema = EMPTY_SCHEMA;
509508
} else {
510509
super.setSchema(schema);
511510
}
@@ -924,7 +923,7 @@ protected void _readHeaderLine() throws IOException {
924923
int newColumnCount = newSchema.size();
925924
if (newColumnCount < 2) { // 1 just because we may get 'empty' header name
926925
String first = (newColumnCount == 0) ? "" : newSchema.columnName(0).trim();
927-
if (first.length() == 0) {
926+
if (first.isEmpty()) {
928927
_reportCsvMappingError("Empty header line: can not bind data");
929928
}
930929
}
@@ -1468,9 +1467,6 @@ protected boolean _isNullValue(String value) {
14681467
if (_cfgEmptyStringAsNull && value.isEmpty()) {
14691468
return true;
14701469
}
1471-
if (_cfgEmptyUnquotedStringAsNull && value.isEmpty() && !_reader.isCurrentTokenQuoted()) {
1472-
return true;
1473-
}
1474-
return false;
1470+
return _cfgEmptyUnquotedStringAsNull && value.isEmpty() && !_reader.isCurrentTokenQuoted();
14751471
}
14761472
}

0 commit comments

Comments
 (0)