Uploaded image for project: 'XWiki Rendering'
  1. XWiki Rendering
  2. XRENDERING-394

Printing a MacroBlock in Groovy generates an infinite loop

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 7.0
    • Fix Version/s: 7.1-milestone-1
    • Component/s: Macro
    • Labels:
    • Documentation:
      N/A
    • Documentation in Release Notes:
      N/A
    • Similar issues:

      Description

      You can reproduce by putting the following Groovy code in a new wiki page:

      {{groovy}}
      import org.xwiki.rendering.block.Block;
      import org.xwiki.rendering.block.match.MacroBlockMatcher;
      
      def xdom = xwiki.getDocument('Sandbox.WebHome').getXDOM()
      println xdom.getBlocks(new MacroBlockMatcher("toc"), Block.Axes.DESCENDANT)
      {{/groovy}}
      

      The loop is not generated if you print the size of the returned list:

      println xdom.getBlocks(new MacroBlockMatcher("toc"), Block.Axes.DESCENDANT).size()
      

      The returned list contains a single object of type org.xwiki.rendering.block.MacroBlock as shown by:

      println xdom.getBlocks(new MacroBlockMatcher("toc"), Block.Axes.DESCENDANT).get(0).getClass().getName()
      

      Note that the infinite loop is not generated if we print a WordBlock:

      {{groovy}}
      import org.xwiki.rendering.block.Block;
      import org.xwiki.rendering.block.WordBlock;
      import org.xwiki.rendering.block.match.ClassBlockMatcher;
      
      def xdom = xwiki.getDocument('Sandbox.WebHome').getXDOM();
      println xdom.getBlocks(new ClassBlockMatcher(WordBlock.class), Block.Axes.DESCENDANT).get(0);
      {{/groovy}}
      

        Attachments

          Activity

            People

            • Assignee:
              tmortagne Thomas Mortagne
              Reporter:
              mflorea Marius Dumitru Florea
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Date of First Response: