[ https://issues.apache.org/jira/browse/JOHNZON-401?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17810929#comment-17810929 ]
Markus Jung commented on JOHNZON-401: ------------------------------------- Can you also assign this to me? We found this when testing Johnzon 2.0.0 in a real JAX-RS application, just wanted to get this bug properly documented here for a possible 2.0.1 release. > Polymorphism attributes not serialized in nested objects > -------------------------------------------------------- > > Key: JOHNZON-401 > URL: https://issues.apache.org/jira/browse/JOHNZON-401 > Project: Johnzon > Issue Type: Bug > Components: JSON-B > Affects Versions: 2.0.0 > Reporter: Markus Jung > Priority: Major > > See the following test: > {code:java} > package org.apache.johnzon.jsonb.polymorphism; > import jakarta.json.bind.annotation.JsonbSubtype; > import jakarta.json.bind.annotation.JsonbTypeInfo; > import org.apache.johnzon.jsonb.test.JsonbRule; > import org.junit.Rule; > import org.junit.Test; > import static org.junit.Assert.assertEquals; > public class JsonbNestedPolymorphismTest { > @Rule public JsonbRule jsonb = new JsonbRule(); > @Test > public void test() > { > Wrapper wrapper = new Wrapper(); > wrapper.something = new ConcreteSomething(); > > assertEquals("{\"something\":{\"@type\":\"concrete\",\"value\":\"asdf\"}}", > jsonb.toJson(wrapper)); > } > @JsonbTypeInfo({ > @JsonbSubtype(alias = "concrete", type = ConcreteSomething.class) > }) > public static class AbstractSomething { > } > public static class ConcreteSomething extends AbstractSomething { > public String value = "asdf"; > } > public static class Wrapper { > public AbstractSomething something; > } > } > {code} > > Test result: > {code:java} > org.junit.ComparisonFailure: > Expected :{"something":{"@type":"concrete","value":"asdf"}} > Actual :{"something":{"value":"asdf"}} > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)