> The problem with this code is that after the call to getResults(), the
> OQLQuery instance goes out of scope - hence it is marked for garbage
> collection.
this is strange. Are you sure this is the reason? Java objects are
allocated on the heap so it doesn't matter if it goes out of scope or not
as long as there is a reference to it. The garbage collector will not
deallocate an object that has a reference to it.
>
> Unfortunately the finalize() method of the OQLQuery class, closes its
> associated resultset (!)
>
> This means that if the OQLQuery instance is garbage collected before you've
> finished iterating through the resultset, then suddenly in the middle of an
> iteration, your code crashes with a mysterious null-pointer exception
> (intermittently and in different places).
>
> Moral of the story - always keep the OQLQuery and its resultset in the same
> scope.
>
> Moreover, always call close() explicitly on the resultset/query and don't
> rely on garbage collection to close it. Putting code in finalizers is (IMHO)
> rarely justified, and cause all sorts of weird bugs/deadlock etc.
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev