You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by an...@apache.org on 2016/04/27 06:23:54 UTC

lucene-solr:branch_6x: SOLR-9016: Fix SolrIdentifierValidator to not accept empty identifiers

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x 6f6630b38 -> 95322605b


SOLR-9016: Fix SolrIdentifierValidator to not accept empty identifiers


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

Branch: refs/heads/branch_6x
Commit: 95322605b80816792b66b81e91064d0014c920c0
Parents: 6f6630b
Author: Shai Erera <sh...@apache.org>
Authored: Tue Apr 26 17:28:04 2016 +0300
Committer: anshum <an...@apache.org>
Committed: Tue Apr 26 20:59:00 2016 -0700

----------------------------------------------------------------------
 solr/CHANGES.txt                                        |  2 ++
 .../solr/client/solrj/util/SolrIdentifierValidator.java | 12 +++++-------
 2 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/95322605/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 4328c8d..56a5f3b 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -116,6 +116,8 @@ Bug Fixes
 
 * SOLR-9029: fix rare ZkStateReader visibility race during collection state format update (Scott Blum, hossman)
 
+* SOLR-9016: Fix SolrIdentifierValidator to not allow empty identifiers. (Shai Erera)
+
 Optimizations
 ----------------------
 * SOLR-8722: Don't force a full ZkStateReader refresh on every Overseer operation.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/95322605/solr/solrj/src/java/org/apache/solr/client/solrj/util/SolrIdentifierValidator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/util/SolrIdentifierValidator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/util/SolrIdentifierValidator.java
index 9473a28..d23b8bb 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/util/SolrIdentifierValidator.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/util/SolrIdentifierValidator.java
@@ -28,7 +28,7 @@ import org.apache.solr.common.SolrException;
  * Identifiers are allowed to contain underscores, periods, hyphens, and alphanumeric characters.
  */
 public class SolrIdentifierValidator {
-  final static Pattern identifierPattern = Pattern.compile("^(?!\\-)[\\._A-Za-z0-9\\-]*$");
+  final static Pattern identifierPattern = Pattern.compile("^(?!\\-)[\\._A-Za-z0-9\\-]+$");
 
   public enum IdentifierType {
     SHARD, COLLECTION, CORE, ALIAS
@@ -64,11 +64,9 @@ public class SolrIdentifierValidator {
   }
 
   public static String getIdentifierMessage(IdentifierType identifierType, String name) {
-      return "Invalid " + identifierType.toString().toLowerCase(Locale.ROOT) + ": " + name + ". "
-          + identifierType.toString().toLowerCase(Locale.ROOT)
-          + " names must consist entirely of periods, underscores, hyphens, and alphanumerics";
-
+      String typeStr = identifierType.toString().toLowerCase(Locale.ROOT);
+    return "Invalid " + typeStr + ": [" + name + "]. " + typeStr + " names must consist entirely of periods, "
+        + "underscores, hyphens, and alphanumerics as well not start with a hyphen";
   }
-}
-
 
+}