apache / lucene

Apache Lucene open-source search software
https://lucene.apache.org/
Apache License 2.0
2.63k stars 1.02k forks source link

Closing the DirTaxonomyReader while another thread access the cache can throw NPE [LUCENE-10077] #11115

Open asfimport opened 3 years ago

asfimport commented 3 years ago

When we close a DirectoryTaxonomyReader in doClose, we set the categoryCache to null. But if a thread is next after this doClose call, it will still try to acquire a lock and synchronize on it. This will result in an NPE.

This works well today, because we operate on the assumption that the user will always call doClose after all threads have completed. One suggestion by @mikemccand in this PR was to make categoryCache final and throw an AlreadyClosedException.


Migrated from LUCENE-10077 by Gautam Worah (@gautamworah96), updated Sep 01 2021

asfimport commented 3 years ago

Marc D'Mello (@mdmarshmallow) (migrated from JIRA)

Hi, I would like to work on this issue.

asfimport commented 3 years ago

Marc D'Mello (@mdmarshmallow) (migrated from JIRA)

Since the results in this JIRA suggest that the cache might not be doing as good of a job as we thought it was, it might get removed. I'll get back to this issue in a few days.