@@ -267,8 +267,8 @@ public CsvDecoder(CsvParser owner, IOContext ctxt, Reader r, CsvSchema schema,
267
267
_inputSource = r ;
268
268
_textBuffer = textBuffer ;
269
269
_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 );
272
272
_trimSpaces = CsvParser .Feature .TRIM_SPACES .enabledIn (csvFeatures );
273
273
_skipBlankLines = CsvParser .Feature .SKIP_EMPTY_LINES .enabledIn (csvFeatures );
274
274
_inputBuffer = ctxt .allocTokenBuffer ();
@@ -284,7 +284,9 @@ public void setSchema(CsvSchema schema)
284
284
_separatorChar = schema .getColumnSeparator ();
285
285
_quoteChar = schema .getQuoteChar ();
286
286
_escapeChar = schema .getEscapeChar ();
287
- _allowComments = _allowComments | schema .allowsComments ();
287
+ if (!_allowComments ) {
288
+ _allowComments = schema .allowsComments ();
289
+ }
288
290
int max = Math .max (_separatorChar , _quoteChar );
289
291
max = Math .max (max , _escapeChar );
290
292
max = Math .max (max , '\r' );
@@ -298,6 +300,12 @@ public void setSchema(CsvSchema schema)
298
300
public void overrideFormatFeatures (int csvFeatures ) {
299
301
_trimSpaces = CsvParser .Feature .TRIM_SPACES .enabledIn (csvFeatures );
300
302
_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
+ }
301
309
}
302
310
303
311
/*
0 commit comments