@@ -284,6 +284,14 @@ public static int collectDefaults() {
284
284
*/
285
285
protected StreamReadConstraints _streamReadConstraints ;
286
286
287
+ /**
288
+ * Container for configuration values used when handling errorneous token inputs.
289
+ *
290
+ * @see ErrorReportConfiguration
291
+ * @since 2.16
292
+ */
293
+ protected ErrorReportConfiguration _errorReportConfiguration ;
294
+
287
295
/**
288
296
* Write constraints to use for {@link JsonGenerator}s constructed using
289
297
* this factory.
@@ -361,6 +369,7 @@ public JsonFactory(ObjectCodec oc) {
361
369
_quoteChar = DEFAULT_QUOTE_CHAR ;
362
370
_streamReadConstraints = StreamReadConstraints .defaults ();
363
371
_streamWriteConstraints = StreamWriteConstraints .defaults ();
372
+ _errorReportConfiguration = ErrorReportConfiguration .defaults ();
364
373
_generatorDecorators = null ;
365
374
}
366
375
@@ -385,6 +394,7 @@ protected JsonFactory(JsonFactory src, ObjectCodec codec)
385
394
_generatorDecorators = _copy (src ._generatorDecorators );
386
395
_streamReadConstraints = Objects .requireNonNull (src ._streamReadConstraints );
387
396
_streamWriteConstraints = Objects .requireNonNull (src ._streamWriteConstraints );
397
+ _errorReportConfiguration = Objects .requireNonNull (src ._errorReportConfiguration );
388
398
389
399
// JSON-specific
390
400
_characterEscapes = src ._characterEscapes ;
@@ -412,6 +422,7 @@ public JsonFactory(JsonFactoryBuilder b) {
412
422
_generatorDecorators = _copy (b ._generatorDecorators );
413
423
_streamReadConstraints = Objects .requireNonNull (b ._streamReadConstraints );
414
424
_streamWriteConstraints = Objects .requireNonNull (b ._streamWriteConstraints );
425
+ _errorReportConfiguration = Objects .requireNonNull (b ._errorReportConfiguration );
415
426
416
427
// JSON-specific
417
428
_characterEscapes = b ._characterEscapes ;
@@ -439,6 +450,7 @@ protected JsonFactory(TSFBuilder<?,?> b, boolean bogus) {
439
450
_generatorDecorators = _copy (b ._generatorDecorators );
440
451
_streamReadConstraints = Objects .requireNonNull (b ._streamReadConstraints );
441
452
_streamWriteConstraints = Objects .requireNonNull (b ._streamWriteConstraints );
453
+ _errorReportConfiguration = Objects .requireNonNull (b ._errorReportConfiguration );
442
454
443
455
// JSON-specific: need to assign even if not really used
444
456
_characterEscapes = null ;
@@ -838,6 +850,26 @@ public JsonFactory setStreamReadConstraints(StreamReadConstraints src) {
838
850
return this ;
839
851
}
840
852
853
+ /**
854
+ * Method for overriding {@link ErrorReportConfiguration} defined for
855
+ * this factory.
856
+ *<p>
857
+ * NOTE: the preferred way to set constraints is by using
858
+ * {@link JsonFactoryBuilder#errorReportConfiguration}: this method is only
859
+ * provided to support older non-builder-based construction.
860
+ * In Jackson 3.x this method will not be available.
861
+ *
862
+ * @param src Configuration
863
+ *
864
+ * @return This factory instance (to allow call chaining)
865
+ *
866
+ * @since 2.16
867
+ */
868
+ public JsonFactory setErrorReportConfiguration (ErrorReportConfiguration src ) {
869
+ _errorReportConfiguration = Objects .requireNonNull (src , "Cannot pass null ErrorReportConfiguration" );;
870
+ return this ;
871
+ }
872
+
841
873
/**
842
874
* Method for overriding {@link StreamWriteConstraints} defined for
843
875
* this factory.
@@ -2112,7 +2144,7 @@ protected IOContext _createContext(ContentReference contentRef, boolean resource
2112
2144
if (contentRef == null ) {
2113
2145
contentRef = ContentReference .unknown ();
2114
2146
}
2115
- return new IOContext (_streamReadConstraints , _streamWriteConstraints ,
2147
+ return new IOContext (_streamReadConstraints , _streamWriteConstraints , _errorReportConfiguration ,
2116
2148
_getBufferRecycler (), contentRef , resourceManaged );
2117
2149
}
2118
2150
@@ -2128,7 +2160,7 @@ protected IOContext _createContext(ContentReference contentRef, boolean resource
2128
2160
*/
2129
2161
@ Deprecated // @since 2.13
2130
2162
protected IOContext _createContext (Object rawContentRef , boolean resourceManaged ) {
2131
- return new IOContext (_streamReadConstraints , _streamWriteConstraints ,
2163
+ return new IOContext (_streamReadConstraints , _streamWriteConstraints , _errorReportConfiguration ,
2132
2164
_getBufferRecycler (),
2133
2165
_createContentReference (rawContentRef ),
2134
2166
resourceManaged );
@@ -2147,7 +2179,7 @@ protected IOContext _createContext(Object rawContentRef, boolean resourceManaged
2147
2179
protected IOContext _createNonBlockingContext (Object srcRef ) {
2148
2180
// [jackson-core#479]: allow recycling for non-blocking parser again
2149
2181
// now that access is thread-safe
2150
- return new IOContext (_streamReadConstraints , _streamWriteConstraints ,
2182
+ return new IOContext (_streamReadConstraints , _streamWriteConstraints , _errorReportConfiguration ,
2151
2183
_getBufferRecycler (),
2152
2184
_createContentReference (srcRef ),
2153
2185
false );
@@ -2168,7 +2200,7 @@ protected IOContext _createNonBlockingContext(Object srcRef) {
2168
2200
protected ContentReference _createContentReference (Object contentAccessor ) {
2169
2201
// 21-Mar-2021, tatu: For now assume "canHandleBinaryNatively()" is reliable
2170
2202
// indicator of textual vs binary format:
2171
- return ContentReference .construct (!canHandleBinaryNatively (), contentAccessor );
2203
+ return ContentReference .construct (!canHandleBinaryNatively (), contentAccessor , _errorReportConfiguration );
2172
2204
}
2173
2205
2174
2206
/**
@@ -2192,7 +2224,7 @@ protected ContentReference _createContentReference(Object contentAccessor,
2192
2224
// 21-Mar-2021, tatu: For now assume "canHandleBinaryNatively()" is reliable
2193
2225
// indicator of textual vs binary format:
2194
2226
return ContentReference .construct (!canHandleBinaryNatively (),
2195
- contentAccessor , offset , length );
2227
+ contentAccessor , offset , length , _errorReportConfiguration );
2196
2228
}
2197
2229
2198
2230
/*
0 commit comments