I recently upgraded from 1.0.rc4 to 1.0.rc5. This broke some code I had written that used the method org.apache.ojb.broker.query.Criteria.addSql(String). The SQL I added was of the form: soundex(value) = soundex(column). This resulted in an java.lang.ArrayIndexOutOfBoundsException being thrown by the org.apache.ojb.broker.util.SqlHelper.splitPath(String) method because the braceBegin variable was greater than the braceEnd variable. In addition to the check that both braceEnd and braceBegin are at least zero, there should be a check that braceEnd is, in fact, bigger than braceBegin.

The patch is below.

Thanks
Andrew

Index: SqlHelper.java
===================================================================
RCS file: /home/cvspublic/db-ojb/src/java/org/apache/ojb/broker/util/SqlHelper.java,v
retrieving revision 1.21
diff -u -r1.21 SqlHelper.java
--- SqlHelper.java 12 Dec 2003 16:30:37 -0000 1.21
+++ SqlHelper.java 3 Feb 2004 14:23:44 -0000
@@ -122,7 +122,7 @@
int braceBegin = aPath.lastIndexOf("(");
int braceEnd = aPath.indexOf(")");


-        if (braceBegin >= 0 && braceEnd >= 0)
+        if (braceBegin >= 0 && braceEnd >= 0 && braceEnd > braceBegin)
        {
                int colBegin;
                int colEnd;




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to