[ 
https://issues.apache.org/jira/browse/LUCENE-8292?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16763797#comment-16763797
 ] 

David Smiley commented on LUCENE-8292:
--------------------------------------

Adrien last said:
{quote}In general, we do not delegate methods that have a default 
implementation because the default implementation is correct regardless of what 
the wrapper class does. Overriding these methods in FilterTermsEnum to delegate 
to the wrapped instance would make room for bugs by requiring more methods to 
be overridden for the wrapper to be correct.
{quote}
CC [~simonw] curious about your thoughts too

_In general_ I can see this.  For the case of termState() and 
seekExact(termState) in particular, I don't.  Hypothetically what could go 
wrong if FilterTermsEnum delegated?  When I think of filtering a TermsEnum, I 
think of something that might match a subset of terms from the underlying 
TermsEnum.  The TermsEnum must be positioned to something that matches when 
termState is called.  If seekExact(termState) in the underlying TermsEnum 
receives some termState impl it doesn't identify (isn't of a class it knows), 
then you get the default functional behavior, which is safe.  I'm looking at 
the 6 subclasses of FilterTermsEnum we have in Lucene and I don't see an issue. 
 (Interestingly, 3 of them are in the UnifiedHighlighter).  I checked that 
delegating these two methods doesn't result in test failures too, aside from 
TestFilterLeafReader.testOverrideMethods which expressly tests our policy.

> Fix FilterLeafReader.FilterTermsEnum to delegate all seekExact methods
> ----------------------------------------------------------------------
>
>                 Key: LUCENE-8292
>                 URL: https://issues.apache.org/jira/browse/LUCENE-8292
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: core/index
>    Affects Versions: 7.2.1
>            Reporter: Bruno Roustant
>            Priority: Major
>             Fix For: trunk
>
>         Attachments: 
> 0001-Fix-FilterLeafReader.FilterTermsEnum-to-delegate-see.patch, 
> LUCENE-8292.patch
>
>
> FilterLeafReader#FilterTermsEnum wraps another TermsEnum and delegates many 
> methods.
> It misses some seekExact() methods, thus it is not possible to the delegate 
> to override these methods to have specific behavior (unlike the TermsEnum API 
> which allows that).
> The fix is straightforward: simply override these seekExact() methods and 
> delegate.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to