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
fix bug - Marshalling an object that overrides the parent's method, the XML that created contains both child's and parent's tag, the problem was in serializeBody method in the reflection section. the condition should check if the super class contains the declared field that the child overrides. #1590
Conversation
…he XML that created contains both child's and parent's tag, the problem was in serializeBody method in the reflection section. the condition should check if the super class contains the declared field that the child overrides. DTOs: @XmlRootElement(name = "parent") public class ParentDTO { Protected String name; @xmlelement(name= “parentName”) getName) { return name; } setName(String name) { this.name = name; } } @XmlRootElement(name = "child") public class ChildDTO extends ParentDTO { @OverRide @xmlelement(name="childName") public String getName() { return name; } } Program: Child child = new Child(); child.setName("aaa"); final Marshaller marshaller = JAXBContext.newInstance(ChildDTO.class).createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); StringWriter stringWriter = new StringWriter(); marshaller.marshal(ChildDTO, stringWriter); String xmlAsString = stringWriter.toString(); XML after Marshall: <child> <parentName> aa </parentName > <childName> aa </ childName > </child>
Any chance to get a new version that contains this patch soon? |
Can you help me guys? It is very important for us. We cannot use all version after 2.2.6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM; I'll add a test for this myself. Thx!
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
@lukasj Any idea when the new release will be available? |
@lukasj Hi, Do you know when the new release with this changes will be available? |
In which version do you need the fix? 2.3.x (javax namespace) or 3.0.x (jakarta namespace)? |
@lukasj We are working with javax namespace |
@lukasj Do you have an indication as to when this will happen? |
likely this week, as to which day exactly - I don't know, there few more pending tasks on my list |
…he XML that created contains both child's and parent's tag, the problem was in serializeBody method in the reflection section. the condition should check if the super class contains the declared field that the child overrides. (eclipse-ee4j#1590) * fix bug - Marshalling an object that overrides the parent's method, the XML that created contains both child's and parent's tag, the problem was in serializeBody method in the reflection section. the condition should check if the super class contains the declared field that the child overrides. DTOs: @XmlRootElement(name = "parent") public class ParentDTO { Protected String name; @xmlelement(name= “parentName”) getName) { return name; } setName(String name) { this.name = name; } } @XmlRootElement(name = "child") public class ChildDTO extends ParentDTO { @OverRide @xmlelement(name="childName") public String getName() { return name; } } Program: Child child = new Child(); child.setName("aaa"); final Marshaller marshaller = JAXBContext.newInstance(ChildDTO.class).createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); StringWriter stringWriter = new StringWriter(); marshaller.marshal(ChildDTO, stringWriter); String xmlAsString = stringWriter.toString(); XML after Marshall: <child> <parentName> aa </parentName > <childName> aa </ childName > </child> (cherry picked from commit be6d4fd)
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com> (cherry picked from commit db536c9)
…he XML that created contains both child's and parent's tag, the problem was in serializeBody method in the reflection section. the condition should check if the super class contains the declared field that the child overrides. (#1590) * fix bug - Marshalling an object that overrides the parent's method, the XML that created contains both child's and parent's tag, the problem was in serializeBody method in the reflection section. the condition should check if the super class contains the declared field that the child overrides. DTOs: @XmlRootElement(name = "parent") public class ParentDTO { Protected String name; @xmlelement(name= “parentName”) getName) { return name; } setName(String name) { this.name = name; } } @XmlRootElement(name = "child") public class ChildDTO extends ParentDTO { @OverRide @xmlelement(name="childName") public String getName() { return name; } } Program: Child child = new Child(); child.setName("aaa"); final Marshaller marshaller = JAXBContext.newInstance(ChildDTO.class).createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); StringWriter stringWriter = new StringWriter(); marshaller.marshal(ChildDTO, stringWriter); String xmlAsString = stringWriter.toString(); XML after Marshall: <child> <parentName> aa </parentName > <childName> aa </ childName > </child> (cherry picked from commit be6d4fd)
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com> (cherry picked from commit db536c9)
can you check https://jakarta.oss.sonatype.org/content/repositories/staging/com/sun/xml/bind/jaxb-ri/2.3.6/jaxb-ri-2.3.6.zip (or through https://jakarta.oss.sonatype.org/content/repositories/staging maven repo) and let me know the problem is fixed there? just to double check it before the binary gets published to central... |
@lukasj looks great!! |
thanks for checking; it will appear in central today (in an hour or two) |
@lukasj Thank you!! |
DTOs:
Program:
XML after Marshall: