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

SpEL's Indexer.setArrayElement() incorrectly requests conversion to wrapper instead of primitive #32147

Closed
sbrannen opened this issue Jan 28, 2024 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@sbrannen
Copy link
Member

The setArrayElement(...) method in SpEL's Indexer incorrectly requests conversion to wrappers instead of primitives when setting an element in a primitive array.

See the associated disabled test:

@Disabled("Disabled due to bug in Indexer.setArrayElement() regarding primitive/wrapper types")
@Test
void setArrayElementToPrimitiveFromEmptyCollectionFails() {
List<Object> emptyList = List.of();
// TODO These fail because CollectionToObjectConverter returns null.
// It currently throws: java.lang.IllegalStateException: Null conversion result for index [[]].
// Whereas, it should throw a SpelEvaluationException.
setValueAndExpectError("arrayContainer.booleans[1]", emptyList);
setValueAndExpectError("arrayContainer.chars[1]", emptyList);
setValueAndExpectError("arrayContainer.shorts[1]", emptyList);
setValueAndExpectError("arrayContainer.bytes[1]", emptyList);
setValueAndExpectError("arrayContainer.ints[1]", emptyList);
setValueAndExpectError("arrayContainer.longs[1]", emptyList);
setValueAndExpectError("arrayContainer.floats[1]", emptyList);
setValueAndExpectError("arrayContainer.doubles[1]", emptyList);
}

@sbrannen sbrannen added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 28, 2024
@sbrannen sbrannen added this to the 6.1.4 milestone Jan 28, 2024
@sbrannen sbrannen self-assigned this Jan 28, 2024
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) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant