johnzon-dev mailing list archives

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

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

Romain Manni-Bucau edited comment on JOHNZON-219 at 7/1/19 9:21 AM:
--------------------------------------------------------------------

Hi,

the 2 generics levels is the issue there so SomeError is not a class and therefore not mappable,
if you move to an explicit binding then it works well:

{code}
public static class SomeVoidError extends Some.SomeError<Void> {}
public static class VoidSome extends Some<Void, SomeVoidError, Void> {}

// final Some<Void, ? extends Some.SomeError<Void>, Void> value = jsonb.fromJson(a,
VoidSome.class);
{code}

Not sure it is linked to any property in particular


was (Author: romain.manni-bucau):
Hi,

the 2 generics level is the issue there,
if you move to a single one it works well:

{code}
public static class SomeVoidError extends Some.SomeError<Void> {}
public static class VoidSome extends Some<Void, SomeVoidError, Void> {}

// final Some<Void, ? extends Some.SomeError<Void>, Void> value = jsonb.fromJson(a,
VoidSome.class);
{code}

Not sure it is linked to any property in particular

> 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