SOLR-869 -- Fix file descriptor leak in SolrResourceLoader#getLines

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@718941 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2008-11-19 12:25:08 +00:00
parent 993c2dbb98
commit 8f14ef8475
2 changed files with 18 additions and 10 deletions

View File

@ -121,6 +121,8 @@ Bug Fixes
9. SOLR-803: CoreAdminRequest.createCore fails because name parameter isn't set (Sean Colombo via ryan)
10. SOLR-869: Fix file descriptor leak in SolrResourceLoader#getLines (Mark Miller, shalin)
Other Changes
----------------------

View File

@ -236,10 +236,12 @@ public class SolrResourceLoader implements ResourceLoader
public List<String> getLines(String resource, Charset charset) throws IOException{
BufferedReader input = null;
ArrayList<String> lines;
try {
input = new BufferedReader(new InputStreamReader(openResource(resource),
charset));
ArrayList<String> lines = new ArrayList<String>();
lines = new ArrayList<String>();
for (String word=null; (word=input.readLine())!=null;) {
// skip comments
if (word.startsWith("#")) continue;
@ -248,6 +250,10 @@ public class SolrResourceLoader implements ResourceLoader
if (word.length()==0) continue;
lines.add(word);
}
} finally {
if (input != null)
input.close();
}
return lines;
}