You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2015/04/19 20:58:00 UTC

svn commit: r1674668 - in /lucene/dev/branches/branch_5x: ./ solr/ solr/CHANGES.txt solr/core/ solr/core/src/java/org/apache/solr/core/SolrConfig.java

Author: markrmiller
Date: Sun Apr 19 18:57:59 2015
New Revision: 1674668

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

Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/solr/   (props changed)
    lucene/dev/branches/branch_5x/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_5x/solr/core/   (props changed)
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/SolrConfig.java

Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1674668&r1=1674667&r2=1674668&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Sun Apr 19 18:57:59 2015
@@ -86,6 +86,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/branches/branch_5x/solr/core/src/java/org/apache/solr/core/SolrConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/SolrConfig.java?rev=1674668&r1=1674667&r2=1674668&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/SolrConfig.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/SolrConfig.java Sun Apr 19 18:57:59 2015
@@ -19,13 +19,16 @@ package org.apache.solr.core;
 
 
 import com.google.common.base.Charsets;
+
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.xpath.XPathConstants;
+
 import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.EnumSet;
@@ -41,6 +44,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 +52,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;
@@ -387,25 +392,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, Charsets.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();