mirror of https://github.com/apache/lucene.git
LUCENE-7547: close the dictionary file so we don't leak file handles
This commit is contained in:
parent
77605fe7b7
commit
bd6c0523c2
|
@ -60,6 +60,11 @@ New features
|
||||||
|
|
||||||
* LUCENE-5867: Added BooleanSimilarity. (Robert Muir, Adrien Grand)
|
* LUCENE-5867: Added BooleanSimilarity. (Robert Muir, Adrien Grand)
|
||||||
|
|
||||||
|
Bug Fixes
|
||||||
|
|
||||||
|
* LUCENE-7547: JapaneseTokenizerFactory was failing to close the
|
||||||
|
dictionary file it opened (Markus via Mike McCandless)
|
||||||
|
|
||||||
Improvements
|
Improvements
|
||||||
|
|
||||||
* LUCENE-6824: TermAutomatonQuery now rewrites to TermQuery,
|
* LUCENE-6824: TermAutomatonQuery now rewrites to TermQuery,
|
||||||
|
|
|
@ -127,16 +127,17 @@ public class JapaneseTokenizerFactory extends TokenizerFactory implements Resour
|
||||||
@Override
|
@Override
|
||||||
public void inform(ResourceLoader loader) throws IOException {
|
public void inform(ResourceLoader loader) throws IOException {
|
||||||
if (userDictionaryPath != null) {
|
if (userDictionaryPath != null) {
|
||||||
InputStream stream = loader.openResource(userDictionaryPath);
|
try (InputStream stream = loader.openResource(userDictionaryPath)) {
|
||||||
String encoding = userDictionaryEncoding;
|
String encoding = userDictionaryEncoding;
|
||||||
if (encoding == null) {
|
if (encoding == null) {
|
||||||
encoding = IOUtils.UTF_8;
|
encoding = IOUtils.UTF_8;
|
||||||
}
|
}
|
||||||
CharsetDecoder decoder = Charset.forName(encoding).newDecoder()
|
CharsetDecoder decoder = Charset.forName(encoding).newDecoder()
|
||||||
.onMalformedInput(CodingErrorAction.REPORT)
|
.onMalformedInput(CodingErrorAction.REPORT)
|
||||||
.onUnmappableCharacter(CodingErrorAction.REPORT);
|
.onUnmappableCharacter(CodingErrorAction.REPORT);
|
||||||
Reader reader = new InputStreamReader(stream, decoder);
|
Reader reader = new InputStreamReader(stream, decoder);
|
||||||
userDictionary = UserDictionary.open(reader);
|
userDictionary = UserDictionary.open(reader);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
userDictionary = null;
|
userDictionary = null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue