Bugs in WorkflowQuery

"Philipp Hug" <[email protected]>
Newsgroups gmane.comp.java.open-symphony.devel
Message-ID <03b401c30f15$a468fe60$522210ac@chimera>
I found some problems in WorkflowQuery and JDBCWorkflowStore:

1. JDBCWorkflowStore cannot handle queries with null values such as:
    WorkflowQuery(WorkflowQuery.OWNER, WorkflowQuery.CURRENT,
WorkflowQuery.EQUALS, null)
this results in a NPE.

Patch: JDBCWorkflowStore.java
661c661,665
<         right = value.toString();
---
>         if (value != null) {
>             right = "'" + escape(value.toString()) + "'";
>         } else {
>             right = "null";
>         }
663c667
<         return left + oper + "'" + escape(right) + "'";
---
>         return left + oper + right;


2. recursive queries are handled incorrectly:
if the root WorkflowQuery object is an AND/OR/XOR query, qtype is set to
zero.
JDBCWorkflowStore just uses the qtype of the left query:
            if (query.getLeft() != null) {
                qtype = query.getLeft().getType();
but if this query object is also an AND/OR or XOR query it'll use zero as
qtype and
it will build a query that searches in the HISTORY_STEPS table.

Patch:
-> move code from JDBCWorkflStore to WorkflowQuery
-> do recursive search for qtype instead of just going one level down.

WorkflowQuery
diff -r1.1 -r1.2
17c17
<  * @version $Revision: 1.1 $
---
>  * @version $Revision: 1.2 $
84c84,95
<         return type;
---
>         int qtype = type;
>
>         if (qtype == 0) { // then not set, so look in sub queries
>                           // todo: not sure if you would have a query that
would look in both old and new, if so, i'll have to change this - TR
>                           // but then again, why are there redundant
tables in the first place? the data model should probably change
>
>             if (getLeft() != null) {
>                 qtype = getLeft().getType();
>             }
>         }
>
>         return qtype;


philipp



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.