DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7782>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7782

query parser does not close TokenStreams returned by Analyzer

           Summary: query parser does not close TokenStreams returned by
                    Analyzer
           Product: Lucene
           Version: 1.0.2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: Blocker
          Priority: Other
         Component: QueryParser
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]
                CC: [EMAIL PROTECTED]


The TokenStream class has a close() method which must be called afterthe token stream 
has been exhausted (i.e. next() returns null) torelease underlying resources held by 
the stream, such as a Reader.This method invocation is essential in cases where 
TokenStreams areexpensive to set up and the Analyzer decides to cache them, becausethe 
call to close is how the token stream knows to clean up.The QueryParser violates this 
contract by creating and using TokenStreamsbut not closing them.  The getFieldQuery 
method is an example of this.I suggest rewriting this portion:while (true) {      try 
{        t = source.next();      }      catch (IOException e) {        t = null;      
}      if (t == null)        break;      v.addElement(t.termText());    }as 
follows:try {  Token t = null;  while ((t = source.next()) != null) {    
v.addElement(t.termText());  }} catch (IOException ioe) {  // this should be raised, 
not swallowed as it currently is  // the TokenStream writer may have raised an 
IOException that needs  // to be handled} finally {  source.close(); // must do 
this!}There may be other instances of this problem which also need to have the call to 
TokenStream.close() added.

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to