LUCENE-6949: fix (potential) resource leak in SynonymFilterFactory (https://scan.coverity.com/projects/5620 CID 120656)

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1722856 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Christine Poerschke 2016-01-04 12:19:38 +00:00
parent 3a29f0ebe1
commit 7ba2b5d7d8
2 changed files with 7 additions and 1 deletions

View File

@ -214,6 +214,10 @@ Other
* LUCENE-6945: factor out TestCorePlus(Queries|Extensions)Parser from * LUCENE-6945: factor out TestCorePlus(Queries|Extensions)Parser from
TestParser, rename TestParser to TestCoreParser (Christine Poerschke) TestParser, rename TestParser to TestCoreParser (Christine Poerschke)
* LUCENE-6949: fix (potential) resource leak in SynonymFilterFactory
(https://scan.coverity.com/projects/5620 CID 120656)
(Christine Poerschke, Coverity Scan (via Rishabh Patel))
======================= Lucene 5.4.0 ======================= ======================= Lucene 5.4.0 =======================
New Features New Features

View File

@ -171,7 +171,9 @@ public class SynonymFilterFactory extends TokenFilterFactory implements Resource
List<String> files = splitFileNames(synonyms); List<String> files = splitFileNames(synonyms);
for (String file : files) { for (String file : files) {
decoder.reset(); decoder.reset();
parser.parse(new InputStreamReader(loader.openResource(file), decoder)); try (final Reader isr = new InputStreamReader(loader.openResource(file), decoder)) {
parser.parse(isr);
}
} }
return parser.build(); return parser.build();
} }