Apache Lucene open-source search software
SOLR-12662: Reproducing TestPolicy failures: NPE and NoClassDefFoundError
Steve Rowe6430749d46cd
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 5733ce5eb13..520e9151b5c 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -8146,6 +8146,9 @@ Bug Fixes* SOLR-6693: bin\solr.cmd doesn't support 32-bit JRE/JDK running on Windows due toparenthesis in JAVA_HOME. (Timothy Potter, Christopher Hewitt, Jan Høydahl)++* SOLR-12662: Reproducing TestPolicy failures: NPE and NoClassDefFoundError.+ (Steve Rowe)Optimizations----------------------diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/VariableBase.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/VariableBase.javaindex 4387eb10713..8b0c1cf52ea 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/VariableBase.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/VariableBase.java@@ -77,7 +77,7 @@ public class VariableBase implements Variable {}public static Type getTagType(String name) {- Type info = validatetypes.get(name);+ Type info = getValidatetypes().get(name);if (info == null && name.startsWith(ImplicitSnitch.SYSPROP)) info = Type.STRING;if (info == null && name.startsWith(Clause.METRICS_PREFIX)) info = Type.LAZY;return info;@@ -196,11 +196,15 @@ public class VariableBase implements Variable {}- private static Map<String, Type> validatetypes;+ private static Map<String, Type> validatetypes = null;- static {- validatetypes = new HashMap<>();- for (Type t : Type.values())- validatetypes.put(t.tagName, t);+ /** SOLR-12662: Lazily init validatetypes to avoid Type.values() NPE due to static initializer ordering */+ private static Map<String, Type> getValidatetypes() {+ if (validatetypes == null) {+ validatetypes = new HashMap<>();+ for (Type t : Type.values())+ validatetypes.put(t.tagName, t);+ }+ return validatetypes;}}