[
https://issues.apache.org/jira/browse/LUCENE-776?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12464610
]
Nicolas Lalevée commented on LUCENE-776:
----------------------------------------
I think you've describe the problem completely Michael. When submitting this
issue, I thought that the weak object in a WeakHashMap was the value of the
map. So it appears that it is not done for that. About your last though, it is
accurate because I think that most of the time, Lucene-based application are
opening their directories at the same place.
My turn of though : we might have an issue if the table holds some reference
that are not yet GCed. A directory is closed, "manually" cleaned up, and
reopened with a different lock factory : this will fail with the IOException
because of the still cached directory, conflicting because of its different
lock factory. So the current design might be the best one in fact.
> Use WeakHashMap instead of Hashtable in FSDirectory
> ---------------------------------------------------
>
> Key: LUCENE-776
> URL: https://issues.apache.org/jira/browse/LUCENE-776
> Project: Lucene - Java
> Issue Type: Improvement
> Affects Versions: 2.0.0
> Reporter: Nicolas Lalevée
> Assigned To: Michael McCandless
> Priority: Trivial
>
> I was just reading the FSDirectory java code, then I found this :
> /** This cache of directories ensures that there is a unique Directory
> * instance per path, so that synchronization on the Directory can be used
> to
> * synchronize access between readers and writers.
> *
> * This should be a WeakHashMap, so that entries can be GC'd, but that would
> * require Java 1.2. Instead we use refcounts...
> */
> private static final Hashtable DIRECTORIES = new Hashtable();
> Since Lucene is now requiring at least 1.2 (for ThreadLocal for instance,
> which is using BTW some WeakHashMap), maybe it is time to change ?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]