[OVSDB-127] Unable to set the external_ids field of the Qos object Created: 17/Oct/14  Updated: 04/Nov/14  Resolved: 04/Nov/14

Status: Resolved
Project: ovsdb
Component/s: Schemas
Affects Version/s: unspecified
Fix Version/s: None

Type: Bug
Reporter: Jim West Assignee: Flavio Fernandes
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 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.



 Comments   
Comment by Flavio Fernandes [ 04/Nov/14 ]

master:
https://git.opendaylight.org/gerrit/#/c/12465/

stable/helium:
https://git.opendaylight.org/gerrit/#/c/12487/

Generated at Wed Feb 07 20:35:34 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.