Avoid ArrayIndexOutOfBoundsException in SpEL's Indexer
When index == arrayLength, the array index is also out of bounds. For this scenario, a SpelEvaluationException should be thrown instead of ArrayIndexOutOfBoundsException. Closes gh-23658
This commit is contained in:
@@ -439,7 +439,7 @@ public class Indexer extends SpelNodeImpl {
|
||||
}
|
||||
|
||||
private void checkAccess(int arrayLength, int index) throws SpelEvaluationException {
|
||||
if (index > arrayLength) {
|
||||
if (index >= arrayLength) {
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessage.ARRAY_INDEX_OUT_OF_BOUNDS,
|
||||
arrayLength, index);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user