-
Couldn't load subscription status.
- Fork 38.8k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: regressionA bug that is also a regressionA bug that is also a regression
Milestone
Description
Trying to migrate from Spring Famework 6.1 to 6.2, I get an exception in Spring's validation code, located in the DataBinder::getIndexes method.
When I look at the code it looks like a bug.
@Nullable
private static SortedSet<Integer> getIndexes(String paramPath, ValueResolver valueResolver) {
SortedSet<Integer> indexes = null;
for (String name : valueResolver.getNames()) {
if (name.startsWith(paramPath + "[")) {
int endIndex = name.indexOf(']', paramPath.length() + 2); // returns -1
String rawIndex = name.substring(paramPath.length() + 1, endIndex); // throws java.lang.StringIndexOutOfBoundsException
int index = Integer.parseInt(rawIndex);
indexes = (indexes != null ? indexes : new TreeSet<>());
indexes.add(index);
}
}
return indexes;
}In my case, name contains someField[], so paramPath.length() + 2 points outside the string. I think that paramPath.length() + 1 should be used instead.
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: regressionA bug that is also a regressionA bug that is also a regression