Issue Details (XML | Word | Printable)

Key: NUCCORE-700
Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: Major Major
Assignee: Unassigned
Reporter: Guido Anzuoni
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus Core

Query result not closed if single result taken

Created: 20/Apr/11 07:53 PM   Updated: 09/May/11 09:58 AM   Resolved: 21/Apr/11 08:12 AM
Component/s: None
Affects Version/s: None
Fix Version/s: None


 Description  « Hide
The close() methog in org.datanucleus.store.query.Query


    public void close(Object queryResult)
    {
        if (queryResult != null && queryResult instanceof QueryResult && queryResults != null)
        {
            // important to remove result first before closing it, as its hashCode() may
            // change after closing so the queryResults HashSet won't find it anymore and
            // consequently won't remove it (see AbstractQueryResult.hashCode())
            queryResults.remove(queryResult);
            ((QueryResult)queryResult).close();
        }
    }

does not close se query result in JPA case because queryResults member is null in that case

the method should become:
    public void close(Object queryResult)
    {
        if (queryResult != null && queryResult instanceof QueryResult)
        {
            // important to remove result first before closing it, as its hashCode() may
            // change after closing so the queryResults HashSet won't find it anymore and
            // consequently won't remove it (see AbstractQueryResult.hashCode())
            if (queryResults != null)
            {
                queryResults.remove(queryResult);
            }
            ((QueryResult)queryResult).close();
        }
    }




Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 21/Apr/11 08:12 AM

Guido Anzuoni added a comment - 21/Apr/11 08:44 AM
The problem is at line 1785 the result is closed because we return the data rather then the result, so there
is no way to remove the QueryResult from the listener of the managed connection (see line 618 of JPQLQuery) .
Now you can even change line 1785 to simply
qr.close();

This problem maybe applies even to find() method and the above should fix it as well

Andy Jefferson added a comment - 21/Apr/11 09:23 AM
The point is that any "bug" has to be against a released version; there is no released version that this applies to. The change in NUCJPA-125 is what is related, and SVN trunk has all changes I can see as necessary.

Guido Anzuoni added a comment - 21/Apr/11 11:45 AM
Yes I forgot to set m4 as affected release.
Anyway I have seen that NUCJPA-125 was closed on 8/4 and not modified and I've not seen today's SVN changelog.
Sorry for that