<< Back to previous view

[NUCCORE-700] Query result not closed if single result taken Created: 20/Apr/11  Updated: 09/May/11  Resolved: 21/Apr/11

Status: Closed
Project: DataNucleus Core
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Guido Anzuoni Assignee: Unassigned
Resolution: Duplicate Votes: 0


 Description   
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();
        }
    }




 Comments   
Comment by Andy Jefferson [ 21/Apr/11 08:12 AM ]
See NUCJPA-125
Comment by Guido Anzuoni [ 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
Comment by Andy Jefferson [ 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.
Comment by Guido Anzuoni [ 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
Generated at Fri Dec 15 11:20:40 CET 2017 using JIRA 4.0#466.