From d98ca1d91d3487601eb27fd7d14f0b52732f72ba Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Sun, 17 Dec 2006 00:31:48 +0000 Subject: [PATCH] Fixed error in substring range check. git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@487923 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/openjpa/kernel/exps/Substring.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/Substring.java b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/Substring.java index aee66783d..e9fa96f17 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/Substring.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/Substring.java @@ -51,9 +51,9 @@ class Substring if (arg instanceof Object[]) { Object[] args = (Object[]) arg; int start = ((Number) args[0]).intValue(); - int end = Math.min(((Number) args[1]).intValue(), - str.toString().length() - start + 1); - return str.toString().substring(start, end); + int end = ((Number) args[1]).intValue(); + String string = str == null ? "" : str.toString(); + return string.substring(start, Math.min(end, string.length())); } return str.toString().substring(((Number) arg).intValue()); }