db-ojb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Geery <geery.and...@doc.state.sc.us>
Subject patch for org.apache.ojb.broker.util.SqlHelper class
Date Tue, 03 Feb 2004 14:18:22 GMT
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: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Mime
View raw message