You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2016/11/11 18:43:10 UTC
lucene-solr:branch_6x: LUCENE-7547: close the dictionary file so we
don't leak file handles
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6x d8d3d29f9 -> ecff2519b
LUCENE-7547: close the dictionary file so we don't leak file handles
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/ecff2519
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/ecff2519
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/ecff2519
Branch: refs/heads/branch_6x
Commit: ecff2519b830e2436df835635e2395efe86dff1e
Parents: d8d3d29
Author: Mike McCandless <mi...@apache.org>
Authored: Fri Nov 11 13:42:06 2016 -0500
Committer: Mike McCandless <mi...@apache.org>
Committed: Fri Nov 11 13:42:37 2016 -0500
----------------------------------------------------------------------
lucene/CHANGES.txt | 5 +++++
.../analysis/ja/JapaneseTokenizerFactory.java | 17 +++++++++--------
2 files changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ecff2519/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index bfc1b1b..4ad1a21 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -9,6 +9,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-7532: Add back lost codec file format documentation
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ecff2519/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseTokenizerFactory.java
----------------------------------------------------------------------
diff --git a/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseTokenizerFactory.java b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseTokenizerFactory.java
index 99ad61b..844684a 100644
--- a/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseTokenizerFactory.java
+++ b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseTokenizerFactory.java
@@ -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;
}