lucene-java-user mailing list archives

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

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);
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?

Institut für Deutsche Sprache |
Projekt KorAP                 |
Tel. +49-(0)621-43740789      |
Korpusanalyseplattform der nächsten Generation
Next Generation Corpus Analysis Platform

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message