fix JAXB usage/design bug in NeutronObject re. null tenant_id 26/75926/1
authorMichael Vorburger <vorburger@redhat.com>
Mon, 10 Sep 2018 14:18:11 +0000 (16:18 +0200)
committerMichael Vorburger <vorburger@redhat.com>
Mon, 10 Sep 2018 14:22:08 +0000 (16:22 +0200)
@XmlElement on a (package visible..) field and then special logic in the
getter was perhaps an unholy combination.  I can't quite explain why it
worked most of the time but not always.  One would think that the tests
going through the getter should also execute that special logic, but
alas, clearly in some of the test runs (and perhaps in production...)
they did not, see the recurring NEUTRON-159 problem.

background: https://bugs.opendaylight.org/show_bug.cgi?id=4775 (and its
old https://git.opendaylight.org/gerrit/#/c/31324 and
https://git.opendaylight.org/gerrit/#/c/31361/)

JIRA: NEUTRON-159
Change-Id: I986dc6f4bea2f08becea21936bedd831643d212e
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronObject.java

index d138cc4a39c406c3d3d910c21b28f28443791740..c2dfd52921d86ae10e9a71c58e84a4eb766d5e0c 100644 (file)
@@ -31,7 +31,6 @@ public abstract class NeutronObject<T extends NeutronObject<T>> extends NeutronI
 
     private static final long serialVersionUID = 1L;
 
-    @XmlElement(name = "tenant_id")
     String tenantID;
 
     @XmlElement(name = "project_id")
@@ -44,6 +43,7 @@ public abstract class NeutronObject<T extends NeutronObject<T>> extends NeutronI
     }
 
     @Override
+    @XmlElement(name = "tenant_id")
     public String getTenantID() {
         if (tenantID != null && tenantID.isEmpty()) {
             // Bug 4775 - Treat empty string tenantId as null, so no attempt is made
@@ -54,6 +54,7 @@ public abstract class NeutronObject<T extends NeutronObject<T>> extends NeutronI
     }
 
     @Override
+    @XmlElement(name = "tenant_id")
     public void setTenantID(String tenantID) {
         this.tenantID = tenantID;
     }