|
10 | 10 |
|
11 | 11 | import tools.jackson.core.*; |
12 | 12 | import tools.jackson.core.base.TextualTSFactory; |
13 | | -import tools.jackson.core.exc.StreamConstraintsException; |
14 | 13 | import tools.jackson.core.io.*; |
15 | 14 | import tools.jackson.core.json.async.NonBlockingByteArrayJsonParser; |
16 | 15 | import tools.jackson.core.json.async.NonBlockingByteBufferJsonParser; |
@@ -453,17 +452,17 @@ protected JsonParser _createParser(ObjectReadContext readCtxt, IOContext ioCtxt, |
453 | 452 | DataInput input) |
454 | 453 | throws JacksonException |
455 | 454 | { |
456 | | - // [core#1570] DataInput reads byte-by-byte so we cannot efficiently enforce |
457 | | - // maxDocumentLength. Fail fast if the limit has been configured. |
458 | | - if (_streamReadConstraints.hasMaxDocumentLength()) { |
459 | | - throw new StreamConstraintsException( |
460 | | - "Can not enforce `StreamReadConstraints.getMaxDocumentLength()` limit with `DataInput`-backed parser: " |
461 | | - +"use other input source types, or remove the max-document-length limit"); |
462 | | - } |
463 | 455 | // Also: while we can't do full bootstrapping (due to read-ahead limitations), should |
464 | 456 | // at least handle possible UTF-8 BOM |
465 | 457 | int firstByte = ByteSourceJsonBootstrapper.skipUTF8BOM(input); |
466 | 458 | ByteQuadsCanonicalizer can = _byteSymbolCanonicalizer.makeChildOrPlaceholder(_factoryFeatures); |
| 459 | + // [core#1575]: Support max doc length constraints with separate impl |
| 460 | + if (_streamReadConstraints.hasMaxDocumentLength()) { |
| 461 | + return new UTF8DataInputWithDocLengthJsonParser(readCtxt, ioCtxt, |
| 462 | + readCtxt.getStreamReadFeatures(_streamReadFeatures), |
| 463 | + readCtxt.getFormatReadFeatures(_formatReadFeatures), |
| 464 | + input, can, firstByte); |
| 465 | + } |
467 | 466 | return new UTF8DataInputJsonParser(readCtxt, ioCtxt, |
468 | 467 | readCtxt.getStreamReadFeatures(_streamReadFeatures), |
469 | 468 | readCtxt.getFormatReadFeatures(_formatReadFeatures), |
|
0 commit comments