Java 7 to 8 JAXB List issue -


i upgrading our system java 7 8 , noticed strange issue. read category tree data ebay using commerce api , unmarshal using jaxb. specific call use similar example on this page http://sandbox.api.ebaycommercenetwork.com/publisher/3.0/rest/categorytree?apikey=78b0db8a-0ee1-4939-a2f9-d3cd95ec0fcc&visitoruseragent&visitoripaddress&trackingid=7000610&categoryid=0&showalldescendants=true.

category tree response:

@xmlrootelement(name="categorytreeresponse", namespace="urn:types.partner.api.shopping.com") public class categorytreeresponse{      private ebaycategory category;      @xmlelement(namespace="urn:types.partner.api.shopping.com")     public ebaycategory getcategory() {         return category;     }      public void setcategory(ebaycategory category) {         this.category = category;     }  } 

ebay category object:

public class ebaycategory {      @xmlattribute     private string id;     private string name;     private string categoryurl;     private string contenttype;     private list<ebaycategory> categories;      public string getid() {         return id;     }     public void setcategoryid(string categoryid){         this.id = categoryid;     }      @xmlelement(namespace="urn:types.partner.api.shopping.com")     public string getname() {         if(name == null){             return "";         }         return name;     }     public void setname(string name) {         this.name = name;     }      @xmlelement(name="categoryurl", namespace="urn:types.partner.api.shopping.com")     public string getcategoryurl() {         return categoryurl;     }     public void setcategoryurl(string categoryurl) {         this.categoryurl = categoryurl;     }      @xmlelement(namespace="urn:types.partner.api.shopping.com")     public string getcontenttype() {         return contenttype;     }     public void setcontenttype(string contenttype) {         this.contenttype = contenttype;     }      @xmlelementwrapper(name="categories", namespace="urn:types.partner.api.shopping.com")     @xmlelement(name="category", namespace="urn:types.partner.api.shopping.com")     public list<ebaycategory> getcategories() {         if(categories == null){             return lists.newarraylist();         }         return categories;     }     public void setcategories(list<ebaycategory> categories) {         this.categories = categories;     }  } 

when unmarshal data, ebaycategory.categories list null though there data. there no exception or other message can see, nothing. in java 7, worked perfectly. there change between versions, or there doing incorrectly?

it seems in java 8, performing operations in getter when annotated jaxb annotation cause issues. when getcategories() method changed return local value, works fine.

@xmlelementwrapper(name="categories", namespace="urn:types.partner.api.shopping.com") @xmlelement(name="category", namespace="urn:types.partner.api.shopping.com") public list<ebaycategory> getcategories() {     return categories; } 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -