eclipse-ee4j / eclipselink

Eclipselink project
https://eclipse.dev/eclipselink/
Other
200 stars 171 forks source link

Unmarshalling fails for xml that contains xmlns starting from version 2.6.3 #2227

Open FieteO opened 3 months ago

FieteO commented 3 months ago

Describe the bug I am working on a project that is still on eclipselink 2.6.2. When updating to anything higher, I observe an issue with unmarshalling xml's that contain a namespace, i.e:

<model xmlns="http://org.onap.aai.inventory/v14">
</model>

There is no explicit exception as such, but the resulting DynamicEntity will have the object keys, but without value (such that entity.get("modelId") returns null.

To Reproduce Steps/resources to reproduce the behavior:

I have created the following change request to reproduce the behaviour: Add test case that tests jaxb unmarshalling of xml It contains the following test:

@Test
public void moxyTest() throws IOException, JAXBException{
    String xmlModelPayload = new String(Files.readAllBytes(Paths.get("src/test/resources/payloads/resource/network-service.xml")));
    DynamicJAXBContext jaxbContext = nodeIngestor.getContextForVersion(new SchemaVersion("v14"));
    final Object clazz = jaxbContext.newDynamicEntity("Model");
    Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
    DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(xmlModelPayload)), clazz.getClass()).getValue();
    assertEquals("d821d1aa-8a69-47a4-aa63-3dae1742c47c", entity.get("modelInvariantId"));
    assertEquals("service", entity.get("modelType"));
}

To check it out and run it:

Expected behavior That unmarshalling works for both versions, such that dynamicEntity.get("myAttribute") returns a value != null.