Details
-
Bug
-
Resolution: Fixed
-
Major
-
5.2.1, 6.1-rc-1
-
None
-
Unit
-
Unknown
-
N/A
-
N/A
-
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.