query.next() throwing NPE

Description

Throws NPE when looping over the query using .next()

<cfscript> news = queryNew("id,title", "integer,varchar"); queryAddRow(news); querySetCell(news, "id", "1"); querySetCell(news, "title", "Dewey defeats Truman"); queryAddRow(news); querySetCell(news, "id", "2"); querySetCell(news, "title", "Men walk on Moon"); queryAddRow(news); querySetCell(news, "id", "3"); querySetCell(news, "title", "Men"); while(news.next()){ writeDump(news); } </cfscript>

Environment

None

Attachments

1
  • 03 Oct 2018, 06:22 am

Activity

Show:

Michael Offner 12 October 2018 at 14:05
Edited

the only way to "fix" this is by adding an addional test that is executed for every iteration what adds addional time spend on every loop done.
the "right" way to use this is as follows

news.beforeFirst(); while(news.next()){ writeDump(news); } news.afterLast();

i have used "" above, because you should not use this methods for multiple reasons:
1. it is slow because Lucee needs to call objects methods via reflection
2. because this is a hidden feature it can disappear at any time without warning.

so better do it like this

loop query=news { }

Pothys - MitrahSoft 3 October 2018 at 08:17

I've added a test case for this ticket & confirmed the issue occurs from lucee 5.2.9.26.

Pull request: https://github.com/lucee/Lucee/pull/584

Won't Fix

Details

Assignee

Reporter

Priority

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Created 3 October 2018 at 06:23
Updated 3 February 2020 at 12:56
Resolved 12 October 2018 at 14:06

Flag notifications