There is an incorrect assumption that all Enum types will be a Set/Array.
Thanks to the minimal IT written for hardware_vtep, this assumption is caught for an enum type for "encapsulation_type" field :
"type": { "key": { "enum": "vxlan_over_ipv4", "type": "string" } }
The incorrect assumption caused null pointer exception on the IT run.
Caused by: java.lang.NullPointerException: null
at org.opendaylight.ovsdb.lib.schema.BaseType$StringBaseType.populateEnum(BaseType.java:307)
This fix addresses that problem.
Change-Id: I1cf1a278b6963765cf90268b616de7d721d2ef30
Signed-off-by: Madhu Venugopal <mavenugo@gmail.com>
private void populateEnum(StringBaseType baseType, JsonNode node) {
if (node.has("enum")) {
Set<String> s = Sets.newHashSet();
- JsonNode anEnum = node.get("enum").get(1);
- for (JsonNode n : anEnum) {
- s.add(n.asText());
+ JsonNode enumVal = node.get("enum");
+ if (enumVal.isArray()) {
+ JsonNode anEnum = enumVal.get(1);
+ for (JsonNode n : anEnum) {
+ s.add(n.asText());
+ }
+ } else if (enumVal.isTextual()) {
+ s.add(enumVal.asText());
}
baseType.setEnums(s);
}