[ONOS-2546]Modify the bug of conditional judgment when converting
JsonNode into ColumnType or BaseType.
Change-Id: I8199c097b1cad0234486b9ac3d0eedce9c4772ac
diff --git a/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/BaseTypeFactory.java b/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/BaseTypeFactory.java
index e74d94f..0fd69a3 100644
--- a/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/BaseTypeFactory.java
+++ b/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/BaseTypeFactory.java
@@ -121,8 +121,8 @@
if (node != null) {
max = node.asInt();
}
- if (node.has("enum")) {
- JsonNode anEnum = node.get("enum").get(1);
+ if (type.has("enum")) {
+ JsonNode anEnum = type.get("enum").get(1);
for (JsonNode n : anEnum) {
enums.add(n.asInt());
}
@@ -148,8 +148,8 @@
if (node != null) {
max = node.asDouble();
}
- if (node.has("enum")) {
- JsonNode anEnum = node.get("enum").get(1);
+ if (type.has("enum")) {
+ JsonNode anEnum = type.get("enum").get(1);
for (JsonNode n : anEnum) {
enums.add(n.asDouble());
}
@@ -175,8 +175,8 @@
if (node != null) {
maxLength = node.asInt();
}
- if (node.has("enum")) {
- JsonNode enumVal = node.get("enum");
+ if (type.has("enum")) {
+ JsonNode enumVal = type.get("enum");
if (enumVal.isArray()) {
JsonNode anEnum = enumVal.get(1);
for (JsonNode n : anEnum) {
diff --git a/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/ColumnTypeFactory.java b/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/ColumnTypeFactory.java
index 8406802..0a81c0a 100644
--- a/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/ColumnTypeFactory.java
+++ b/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/ColumnTypeFactory.java
@@ -61,7 +61,7 @@
* @return ColumnType
*/
public static ColumnType getColumnTypeFromJson(JsonNode json) {
- if (json.isObject() && !json.has(Type.VALUE.type())) {
+ if (!json.isObject() || !json.has(Type.VALUE.type())) {
return createAtomicColumnType(json);
} else if (!json.isValueNode() && json.has(Type.VALUE.type())) {
return createKeyValuedColumnType(json);