MMapDirectory not designed for inheritance [LUCENE-2799]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
How to reproduce
Try to inherit from MMapDirectory to change the openInput logic (open files from different directories).
Expected result:
Inherit from MMapDirectory, overwrite the one method, done.
Actual result:
It's impossible to overwrite the method as the inner classes would be missing. It's impossible to fork the inner classes as they depend on a final method with default visibility (cleanMapping).
It turns out to be the easiest option to completely for the code and replace just the method in question.
Possible fix:
Change the visibility of most members and subtypes to be at least protected and avoid the default visibility.
---
Migrated from [LUCENE-2799](https://issues.apache.org/jira/browse/LUCENE-2799) by René Treffer
Contributor guide
Research direction
Start by inspecting MMapDirectory and its openInput method, inner classes, and cleanMapping member. Trace which visibility and final-method constraints prevent subclassing, then define the smallest access changes that let a subclass override openInput without copying the inner classes. Done means the inheritance use case described in the issue is possible without forking the implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- search
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100