openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mprud...@apache.org
Subject svn commit: r487923 - /incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/Substring.java
Date Sun, 17 Dec 2006 00:31:48 GMT
Author: mprudhom
Date: Sat Dec 16 16:31:48 2006
New Revision: 487923

URL: http://svn.apache.org/viewvc?view=rev&rev=487923
Log:
Fixed error in substring range check.

Modified:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/Substring.java

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/Substring.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/Substring.java?view=diff&rev=487923&r1=487922&r2=487923
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/Substring.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/Substring.java
Sat Dec 16 16:31:48 2006
@@ -51,9 +51,9 @@
         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());
     }



Mime
View raw message