mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +00:00
Prior to this commit, the List branch in AbstractNestablePropertyAccessor's getPropertyValue() method called list.get(index) unconditionally after invoking growCollectionIfNecessary(), which implicitly relied on the list throwing an IndexOutOfBoundsException for out-of-range access. Such an exception is caught downstream and wrapped as an InvalidPropertyException; however, any List implementation whose get() method allocates elements on demand rather than throwing an IndexOutOfBoundsException could bypass that check. This behavior was also inconsistent with the Collection/Iterable branch in the same method, which already performs an explicit `index >= collection.size()` bounds check before attempting element access. To address that, this commit aligns the List branch with the Collection/Iterable branch by adding an explicit `index < 0 || index >= list.size()` check immediately after the auto-grow attempt. If the index remains out of bounds after growCollectionIfNecessary() runs – for example, because growth was capped by autoGrowCollectionLimit or auto-growing was disabled – an InvalidPropertyException is now thrown rather than delegating to list.get() which may or may not throw an exception. Closes gh-37036