lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsmi...@apache.org
Subject lucene-solr:master: SOLR-12365: moved parseLuceneVersionString to SolrConfig class
Date Sat, 05 Jan 2019 22:14:46 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master ff19a3a26 -> 84264c741


SOLR-12365: moved parseLuceneVersionString to SolrConfig class


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/84264c74
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/84264c74
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/84264c74

Branch: refs/heads/master
Commit: 84264c7410a04390e79a5248e4d0492c88ec191d
Parents: ff19a3a
Author: David Smiley <dsmiley@apache.org>
Authored: Sat Jan 5 17:14:37 2019 -0500
Committer: David Smiley <dsmiley@apache.org>
Committed: Sat Jan 5 17:14:37 2019 -0500

----------------------------------------------------------------------
 .../java/org/apache/solr/core/SolrConfig.java   | 28 +++++++++++-
 .../org/apache/solr/core/XmlConfigFile.java     | 45 ++------------------
 .../solr/schema/FieldTypePluginLoader.java      |  6 +--
 .../solr/analysis/TestLuceneMatchVersion.java   |  4 +-
 4 files changed, 35 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84264c74/solr/core/src/java/org/apache/solr/core/SolrConfig.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/SolrConfig.java b/solr/core/src/java/org/apache/solr/core/SolrConfig.java
index 9bf538f..0b5f35b 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrConfig.java
@@ -28,6 +28,7 @@ import java.net.URL;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.EnumSet;
@@ -39,6 +40,7 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 import java.util.UUID;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -104,6 +106,7 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable
{
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
   public static final String DEFAULT_CONF_FILE = "solrconfig.xml";
+
   private RequestParams requestParams;
 
   public enum PluginOpts {
@@ -204,7 +207,7 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable
{
     getOverlay();//just in case it is not initialized
     getRequestParams();
     initLibs();
-    luceneMatchVersion = getLuceneVersion("luceneMatchVersion");
+    luceneMatchVersion = SolrConfig.parseLuceneVersionString(getVal("luceneMatchVersion",
true));
     String indexConfigPrefix;
 
     // Old indexDefaults and mainIndex sections are deprecated and fails fast for luceneMatchVersion=>LUCENE_4_0_0.
@@ -332,6 +335,29 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable
{
     log.debug("Loaded SolrConfig: {}", name);
   }
 
+  private static final AtomicBoolean versionWarningAlreadyLogged = new AtomicBoolean(false);
+
+  public static final Version parseLuceneVersionString(final String matchVersion) {
+    final Version version;
+    try {
+      version = Version.parseLeniently(matchVersion);
+    } catch (ParseException pe) {
+      throw new SolrException(ErrorCode.SERVER_ERROR,
+          "Invalid luceneMatchVersion.  Should be of the form 'V.V.V' (e.g. 4.8.0)", pe);
+    }
+
+    if (version == Version.LATEST && !versionWarningAlreadyLogged.getAndSet(true))
{
+      log.warn(
+          "You should not use LATEST as luceneMatchVersion property: "+
+              "if you use this setting, and then Solr upgrades to a newer release of Lucene,
"+
+              "sizable changes may happen. If precise back compatibility is important "+
+              "then you should instead explicitly specify an actual Lucene version."
+      );
+    }
+
+    return version;
+  }
+
   public static final List<SolrPluginInfo> plugins = ImmutableList.<SolrPluginInfo>builder()
       .add(new SolrPluginInfo(SolrRequestHandler.class, SolrRequestHandler.TYPE, REQUIRE_NAME,
REQUIRE_CLASS, MULTI_OK, LAZY))
       .add(new SolrPluginInfo(QParserPlugin.class, "queryParser", REQUIRE_NAME, REQUIRE_CLASS,
MULTI_OK))

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84264c74/solr/core/src/java/org/apache/solr/core/XmlConfigFile.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/XmlConfigFile.java b/solr/core/src/java/org/apache/solr/core/XmlConfigFile.java
index b838f74..2802f68 100644
--- a/solr/core/src/java/org/apache/solr/core/XmlConfigFile.java
+++ b/solr/core/src/java/org/apache/solr/core/XmlConfigFile.java
@@ -32,7 +32,6 @@ import javax.xml.xpath.XPathFactory;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.invoke.MethodHandles;
-import java.text.ParseException;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Map;
@@ -42,10 +41,8 @@ import java.util.SortedMap;
 import java.util.SortedSet;
 import java.util.TreeMap;
 import java.util.TreeSet;
-import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.lucene.util.Version;
 import org.apache.solr.cloud.ZkSolrResourceLoader;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.util.XMLErrorLogger;
@@ -438,49 +435,13 @@ public class XmlConfigFile { // formerly simply "Config"
     return val!=null ? Float.parseFloat(val) : def;
   }
 
-
   public double getDouble(String path){
      return Double.parseDouble(getVal(path, true));
    }
 
-   public double getDouble(String path, double def) {
-     String val = getVal(path, false);
-     return val!=null ? Double.parseDouble(val) : def;
-   }
-
-  //TODO belongs on SolrXmlConfig?
-   public Version getLuceneVersion(String path) {
-     return parseLuceneVersionString(getVal(path, true));
-   }
-
-  //TODO belongs on SolrXmlConfig?
-   public Version getLuceneVersion(String path, Version def) {
-     String val = getVal(path, false);
-     return val!=null ? parseLuceneVersionString(val) : def;
-   }
-  
-  private static final AtomicBoolean versionWarningAlreadyLogged = new AtomicBoolean(false);
-
-  //TODO belongs on SolrXmlConfig?
-  public static final Version parseLuceneVersionString(final String matchVersion) {
-    final Version version;
-    try {
-      version = Version.parseLeniently(matchVersion);
-    } catch (ParseException pe) {
-      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
-        "Invalid luceneMatchVersion.  Should be of the form 'V.V.V' (e.g. 4.8.0)", pe);
-    }
-    
-    if (version == Version.LATEST && !versionWarningAlreadyLogged.getAndSet(true))
{
-      log.warn(
-        "You should not use LATEST as luceneMatchVersion property: "+
-        "if you use this setting, and then Solr upgrades to a newer release of Lucene, "+
-        "sizable changes may happen. If precise back compatibility is important "+
-        "then you should instead explicitly specify an actual Lucene version."
-      );
-    }
-    
-    return version;
+  public double getDouble(String path, double def) {
+    String val = getVal(path, false);
+    return val != null ? Double.parseDouble(val) : def;
   }
 
   /**If this config is loaded from zk the version is relevant other wise -1 is returned

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84264c74/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java b/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java
index ed6ccbf..25b5408 100644
--- a/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java
+++ b/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java
@@ -33,7 +33,7 @@ import org.apache.lucene.analysis.util.TokenizerFactory;
 import org.apache.lucene.util.Version;
 import org.apache.solr.analysis.TokenizerChain;
 import org.apache.solr.common.SolrException;
-import org.apache.solr.core.XmlConfigFile;
+import org.apache.solr.core.SolrConfig;
 import org.apache.solr.core.SolrResourceLoader;
 import org.apache.solr.util.DOMUtil;
 import org.apache.solr.util.plugin.AbstractPluginLoader;
@@ -231,7 +231,7 @@ public final class FieldTypePluginLoader
         final String matchVersionStr = DOMUtil.getAttr(attrs, LUCENE_MATCH_VERSION_PARAM);
         final Version luceneMatchVersion = (matchVersionStr == null) ?
           schema.getDefaultLuceneMatchVersion() :
-          XmlConfigFile.parseLuceneVersionString(matchVersionStr);
+          SolrConfig.parseLuceneVersionString(matchVersionStr);
         if (luceneMatchVersion == null) {
           throw new SolrException
             ( SolrException.ErrorCode.SERVER_ERROR,
@@ -362,7 +362,7 @@ public final class FieldTypePluginLoader
 
   private Version parseConfiguredVersion(String configuredVersion, String pluginClassName)
{
     Version version = (configuredVersion != null) ?
-            XmlConfigFile.parseLuceneVersionString(configuredVersion) : schema.getDefaultLuceneMatchVersion();
+            SolrConfig.parseLuceneVersionString(configuredVersion) : schema.getDefaultLuceneMatchVersion();
 
     if (!version.onOrAfter(Version.LUCENE_7_0_0)) {
       log.warn(pluginClassName + " is using deprecated " + version +

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84264c74/solr/core/src/test/org/apache/solr/analysis/TestLuceneMatchVersion.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestLuceneMatchVersion.java b/solr/core/src/test/org/apache/solr/analysis/TestLuceneMatchVersion.java
index 15fcb94..859f141 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestLuceneMatchVersion.java
+++ b/solr/core/src/test/org/apache/solr/analysis/TestLuceneMatchVersion.java
@@ -17,7 +17,7 @@
 package org.apache.solr.analysis;
 
 import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.core.XmlConfigFile;
+import org.apache.solr.core.SolrConfig;
 import org.apache.solr.schema.IndexSchema;
 import org.apache.solr.schema.FieldType;
 import org.apache.lucene.analysis.Analyzer;
@@ -37,7 +37,7 @@ public class TestLuceneMatchVersion extends SolrTestCaseJ4 {
   
   // this must match the solrconfig.xml version for this test
   public static final Version DEFAULT_VERSION =
-    XmlConfigFile.parseLuceneVersionString(System.getProperty("tests.luceneMatchVersion",
"LATEST"));
+    SolrConfig.parseLuceneVersionString(System.getProperty("tests.luceneMatchVersion", "LATEST"));
 
   public void testStandardTokenizerVersions() throws Exception {
     assertEquals(DEFAULT_VERSION, solrConfig.luceneMatchVersion);


Mime
View raw message