johnzon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jin Kwon (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (JOHNZON-219) A null classMapping for inner class with fields.
Date Mon, 01 Jul 2019 09:37:00 GMT

    [ https://issues.apache.org/jira/browse/JOHNZON-219?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16876055#comment-16876055
] 

Jin Kwon commented on JOHNZON-219:
----------------------------------

[~romain.manni-bucau] Thank your the reply.
The following code evaluates as {{false}} and returns {{null}}.
{code:java}
if (!Class.class.isInstance(clazz)) { // clazz: "...JsonbTest$Some$SomeError<java.lang.Void>"
    return null;
}
{code}
Thank you.

> A null classMapping for inner class with fields.
> ------------------------------------------------
>
>                 Key: JOHNZON-219
>                 URL: https://issues.apache.org/jira/browse/JOHNZON-219
>             Project: Johnzon
>          Issue Type: Bug
>          Components: JSON-B
>    Affects Versions: 1.1.12
>            Reporter: Jin Kwon
>            Priority: Major
>
> I'm sorry I can't find any good words for the issue.
> With following code,
> {code:java}
>     public static class Some<T, U extends Some.SomeError<?>, V> {
>         public static class SomeError<W> {
>             @Setter
>             @Getter
>             private int code;
>             @Setter
>             @Getter
>             private W data;
>         }
>         @Setter
>         @Getter
>         private T t;
>         @Setter
>         @Getter
>         private U u;
>         @Setter
>         @Getter
>         private V v;
>     }
>     public static class VoidSome extends Some<Void, Some.SomeError<Void>, Void>
{
>     }
>     @Test
>     void test() throws IOException {
>         final String a = "{\"t\": null, \"u\": {\"code\":1}, \"v\": null}";
>         final String b = "{\"t\": null, \"u\": null, \"v\": null}";
>         //final Some<Void, Some.SomeError<Void>, Void> value = JSONB.fromJson(b,
VoidSome.class);
>         final Some<Void, Some.SomeError<Void>, Void> value = JSONB.fromJson(a,
VoidSome.class);
>         log.debug("value: {}", value);
>     }
> {code}
> I got,
> {code}
> javax.json.bind.JsonbException: Can't map com.github.jinahya.jsonrpc.bind.JsonbTest$Some$SomeError<java.lang.Void>
> Caused by: org.apache.johnzon.mapper.MapperException: Can't map com.github.jinahya.jsonrpc.bind.JsonbTest$Some$SomeError<java.lang.Void>
> 	at org.apache.johnzon.mapper.MappingParserImpl.buildObject(MappingParserImpl.java:277)
> 	at org.apache.johnzon.mapper.MappingParserImpl.toObject(MappingParserImpl.java:537)
> 	at org.apache.johnzon.mapper.MappingParserImpl.toValue(MappingParserImpl.java:736)
> 	at org.apache.johnzon.mapper.MappingParserImpl.buildObject(MappingParserImpl.java:338)
> 	at org.apache.johnzon.mapper.MappingParserImpl.readObject(MappingParserImpl.java:141)
> 	at org.apache.johnzon.mapper.MappingParserImpl.readObject(MappingParserImpl.java:133)
> 	at org.apache.johnzon.mapper.MappingParserImpl.readObject(MappingParserImpl.java:125)
> 	at org.apache.johnzon.mapper.Mapper.mapObject(Mapper.java:328)
> 	at org.apache.johnzon.mapper.Mapper.readObject(Mapper.java:267)
> 	at org.apache.johnzon.mapper.Mapper.readObject(Mapper.java:262)
> 	at org.apache.johnzon.jsonb.JohnzonJsonb.fromJson(JohnzonJsonb.java:60)
> 	... 64 more
> {code}
> Weird somehow,
> When I remove {{code}} property and use {{b}} instead, it works.
> I tried to debug the code and I failed.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message