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

Uwe Schindler edited comment on LUCENE-3456 at 9/25/11 9:21 AM:
----------------------------------------------------------------

I have some idea how to assert this is tests (now that 
Analyzer.(reuseable)tokenStream is final everywhere):
We can wrap the TokenStream reaturned by those two methods in Analyzer using a 
AssertingTokenFilter that simply tracks in its methods the correct usage of 
reset() [throw AssertionFailed if missing], increment(), end(), close() [this 
last one is hard to track].

The idea is:
If assertions are enabled, the tokenstream-returning methods in Analyzer.java 
should check the desiredAssertionStatus of this' class and wrap the TokenStream 
using that TokenFilter described before. If a consumer then forgets to call any 
of these methods oir does this in wrong order, an AssertionError is thrown.

I could hack something together (yes, it is a hack).

      was (Author: thetaphi):
    I have some idea how to assert this is tests (now that 
Analyzer.(reuseable)tokenStream is final everywhere):
We can wrap the TokenStream reaturned by those two methods in TokenStream using 
a AssertingTokenFilter that simply tracks in its methods the correct usage of 
reset() [throw AssertionFailed if missing], increment(), end(), close() [this 
last one is hard to track].

The idea is:
If assertions are enabled, the tokenstream-returning methods in Analyzer.java 
should check the desiredAssertionStatus of this' class and wrap the TokenStream 
using that TokenFilter described before. If a consumer then forgets to call any 
of these methods oir does this in wrong order, an AssertionError is thrown.

I could hack something together (yes, it is a hack).
  
> Analysis Consumers should end and close any TokenStreams
> --------------------------------------------------------
>
>                 Key: LUCENE-3456
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3456
>             Project: Lucene - Java
>          Issue Type: Sub-task
>            Reporter: Chris Male
>
> While converting consumers over to using reusableTokenStream, I notice many 
> don't call end() or close() on TokenStreams.
> Even if they are test TSs only created once, we should follow the defined 
> usage pattern.

--
This message is automatically generated by JIRA.
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]

Reply via email to