Details
-
Bug
-
Status: Resolved
-
Resolution: Done
-
unspecified
-
None
-
None
-
Operating System: All
Platform: All
-
2214
Description
For the implementation I'm working on, I need to write some data into the external_ids field of objects in OVSDB's Qos table.
I implemented this with the following code:
final Qos newQos = ovsdbCfg.createTypedRow(node, Qos.class);
final HashSet<String> typeSet = new HashSet<String>();
typeSet.add(MY_QOS_TYPE);
newQos.setType(typeSet);
final HashMap<String, String> extIds = new HashMap<>();
extIds.put(QOS_ATTR, attrValue);
newQos.setExternalIds(extIds);
final StatusWithUuid status = ovsdbCfg.insertRow(ovsNode, tableName, parentUuid, row);
However, when I set the external_ids field, I get a NullPointerException deep down in the ovsdb library code. Here's a stack trace:
java.lang.NullPointerException
at org.opendaylight.ovsdb.lib.operations.Insert.value(Insert.java:65)
at org.opendaylight.ovsdb.lib.operations.Insert.value(Insert.java:73)
at org.opendaylight.ovsdb.lib.operations.Insert.<init>(Insert.java:56)
at org.opendaylight.ovsdb.lib.operations.Operations.insert(Operations.java:31)
at org.opendaylight.ovsdb.plugin.impl.ConfigurationServiceImpl.processInsertTransaction(ConfigurationServiceImpl.java:1205)
at org.opendaylight.ovsdb.plugin.impl.ConfigurationServiceImpl.processTypedInsertTransaction(ConfigurationServiceImpl.java:209)
at org.opendaylight.ovsdb.plugin.impl.ConfigurationServiceImpl.insertRow(ConfigurationServiceImpl.java:265)
Root cause:
There a bug in schemas/openvswitch/src/main/java/org/opendaylight/ovsdb/schema/openvswitch/Qos.java
What's happening in Insert.java (line 65) is that the columnSchema is null:
public <D, C extends TableSchema<C>> Insert<E> value(ColumnSchema<C, D> columnSchema, D value)
{ Object untypedValue = columnSchema.getNormalizeData(value); row.put(columnSchema.getName(), untypedValue); return this; }This happens because the schema for 'external_ids' can't be found (the schema for other fields CAN be found and if I remove the setting of 'external_ids' the code works correctly.
Fix:
The fix is to fix the annotation in Qos.java
diff --git a/schemas/openvswitch/src/main/java/org/opendaylight/ovsdb/schema/openvswitch/Qos.java b/schemas/openvswitch/src/main/java/org/opendaylight/ovsdb/schema/openvswitch/Q
index b853ede..3c4896f 100644
— a/schemas/openvswitch/src/main/java/org/opendaylight/ovsdb/schema/openvswitch/Qos.java
+++ b/schemas/openvswitch/src/main/java/org/opendaylight/ovsdb/schema/openvswitch/Qos.java
@@ -45,9 +45,9 @@ public interface Qos extends TypedBaseTable<GenericTableSchema> {
@TypedColumn (name="other_config", method= MethodType.SETDATA, fromVersion="1.0.0")
public void setOtherConfig(Map<String, String> otherConfig) ;
- @TypedColumn (name="externalIds", method= MethodType.GETCOLUMN, fromVersion="1.0.0")
+ @TypedColumn (name="external_ids", method= MethodType.GETCOLUMN, fromVersion="1.0.0")
public Column<GenericTableSchema, Map<String, String>> getExternalIdsColumn() ;
- @TypedColumn (name="externalIds", method= MethodType.SETDATA, fromVersion="1.0.0")
+ @TypedColumn (name="external_ids", method= MethodType.SETDATA, fromVersion="1.0.0")
public void setExternalIds(Map<String, String> externalIds) ;
}
I've tested this fix and I now get the expected behavior.