You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
DynamicEntity created from a DynamicType do not initialise collection properties with an empty list. Because the collections are not initialised, all XPath actions on these properties will result in NullPointerExceptions.
To Reproduce
Steps/resources to reproduce the behavior:
Below is a simple test case to replicate the issue.
InputStream schemaStream = ClassLoader.getSystemResourceAsStream("single.xsd");
jaxbContext = DynamicJAXBContextFactory.createContextFromXSD(schemaStream, null, null, null);
var customer = jaxbContext.newDynamicEntity("Customer");
assertNotNull(customer.get("phoneNumbers")); // currently this is null
var resolver = new NamespaceResolver();
resolver.setDefaultNamespaceURI("www.example.org/customer");
/*
currently throws a NullPointerException
java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "collection" is null
at org.eclipse.persistence.core/org.eclipse.persistence.internal.oxm.Context.getValueByXPath(Context.java:551)
at org.eclipse.persistence.core/org.eclipse.persistence.internal.oxm.Context.getValueByXPath(Context.java:528)
at org.eclipse.persistence.core/org.eclipse.persistence.oxm.XMLContext.getValueByXPath(XMLContext.java:573)
at org.eclipse.persistence.moxy/org.eclipse.persistence.jaxb.JAXBContext.getValueByXPath(JAXBContext.java:654)
*/
var phoneNumbers = jaxbContext.getValueByXPath(customer, "phone-numbers", resolver, Object.class);
assertNotNull(phoneNumbers);
assertEquals(ArrayList.class, phoneNumbers.getClass());
Expected behavior
Similar to how the static JAXB classes behave, new entities should be created with collection properties initialised with an empty collection.
The text was updated successfully, but these errors were encountered:
Describe the bug
DynamicEntity created from a DynamicType do not initialise collection properties with an empty list. Because the collections are not initialised, all XPath actions on these properties will result in NullPointerExceptions.
To Reproduce
Steps/resources to reproduce the behavior:
Below is a simple test case to replicate the issue.
single.xsd
Expected behavior
Similar to how the static JAXB classes behave, new entities should be created with collection properties initialised with an empty collection.
The text was updated successfully, but these errors were encountered: