Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly set auto-growing array's element #26600

Closed
wants to merge 2 commits into from

Conversation

nullzl
Copy link
Contributor

@nullzl nullzl commented Feb 24, 2021

The implementation of AbstractNestablePropertyAccessor.processKeyedProperty results in a java.lang.IllegalArgumentException: array element type mismatch when the property expression has more than one property key and the last key causes the array to grow automatically.

For example, given a property int[][] multiArray = new int[2][2] and property expression multiArray[1][3], the processKeyedProperty method creates a new array object and assigns it to multiArray; whereas, the new array object should be assigned to multiArray[1].

AbstractNestablePropertyAccessor.processKeyedProperty implementations throw
IllegalArgumentException, when the property expression has more than one
property key and the last key causes array to grow automatically. This commit fix it.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 24, 2021
@sbrannen sbrannen added the in: core Issues in core modules (aop, beans, core, context, expression) label Feb 24, 2021
@sbrannen sbrannen self-assigned this Feb 24, 2021
Copy link
Member

@sbrannen sbrannen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide a unit test that fails before the change and passes after the change -- for example, something analogous to org.springframework.beans.BeanWrapperAutoGrowingTests.getPropertyValueAutoGrowMultiDimensionalArray().

Thanks

@sbrannen sbrannen added the status: waiting-for-feedback We need additional information before we can continue label Feb 24, 2021
@nullzl nullzl marked this pull request as draft February 24, 2021 12:51
@nullzl nullzl marked this pull request as ready for review February 24, 2021 15:46
@nullzl
Copy link
Contributor Author

nullzl commented Feb 24, 2021

Please provide a unit test that fails before the change and passes after the change -- for example, something analogous to org.springframework.beans.BeanWrapperAutoGrowingTests.getPropertyValueAutoGrowMultiDimensionalArray().

Thanks

Thank you very much for your review. I have added a unit test org.springframework.beans.BeanWrapperAutoGrowingTests.setPropertyValueAutoGrowMultiDimensionalArray().

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Feb 24, 2021
@nullzl nullzl requested a review from sbrannen February 24, 2021 16:07
@sbrannen sbrannen added this to the 5.3.5 milestone Feb 24, 2021
@sbrannen sbrannen added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 24, 2021
@sbrannen sbrannen added for: backport-to-5.2.x and removed status: feedback-provided Feedback has been provided labels Feb 25, 2021
@spring-projects-issues spring-projects-issues added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-5.2.x labels Feb 25, 2021
sbrannen added a commit to sbrannen/spring-framework that referenced this pull request Feb 25, 2021
@sbrannen sbrannen closed this in a33eac3 Feb 25, 2021
sbrannen pushed a commit to sbrannen/spring-framework that referenced this pull request Feb 25, 2021
Prior to this commit, the implementation of processKeyedProperty() in
AbstractNestablePropertyAccessor resulted in a
`java.lang.IllegalArgumentException: array element type mismatch` when
the property expression had more than one property key and the last key
should cause the array to grow automatically.

For example, given a property `int[][] multiArray` and property
expression `multiArray[1][3]`, the `processKeyedProperty()` method
created a new array object and assigned it to `multiArray`; whereas,
the new array object should have be assigned to `multiArray[1]`.

This commit fixes this issue.

Closes spring-projectsgh-26600
sbrannen added a commit to sbrannen/spring-framework that referenced this pull request Feb 25, 2021
@sbrannen
Copy link
Member

This has been merged into master in a33eac3, revised in 8baf404, and backported to 5.2.x.

Thanks for catching and fixing this bug!

This was referenced Mar 17, 2021
lxbzmy pushed a commit to lxbzmy/spring-framework that referenced this pull request Mar 26, 2022
Prior to this commit, the implementation of processKeyedProperty() in
AbstractNestablePropertyAccessor resulted in a
`java.lang.IllegalArgumentException: array element type mismatch` when
the property expression had more than one property key and the last key
should cause the array to grow automatically.

For example, given a property `int[][] multiArray` and property
expression `multiArray[1][3]`, the `processKeyedProperty()` method
created a new array object and assigned it to `multiArray`; whereas,
the new array object should have be assigned to `multiArray[1]`.

This commit fixes this issue.

Closes spring-projectsgh-26600
lxbzmy pushed a commit to lxbzmy/spring-framework that referenced this pull request Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants