Skip to content

Commit fa2ce20

Browse files
committed
Merge branch '2.10' into 2.11
2 parents cc387d7 + d39071a commit fa2ce20

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

csv/src/main/java/com/fasterxml/jackson/dataformat/csv/impl/CsvDecoder.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ public CsvDecoder(CsvParser owner, IOContext ctxt, Reader r, CsvSchema schema,
267267
_inputSource = r;
268268
_textBuffer = textBuffer;
269269
_autoCloseInput = JsonParser.Feature.AUTO_CLOSE_SOURCE.enabledIn(stdFeatures);
270-
final boolean legacy = JsonParser.Feature.ALLOW_YAML_COMMENTS.enabledIn(stdFeatures);
271-
_allowComments = legacy | CsvParser.Feature.ALLOW_COMMENTS.enabledIn(csvFeatures);
270+
final boolean oldComments = JsonParser.Feature.ALLOW_YAML_COMMENTS.enabledIn(stdFeatures);
271+
_allowComments = oldComments | CsvParser.Feature.ALLOW_COMMENTS.enabledIn(csvFeatures);
272272
_trimSpaces = CsvParser.Feature.TRIM_SPACES.enabledIn(csvFeatures);
273273
_skipBlankLines = CsvParser.Feature.SKIP_EMPTY_LINES.enabledIn(csvFeatures);
274274
_inputBuffer = ctxt.allocTokenBuffer();
@@ -284,7 +284,9 @@ public void setSchema(CsvSchema schema)
284284
_separatorChar = schema.getColumnSeparator();
285285
_quoteChar = schema.getQuoteChar();
286286
_escapeChar = schema.getEscapeChar();
287-
_allowComments = _allowComments | schema.allowsComments();
287+
if (!_allowComments) {
288+
_allowComments = schema.allowsComments();
289+
}
288290
int max = Math.max(_separatorChar, _quoteChar);
289291
max = Math.max(max, _escapeChar);
290292
max = Math.max(max, '\r');
@@ -298,6 +300,12 @@ public void setSchema(CsvSchema schema)
298300
public void overrideFormatFeatures(int csvFeatures) {
299301
_trimSpaces = CsvParser.Feature.TRIM_SPACES.enabledIn(csvFeatures);
300302
_skipBlankLines = CsvParser.Feature.SKIP_EMPTY_LINES.enabledIn(csvFeatures);
303+
304+
// 07-Oct-2019, tatu: not 100% accurate, as we have no access to legacy
305+
// setting. But close enough, fixed in 3.0
306+
if (CsvParser.Feature.ALLOW_COMMENTS.enabledIn(csvFeatures)) {
307+
_allowComments = true;
308+
}
301309
}
302310

303311
/*

csv/src/test/java/com/fasterxml/jackson/dataformat/csv/deser/SkipBlankLines15Test.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public void testCsvWithBlankLineAndCommentSkipBlankLinesFeatureEnabledAndAllowCo
9090
.with(CsvParser.Feature.ALLOW_COMMENTS)
9191
.readValue(CSV_WITH_BLANK_LINE_AND_COMMENT);
9292
// blank/empty/comment lines are skipped
93+
9394
assertArrayEquals(expected(
9495
row("1", "xyz"),
9596
row("true", "")

0 commit comments

Comments
 (0)