SOLR-9016: Fix SolrIdentifierValidator to not accept empty identifiers

This commit is contained in:
Shai Erera 2016-04-26 17:28:04 +03:00 committed by anshum
parent 6f6630b38e
commit 95322605b8
2 changed files with 7 additions and 7 deletions

View File

@ -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.

View File

@ -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";
}
}