Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
FieteO opened this issue Aug 7, 2024 · 0 comments
Open

Comments

@FieteO
Copy link

FieteO commented Aug 7, 2024

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:

  • EclipseLink version: 2.6.3
  • Java/JDK version: Java 8
  • Entity source (mainly applied annotations)
    For problem in MOXy (JAXB implementation)
  • Code example which leads into bug like:

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:

  • Clone the project with git fetch https://gerrit.onap.org/r/aai/aai-common refs/changes/46/138646/2 && git checkout -b change-138646 FETCH_HEAD
  • make sure you are using Java 8 (i.e by prefixing the following command with JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/)
  • Run cd aai-core && mvn test -Dcheckstyle.skip -Dtest=MoxyEngineTest#moxyTest
  • The test should pass
  • Change the eclipse.persistence.version in the pom.xml to 2.6.3 and rerun the test
  • The test should fail
  • Optionally mvn test [...] -Dmaven.surefire.debug can be used to enable remote debugging

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant