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 4747 */
4848class JsonValueWriter {
4949
50- private static final int DEFAULT_MAX_NESTING_DEPTH = 1000 ;
50+ private static final int DEFAULT_MAX_NESTING_DEPTH = 500 ;
5151
5252 private final Appendable out ;
5353
@@ -160,7 +160,10 @@ private <V> boolean canWriteAsArray(Iterable<?> iterable) {
160160 */
161161 void start (Series series ) {
162162 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 ));
164167 this .activeSeries .push (new ActiveSeries (series ));
165168 append (series .openChar );
166169 }
@@ -288,13 +291,6 @@ private void writeString(Object value) {
288291 }
289292 }
290293
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-
298294 private void append (String value ) {
299295 try {
300296 this .out .append (value );
You can’t perform that action at this time.
0 commit comments