Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-10600

Executing a JSR223 script macro directly or indirectly from another JSR223 script macro might break the root script context

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.2.1, 6.1-rc-1
    • Fix Version/s: 6.2-milestone-1
    • Component/s: Scripting
    • Labels:
      None
    • Tests:
      Unit
    • Difficulty:
      Unknown
    • Documentation:
      N/A
    • Documentation in Release Notes:
      N/A
    • Similar issues:

      Description

      Like rendering a document containing a groovy macro from a groovy macro in another document.

      The same instance of ScriptContext is used during the HTTP request (so share bindings between macros among other things) and right now AbstractJSR223ScriptMacro does not really take that into account. It should save a few plumbing stuff like the writer/reader and "context" binding and restore them after script execution in case it's a subscript.

      Here is a simple script to reproduce the issue:

      {{groovy}}
      println 'before'
      
      services.component.getInstance(org.xwiki.rendering.converter.Converter.class).convert(new java.io.StringReader("{{groovy}}print 'inside'{{/groovy}}"), org.xwiki.rendering.syntax.Syntax.XWIKI_2_1, org.xwiki.rendering.syntax.Syntax.PLAIN_1_0, org.xwiki.rendering.renderer.printer.VoidWikiPrinter.VOIDWIKIPRINTER)
      
      println 'after'
      {{/groovy}}
      

      the second println ("after") ends up in the log because groovy cannot find the custom writer anymore and fallback on standard output.

        Attachments

          Activity

            People

            • Assignee:
              tmortagne Thomas Mortagne
              Reporter:
              tmortagne Thomas Mortagne
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: