Repository navigation
bound auto-grow of indexed properties in LazyDynaBean and LazyDynaList - #448
Open
rootvector2 wants to merge 1 commit into
Open
rootvector2 wants to merge 1 commit into
rootvector2 wants to merge 1 commit into
Conversation
growIndexedProperty and growList filled an indexed property up to any requested index. the index comes from property expressions, so a single populate key like x[2147483646] made a LazyDynaBean append ~2^31 elements until the heap ran out. limit how many elements one access may add (default 256, configurable with setAutoGrowLimit) and throw IndexOutOfBoundsException past it. appending one element at a time is unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LazyDynaBean.growIndexedPropertygrows an indexed property to whatever index is asked for, filling every slot up to it. The index comes straight from property expressions, soBeanUtils.populate(lazyDynaBean, request.getParameterMap()), the usageLazyDynaBeanis built for, lets one short parameter name decide how much memory the server allocates.LazyDynaList.growListdoes the same forget/set/add, reached throughPropertyUtilsindexed access on any bean property of typeLazyDynaList. Found while reading the auto-grow paths reachable fromDefaultResolverindexes.Reproduced with
BeanUtils.populate(new LazyDynaBean(), Map.of(key, "v"))on-Xmx1g:A 14-byte key exhausts the shared heap, so concurrent requests fail too. With the patch, both large keys fail fast with
IndexOutOfBoundsException, whichget/setalready declare, andx[10]/x[255]behave as before.The bound limits how many elements a single access may add (default 256, the same default Spring's
DataBinderuses for its auto-grow limit), not the total size. Filling a property one element at a time still grows without limit. Callers that legitimately jump far ahead can raise it withsetAutoGrowLimit. The check lives in the two grow methods because every path into them (DynaBean.get/set,PropertyUtils,BeanUtils.populate,List.get/set/add/addAll) ends there.LazyDynaMapinherits theLazyDynaBeanchange.LazyDynaBeanTest.testIndexedAutoGrowLimitandLazyDynaListTest.testAutoGrowLimitcover lists, arrays, thepopulatepath and raising the limit. The behavioral assertions fail on master:set(name, 100000, v)grows instead of throwing, andset(name, Integer.MAX_VALUE, v)on aString[]property throwsNegativeArraySizeException. Defaultmvnis green (1319 tests, rat, checkstyle, japicmp, javadoc).Before you push a pull request, review this list:
mvn; that'smvnon the command line by itself.