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] [Updated] (JOHNZON-219) A null classMapping for inner class with fields.
Date Mon, 01 Jul 2019 08:59:00 GMT

     [ https://issues.apache.org/jira/browse/JOHNZON-219?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Jin Kwon updated JOHNZON-219:
-----------------------------
    Description: 
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.

  was:
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>

	at org.apache.johnzon.jsonb.JohnzonJsonb.fromJson(JohnzonJsonb.java:66)
	at com.github.jinahya.jsonrpc.bind.JsonbTest.test(JsonbTest.java:50)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:132)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:124)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:74)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:43)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:35)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:202)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:198)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:229)
	at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:197)
	at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:211)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:191)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
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.


> 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