lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stuart Robinson (JIRA)" <>
Subject [Lucene.Net] [jira] [Commented] (LUCENENET-443) SpellChecker finaliser calls close regardless of if closed already
Date Thu, 15 Sep 2011 13:21:10 GMT


Stuart Robinson commented on LUCENENET-443:

Hi Michael, 
my problem with IsClosed being internal is that there's no way to protect yourself from an
exception being thrown from an already closed SpellChecker. If Close() didn't throw an exception
or IsClosed() were public this wouldn't be a problem.

I agree that the fastest thing to do - and most importantly to avoid exceptions being thrown
in the finaliser - would be to amend the finaliser.


> SpellChecker finaliser calls close regardless of if closed already
> ------------------------------------------------------------------
>                 Key: LUCENENET-443
>                 URL:
>             Project: Lucene.Net
>          Issue Type: Improvement
>          Components: Lucene.Net Contrib
>    Affects Versions: Lucene.Net 2.9.2
>            Reporter: Stuart Robinson
>              Labels: lucene, spellcheck, spellchecker
> The SpellChecker Class currently has no publicly visible way of accessing the closed
field. It also calls close in the finaliser killing the process it is in upon GC as this can
throw an exceptin. I propose two changes:
> Change the already existing method "IsClosed()" to public:
>         public bool IsClosed()
>         {
>             return closed;
>         }
> and add a check on this in the finaliser:
>         ~SpellChecker()
>         {
>             if (!IsClosed())
>                 this.Close();
>         }
> Ideally this class should implement IDisposable but I think this would be a bigger job
than this two line change.

This message is automatically generated by JIRA.
For more information on JIRA, see:


View raw message