You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Andrew Geery <ge...@doc.state.sc.us> on 2004/02/03 15:18:22 UTC
patch for org.apache.ojb.broker.util.SqlHelper class
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
Re: patch for org.apache.ojb.broker.util.SqlHelper class
Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi andrew,
thanks for the patch. i commited the fix to the repository.
jakob
Andrew Geery wrote:
> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org