Skip to content

Add a configurable limit for maximum nesting depth in property paths #37252

Description

@sbrannen

Overview

AbstractNestablePropertyAccessor currently resolves nested property paths such as a.b.c.d recursively, one recursive call per path segment and with no limit on depth. Against a type with deeply nested structures, a sufficiently long path can exhaust the stack with a StackOverflowError and no useful diagnostics.

Thanks to @Banh-Bao-080899 for raising this and suggesting a nesting-depth limit, similar to what we did for SpEL in #36723. The goal is to track nesting depth while resolving a property path and then fail fast with a descriptive exception if a configurable limit is exceeded, rather than recursing until the stack overflows.

NOTE: This issue is assigned and therefore not suitable for community contributions.

Implementation Ideas

  • Add a nesting-depth counter in AbstractNestablePropertyAccessor.
  • Throw a descriptive exception (e.g., InvalidPropertyException) if the limit is exceeded.
  • Expose the limit as a configurable property, analogous to autoGrowCollectionLimit on ConfigurablePropertyAccessor, with a sensible default.
  • Apply regardless of autoGrowNestedPaths, since resolving an existing deep object graph recurses the same way as auto-growing one.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions