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

Printing a MacroBlock in Groovy generates an infinite loop

    XMLWordPrintable

Details

    • N/A
    • N/A

    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

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

            Dates

              Created:
              Updated:
              Resolved: