mirror of https://github.com/apache/lucene.git
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:
parent
993c2dbb98
commit
8f14ef8475
|
@ -121,6 +121,8 @@ Bug Fixes
|
||||||
|
|
||||||
9. SOLR-803: CoreAdminRequest.createCore fails because name parameter isn't set (Sean Colombo via ryan)
|
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
|
Other Changes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
|
@ -236,17 +236,23 @@ public class SolrResourceLoader implements ResourceLoader
|
||||||
|
|
||||||
public List<String> getLines(String resource, Charset charset) throws IOException{
|
public List<String> getLines(String resource, Charset charset) throws IOException{
|
||||||
BufferedReader input = null;
|
BufferedReader input = null;
|
||||||
input = new BufferedReader(new InputStreamReader(openResource(resource),
|
ArrayList<String> lines;
|
||||||
charset));
|
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;) {
|
for (String word=null; (word=input.readLine())!=null;) {
|
||||||
// skip comments
|
// skip comments
|
||||||
if (word.startsWith("#")) continue;
|
if (word.startsWith("#")) continue;
|
||||||
word=word.trim();
|
word=word.trim();
|
||||||
// skip blank lines
|
// skip blank lines
|
||||||
if (word.length()==0) continue;
|
if (word.length()==0) continue;
|
||||||
lines.add(word);
|
lines.add(word);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (input != null)
|
||||||
|
input.close();
|
||||||
}
|
}
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue