lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carsten Schnober <schno...@ids-mannheim.de>
Subject Potential Resource Leak warning in Analyer.createComponents()
Date Wed, 21 Nov 2012 13:50:37 GMT
Hi,
I use a custom analyzer and tokenizer. The analyzer is very basic and it
merely comprises the method createComponents():

-------------------------------------------------------------
@Override
protected TokenStreamComponents createComponents(String fieldName,
Reader reader) {
  return new TokenStreamComponents(new KoraTokenizer(reader));
}
-------------------------------------------------------------

Eclipse gives me a warning though "potential resource leak" because the
tokenizer is never closed. This is clearly true but is it not desirable
either, is it?
To get rid of the warning, I had experimentally changed the method to this:

Tokenizer source = new KoraTokenizer(reader);
TokenStreamComponents ts = new TokenStreamComponents(source);
source.close();
return ts;

This yields what I had expected, namely a null TokenStream during
analysis. So regarding the results, I think the initial version is
right, but I am suspicious against the resource leak warning. How
serious is it?
Best,
Carsten


-- 
Institut für Deutsche Sprache | http://www.ids-mannheim.de
Projekt KorAP                 | http://korap.ids-mannheim.de
Tel. +49-(0)621-43740789      | schnober@ids-mannheim.de
Korpusanalyseplattform der nächsten Generation
Next Generation Corpus Analysis Platform

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message