lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r1674666 - in /lucene/dev/trunk/solr: CHANGES.txt core/src/java/org/apache/solr/core/SolrConfig.java
Date Sun, 19 Apr 2015 18:44:22 GMT
Author: markrmiller
Date: Sun Apr 19 18:44:21 2015
New Revision: 1674666

URL: http://svn.apache.org/r1674666
Log:
SOLR-7426: SolrConfig#getConfigOverlay does not clean up it's resources.

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrConfig.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1674666&r1=1674665&r2=1674666&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Sun Apr 19 18:44:21 2015
@@ -138,6 +138,8 @@ Bug Fixes
 * SOLR-7392: Fix SOLR_JAVA_MEM and SOLR_OPTS customizations in solr.in.sh being ignored
   (Ramkumar Aiyengar, Ere Maijala)
 
+* SOLR-7426: SolrConfig#getConfigOverlay does not clean up it's resources. (Mark Miller)
+
 Optimizations
 ----------------------
 

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrConfig.java?rev=1674666&r1=1674665&r2=1674666&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrConfig.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrConfig.java Sun Apr 19 18:44:21
2015
@@ -20,6 +20,7 @@ package org.apache.solr.core;
 
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.xpath.XPathConstants;
+
 import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
@@ -41,6 +42,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import com.google.common.collect.ImmutableList;
+
 import org.apache.lucene.index.IndexDeletionPolicy;
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.util.Version;
@@ -48,6 +50,7 @@ import org.apache.solr.cloud.ZkSolrResou
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.cloud.ZkNodeProps;
+import org.apache.solr.common.util.IOUtils;
 import org.apache.solr.handler.component.SearchComponent;
 import org.apache.solr.request.SolrRequestHandler;
 import org.apache.solr.response.QueryResponseWriter;
@@ -375,25 +378,31 @@ public class SolrConfig extends Config i
 
   public static ConfigOverlay getConfigOverlay(SolrResourceLoader loader) {
     InputStream in = null;
+    InputStreamReader isr = null;
     try {
-      in = loader.openResource(ConfigOverlay.RESOURCE_NAME);
-    } catch (IOException e) {
-      //no problem no overlay.json file
-      return new ConfigOverlay(Collections.EMPTY_MAP, -1);
-    }
-
-    try {
-      int version = 0; //will be always 0 for file based resourceloader
+      try {
+        in = loader.openResource(ConfigOverlay.RESOURCE_NAME);
+      } catch (IOException e) {
+        // TODO: we should be explicitly looking for file not found exceptions
+        // and logging if it's not the expected IOException
+        // hopefully no problem, assume no overlay.json file
+        return new ConfigOverlay(Collections.EMPTY_MAP, -1);
+      }
+      
+      int version = 0; // will be always 0 for file based resourceLoader
       if (in instanceof ZkSolrResourceLoader.ZkByteArrayInputStream) {
         version = ((ZkSolrResourceLoader.ZkByteArrayInputStream) in).getStat().getVersion();
         log.info("config overlay loaded . version : {} ", version);
       }
-      Map m = (Map) ObjectBuilder.getVal(new JSONParser(new InputStreamReader(in, StandardCharsets.UTF_8)));
+      isr = new InputStreamReader(in, StandardCharsets.UTF_8);
+      Map m = (Map) ObjectBuilder.getVal(new JSONParser(isr));
       return new ConfigOverlay(m, version);
     } catch (Exception e) {
       throw new SolrException(ErrorCode.SERVER_ERROR, "Error reading config overlay", e);
+    } finally {
+      IOUtils.closeQuietly(isr);
+      IOUtils.closeQuietly(in);
     }
-
   }
 
   private Map<String, InitParams> initParams = Collections.emptyMap();



Mime
View raw message