15
15
* @since 2.16
16
16
*/
17
17
public class ErrorReportConfiguration
18
- implements Serializable {
18
+ implements Serializable
19
+ {
19
20
private static final long serialVersionUID = 1L ;
20
21
21
22
/**
@@ -46,6 +47,22 @@ public class ErrorReportConfiguration
46
47
private static ErrorReportConfiguration DEFAULT =
47
48
new ErrorReportConfiguration (DEFAULT_MAX_ERROR_TOKEN_LENGTH , DEFAULT_MAX_RAW_CONTENT_LENGTH );
48
49
50
+ /**
51
+ * Override the default ErrorReportConfiguration. These defaults are only used when {@link JsonFactory}
52
+ * instances are not configured with their own ErrorReportConfiguration.
53
+ * <p>
54
+ * Library maintainers should not set this as it will affect other code that uses Jackson.
55
+ * Library maintainers who want to configure ErrorReportConfiguration for the Jackson usage within their
56
+ * lib should create <code>ObjectMapper</code> instances that have a {@link JsonFactory} instance with
57
+ * the required ErrorReportConfiguration.
58
+ * <p>
59
+ * This method is meant for users delivering applications. If they use this, they set it when they start
60
+ * their application to avoid having other code initialize their mappers before the defaults are overridden.
61
+ *
62
+ * @param errorReportConfiguration new default for ErrorReportConfiguration (a null value will reset to built-in default)
63
+ * @see #defaults()
64
+ * @see #builder()
65
+ */
49
66
public static void overrideDefaultErrorReportConfiguration (final ErrorReportConfiguration errorReportConfiguration ) {
50
67
if (errorReportConfiguration == null ) {
51
68
DEFAULT = new ErrorReportConfiguration (DEFAULT_MAX_ERROR_TOKEN_LENGTH , DEFAULT_MAX_RAW_CONTENT_LENGTH );
@@ -78,7 +95,7 @@ public Builder maxErrorTokenLength(final int maxErrorTokenLength) {
78
95
/**
79
96
*
80
97
* @see ErrorReportConfiguration#_maxRawContentLength
81
- * @return This factory instance (to allow call chaining)
98
+ * @return This builder instance (to allow call chaining)
82
99
*/
83
100
public Builder maxRawContentLength (final int maxRawContentLength ) {
84
101
validateMaxRawContentLength (maxRawContentLength );
@@ -129,8 +146,7 @@ public static ErrorReportConfiguration defaults() {
129
146
}
130
147
131
148
/**
132
- * @return New {@link Builder} initialized with settings of configuration
133
- * instance
149
+ * @return New {@link Builder} initialized with settings of configuration instance
134
150
*/
135
151
public Builder rebuild () {
136
152
return new Builder (this );
@@ -156,7 +172,7 @@ public int getMaxErrorTokenLength() {
156
172
* Accessor for {@link #_maxRawContentLength}
157
173
*
158
174
* @return Maximum length of token to include in error messages
159
- * @see Builder#maxRawContentLength
175
+ * @see Builder#maxRawContentLength(int)
160
176
*/
161
177
public int getMaxRawContentLength () {
162
178
return _maxRawContentLength ;
@@ -174,14 +190,14 @@ public int getMaxRawContentLength() {
174
190
*
175
191
* @param maxErrorTokenLength Maximum length of token to include in error messages
176
192
*/
177
- private static void validateMaxErrorTokenLength (int maxErrorTokenLength ) throws IllegalArgumentException {
193
+ static void validateMaxErrorTokenLength (int maxErrorTokenLength ) throws IllegalArgumentException {
178
194
if (maxErrorTokenLength < 0 ) {
179
195
throw new IllegalArgumentException (
180
196
String .format ("Value of maxErrorTokenLength (%d) cannot be negative" , maxErrorTokenLength ));
181
197
}
182
198
}
183
199
184
- private static void validateMaxRawContentLength (int maxRawContentLength ) {
200
+ static void validateMaxRawContentLength (int maxRawContentLength ) {
185
201
if (maxRawContentLength < 0 ) {
186
202
throw new IllegalArgumentException (
187
203
String .format ("Value of maxRawContentLength (%d) cannot be negative" , maxRawContentLength ));
0 commit comments