mirror of https://github.com/apache/openjpa.git
Prevent the end range of a substring from going over the end of the string.
git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@487401 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4e85c5eb84
commit
53614b371f
|
@ -50,8 +50,10 @@ class Substring
|
||||||
Object arg = _args.eval(candidate, orig, ctx, params);
|
Object arg = _args.eval(candidate, orig, ctx, params);
|
||||||
if (arg instanceof Object[]) {
|
if (arg instanceof Object[]) {
|
||||||
Object[] args = (Object[]) arg;
|
Object[] args = (Object[]) arg;
|
||||||
return str.toString().substring(((Number) args[0]).intValue(),
|
int start = ((Number) args[0]).intValue();
|
||||||
((Number) args[1]).intValue());
|
int end = Math.min(((Number) args[1]).intValue(),
|
||||||
|
str.toString().length() - start + 1);
|
||||||
|
return str.toString().substring(start, end);
|
||||||
}
|
}
|
||||||
return str.toString().substring(((Number) arg).intValue());
|
return str.toString().substring(((Number) arg).intValue());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue