You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Bertrand Delacretaz (JIRA)" <ji...@apache.org> on 2016/05/18 10:39:12 UTC

[jira] [Resolved] (SLING-5578) Json rendering is using recursion for processing flat trees and causes stack overflows

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

Bertrand Delacretaz resolved SLING-5578.
----------------------------------------
    Resolution: Fixed

Thanks for your patch, I have improved the ResourceTraversor tests [1] to reach 100% coverage and applied it. 

With this the tests pass with 100'000 resources in a flat tree, they did fail with a stack overflow without your patch.

[1] https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/json/src/test/java/org/apache/sling/commons/json/sling/ResourceTraversorTest.java

> Json rendering is using recursion for processing flat trees and causes stack overflows
> --------------------------------------------------------------------------------------
>
>                 Key: SLING-5578
>                 URL: https://issues.apache.org/jira/browse/SLING-5578
>             Project: Sling
>          Issue Type: Bug
>          Components: Commons
>    Affects Versions: Commons JSON 2.0.16
>            Reporter: Marius Petria
>            Assignee: Bertrand Delacretaz
>             Fix For: Commons JSON 2.0.18
>
>         Attachments: SLING-5578.diff, SLING-5578.test.diff
>
>
> {{ResourceTraversor.collectChildren}} is unnecessarily using recursion and causes stack overflows for flat trees.
> Example: for a node with 10k direct children it adds 10k calls on the stack. This should be implemented in an iterative way or at most it should do recursion only for the tree depth.
> [1] https://github.com/apache/sling/blob/7c4a53755aed1211c9af313a3973cd2543a7bbe0/bundles/commons/json/src/main/java/org/apache/sling/commons/json/sling/ResourceTraversor.java#L84



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)