File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change 47
47
*/
48
48
class JsonValueWriter {
49
49
50
- private static final int DEFAULT_MAX_NESTING_DEPTH = 1000 ;
50
+ private static final int DEFAULT_MAX_NESTING_DEPTH = 500 ;
51
51
52
52
private final Appendable out ;
53
53
@@ -160,7 +160,10 @@ private <V> boolean canWriteAsArray(Iterable<?> iterable) {
160
160
*/
161
161
void start (Series series ) {
162
162
if (series != null ) {
163
- validateNestingDepth ();
163
+ int nestingDepth = this .activeSeries .size ();
164
+ Assert .state (nestingDepth <= this .maxNestingDepth ,
165
+ () -> "JSON nesting depth (%s) exceeds maximum depth of %s (current path: %s)"
166
+ .formatted (nestingDepth , this .maxNestingDepth , this .path ));
164
167
this .activeSeries .push (new ActiveSeries (series ));
165
168
append (series .openChar );
166
169
}
@@ -288,13 +291,6 @@ private void writeString(Object value) {
288
291
}
289
292
}
290
293
291
- private void validateNestingDepth () {
292
- if (this .activeSeries .size () > this .maxNestingDepth ) {
293
- throw new IllegalStateException ("JSON nesting depth (%s) exceeds maximum depth of %s (current path: %s)"
294
- .formatted (this .activeSeries .size (), this .maxNestingDepth , this .path ));
295
- }
296
- }
297
-
298
294
private void append (String value ) {
299
295
try {
300
296
this .out .append (value );
You can’t perform that action at this time.
0 commit comments