From 7ba2b5d7d8be7503eea754b807ba436f735b37d0 Mon Sep 17 00:00:00 2001 From: Christine Poerschke Date: Mon, 4 Jan 2016 12:19:38 +0000 Subject: [PATCH] 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 --- lucene/CHANGES.txt | 4 ++++ .../apache/lucene/analysis/synonym/SynonymFilterFactory.java | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 182af2416ae..c16fff7c2b6 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -214,6 +214,10 @@ Other * LUCENE-6945: factor out TestCorePlus(Queries|Extensions)Parser from 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 ======================= New Features diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymFilterFactory.java index 20a9e7af2ec..d7dbd0f2309 100644 --- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymFilterFactory.java +++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymFilterFactory.java @@ -171,7 +171,9 @@ public class SynonymFilterFactory extends TokenFilterFactory implements Resource List files = splitFileNames(synonyms); for (String file : files) { 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(); }