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)
|
||||
|
||||
Bug Fixes
|
||||
|
||||
* LUCENE-7547: JapaneseTokenizerFactory was failing to close the
|
||||
dictionary file it opened (Markus via Mike McCandless)
|
||||
|
||||
Improvements
|
||||
|
||||
* LUCENE-6824: TermAutomatonQuery now rewrites to TermQuery,
|
||||
|
|
|
@ -127,16 +127,17 @@ public class JapaneseTokenizerFactory extends TokenizerFactory implements Resour
|
|||
@Override
|
||||
public void inform(ResourceLoader loader) throws IOException {
|
||||
if (userDictionaryPath != null) {
|
||||
InputStream stream = loader.openResource(userDictionaryPath);
|
||||
String encoding = userDictionaryEncoding;
|
||||
if (encoding == null) {
|
||||
encoding = IOUtils.UTF_8;
|
||||
}
|
||||
CharsetDecoder decoder = Charset.forName(encoding).newDecoder()
|
||||
try (InputStream stream = loader.openResource(userDictionaryPath)) {
|
||||
String encoding = userDictionaryEncoding;
|
||||
if (encoding == null) {
|
||||
encoding = IOUtils.UTF_8;
|
||||
}
|
||||
CharsetDecoder decoder = Charset.forName(encoding).newDecoder()
|
||||
.onMalformedInput(CodingErrorAction.REPORT)
|
||||
.onUnmappableCharacter(CodingErrorAction.REPORT);
|
||||
Reader reader = new InputStreamReader(stream, decoder);
|
||||
userDictionary = UserDictionary.open(reader);
|
||||
Reader reader = new InputStreamReader(stream, decoder);
|
||||
userDictionary = UserDictionary.open(reader);
|
||||
}
|
||||
} else {
|
||||
userDictionary = null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue