You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@johnzon.apache.org by "Romain Manni-Bucau (Jira)" <ji...@apache.org> on 2021/05/17 07:06:00 UTC

[jira] [Commented] (JOHNZON-345) StackOverflow when serializing Collection

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

Romain Manni-Bucau commented on JOHNZON-345:
--------------------------------------------

Hi [~mkarg], can you reproduce it on master?
{code:java}
    @Test
    public void collectionOfUrl() throws Exception {
        try (final Jsonb jsonb = JsonbBuilder.create()) {
            final String value = "http://johnzon.apache.org";
            final String json = "[\"" + value + "\"]";
            final URL url = new URL(value);
            assertEquals(json, jsonb.toJson(singleton(url)));
            assertEquals(singletonList(url), jsonb.fromJson(json, new JohnzonParameterizedType(List.class, URL.class)));
        }
    }

{code}
is green

> StackOverflow when serializing Collection<URL>
> ----------------------------------------------
>
>                 Key: JOHNZON-345
>                 URL: https://issues.apache.org/jira/browse/JOHNZON-345
>             Project: Johnzon
>          Issue Type: Bug
>          Components: JSON-B
>    Affects Versions: 1.2.11
>            Reporter: Markus Karg
>            Priority: Blocker
>
> The JSON-B specification mandates that compliant implementations MUST support serialization of Collection and URL.
> Unfortunately when serializing a Collection<URL> using Johnzon-Jsonb 1.2.11 an infinite loop happens, resulting in a StackOverflowException.
> I have reproduced this complaint by the following code:
> {{  JsonbConfig jsonbConfig = new JsonbConfig();}}
> {{  Jsonb jsonb = JsonbBuilder.create(jsonbConfig);}}
> {{  URL url = new URL("http://www.apache.org");}}
> {{  Collection<URL> collection = Collections.singleton(url);}}
> {{  System.out.println("Jsonb collection: " + jsonb.toJson(collection));}}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)