SOLR-12662: Reproducing TestPolicy failures: NPE and NoClassDefFoundError

This commit is contained in:
Steve Rowe 2018-08-28 12:42:59 -04:00
parent ca54137c8e
commit 6430749d46
2 changed files with 13 additions and 6 deletions

View File

@ -8146,6 +8146,9 @@ Bug Fixes
* SOLR-6693: bin\solr.cmd doesn't support 32-bit JRE/JDK running on Windows due to * SOLR-6693: bin\solr.cmd doesn't support 32-bit JRE/JDK running on Windows due to
parenthesis in JAVA_HOME. (Timothy Potter, Christopher Hewitt, Jan Høydahl) parenthesis in JAVA_HOME. (Timothy Potter, Christopher Hewitt, Jan Høydahl)
* SOLR-12662: Reproducing TestPolicy failures: NPE and NoClassDefFoundError.
(Steve Rowe)
Optimizations Optimizations
---------------------- ----------------------

View File

@ -77,7 +77,7 @@ public class VariableBase implements Variable {
} }
public static Type getTagType(String name) { 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(ImplicitSnitch.SYSPROP)) info = Type.STRING;
if (info == null && name.startsWith(Clause.METRICS_PREFIX)) info = Type.LAZY; if (info == null && name.startsWith(Clause.METRICS_PREFIX)) info = Type.LAZY;
return info; 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 { /** SOLR-12662: Lazily init validatetypes to avoid Type.values() NPE due to static initializer ordering */
validatetypes = new HashMap<>(); private static Map<String, Type> getValidatetypes() {
for (Type t : Type.values()) if (validatetypes == null) {
validatetypes.put(t.tagName, t); validatetypes = new HashMap<>();
for (Type t : Type.values())
validatetypes.put(t.tagName, t);
}
return validatetypes;
} }
} }