You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by sh...@apache.org on 2008/11/19 13:25:08 UTC
svn commit: r718941 - in /lucene/solr/trunk: CHANGES.txt
src/java/org/apache/solr/core/SolrResourceLoader.java
Author: shalin
Date: Wed Nov 19 04:25:08 2008
New Revision: 718941
URL: http://svn.apache.org/viewvc?rev=718941&view=rev
Log:
SOLR-869 -- Fix file descriptor leak in SolrResourceLoader#getLines
Modified:
lucene/solr/trunk/CHANGES.txt
lucene/solr/trunk/src/java/org/apache/solr/core/SolrResourceLoader.java
Modified: lucene/solr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/CHANGES.txt?rev=718941&r1=718940&r2=718941&view=diff
==============================================================================
--- lucene/solr/trunk/CHANGES.txt (original)
+++ lucene/solr/trunk/CHANGES.txt Wed Nov 19 04:25:08 2008
@@ -121,6 +121,8 @@
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
----------------------
Modified: lucene/solr/trunk/src/java/org/apache/solr/core/SolrResourceLoader.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/core/SolrResourceLoader.java?rev=718941&r1=718940&r2=718941&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/core/SolrResourceLoader.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/core/SolrResourceLoader.java Wed Nov 19 04:25:08 2008
@@ -236,17 +236,23 @@
public List<String> getLines(String resource, Charset charset) throws IOException{
BufferedReader input = null;
- input = new BufferedReader(new InputStreamReader(openResource(resource),
- charset));
+ ArrayList<String> lines;
+ try {
+ input = new BufferedReader(new InputStreamReader(openResource(resource),
+ charset));
- ArrayList<String> lines = new ArrayList<String>();
- for (String word=null; (word=input.readLine())!=null;) {
- // skip comments
- if (word.startsWith("#")) continue;
- word=word.trim();
- // skip blank lines
- if (word.length()==0) continue;
- lines.add(word);
+ lines = new ArrayList<String>();
+ for (String word=null; (word=input.readLine())!=null;) {
+ // skip comments
+ if (word.startsWith("#")) continue;
+ word=word.trim();
+ // skip blank lines
+ if (word.length()==0) continue;
+ lines.add(word);
+ }
+ } finally {
+ if (input != null)
+ input.close();
}
return lines;
}