lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 7782] New: - query parser does not close TokenStreams returned by Analyzer
Date Sat, 06 Apr 2002 01:01:16 GMT
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: lucene-dev@jakarta.apache.org
        ReportedBy: eric@conveysoftware.com
                CC: eric@conveysoftware.com


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:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>


Mime
View raw message