Disable this warning, your workaround is worse than the warning. ----- Uwe Schindler H.-H.-Meier-Allee 63, D-28213 Bremen http://www.thetaphi.de eMail: u...@thetaphi.de
> -----Original Message----- > From: Carsten Schnober [mailto:schno...@ids-mannheim.de] > Sent: Wednesday, November 21, 2012 2:51 PM > To: java-user > Subject: Potential Resource Leak warning in Analyer.createComponents() > > 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 | schno...@ids-mannheim.de > Korpusanalyseplattform der nächsten Generation Next Generation Corpus > Analysis Platform > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org