It's all about the answers!

Ask a question

Getting exception on IQueryResult.hasNext() method


Joe Celi (1389) | asked Jun 18 '13, 6:42 p.m.
I am making a query to the JTS for work items that were modified after a specific time.  The query works fine if there are work items that meet that criteria.  If there are no work items modified after the provided time then the following method call generates an exception

//
        // This method was created to address the strange problem where the
        // hasNext method is generating an exception when the query did
        // not yield any results.
        //
        private boolean hasNextSafe(IQueryResult<IResolvedResult<IWorkItem>> queried)
        {
            //
            // The queried.hasNext() method is generating an exception when the result is empty, EVEN though the
            // total count above shows there there are results. 
            //
            boolean fContinue = false;
            try
            {
                fContinue = queried.hasNext(null);
            }
            catch(Exception e)
            {
                System.out.println("RTCActionPerformer::hasNextSafe - queried.hasNext generated an exception");
                fContinue = false;
            }
            return fContinue;
           
        } // end of the hasNextSafe method

In the case where there are no work items returned ... the following code seems to yield the results of the previous query ...

ResultSize rs = queried.getResultSize(null);
int iTotal = rs.getTotal();
System.out.println("RTCActionPerformer::processArtifact - " + iTotal + " work items returned");

3 answers



permanent link
Ralph Schoon (59.7k23643) | answered Jun 19 '13, 4:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I am not sure why you get that. I have never seen this in the past. The code described here works for me: http://rsjazz.wordpress.com/2012/10/29/using-work-item-queris-for-automation/

permanent link
Joe Celi (1389) | answered Jun 19 '13, 8:07 a.m.
Ralph - thanks for the quick response and pointer.  Looks like a great article and just what I am looking for.  I did not see a link to download the full source code?  Is that available?

Comments
Ralph Schoon commented Jun 19 '13, 8:21 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Hi Joe, I did not publish the code yet. but you should be able to just cut and paste from the blog. I am still in the process of publishing to https://hub.jazz.net/project/rschoon/Jazz%20In%20Flight but this code is not yet up. I have to do some clean up first.


permanent link
Joe Celi (1389) | answered Jun 19 '13, 8:09 a.m.
Ralph - by the way, I have a hunch that maybe there is something that I need to do to close out the previous query that maybe I am not doing.  In the case where I get the exception I am seeing somethings that were clearly from the previous query.

ResultSize rs = queried.getResultSize(null);
int iTotal = rs.getTotal();
System.out.println("RTCActionPerformer::processArtifact - " + iTotal + " work items returned");

Thanks again for your help.

Joe

Your answer


Register or to post your answer.