[MGNLGROOVY-46] Script output seems to split into different output streams Created: 07/Sep/11  Updated: 04/Nov/15  Resolved: 04/Nov/15

Status: Closed
Project: Magnolia Groovy Module
Component/s: console
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Federico Grilli Assignee: Federico Grilli
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

Greg reported to me a weird behavior while using the groovy module with the following script.

hm = ctx.getHierarchyManager("website");

println "Before visit"

ContentUtil.visit(hm.root, new ContentUtil.Visitor() {
void visit(Content node) {
  println "From Visitor as anonymous impl"
}
})
  
println "After first visit"
  
ContentUtil.visit(hm.root, {
  println "From visitor as closure"
} as ContentUtil.Visitor)
  
println "After both visits"

The result of running this within the dialog or console is that "From Visitor as anonymous impl" gets printed in sys console, all the rest in the dialog/console as expected. I had a quick look at the code in debug mode and what I found is that info.magnolia.module.groovy.console.MgnlGroovyConsole.evaluate(InputStream, String, Writer) at line 74 executing script.run() prints the output that goes to the sys console, whereas
what ends up being displayed in the dialog console is printed later on when the response has been presumably committed. The Writer object passed in the evaluate method above is an instance of PrintWriter which is obtained with response.getPrintWriter(). It looks like the Groovy's Script class internally redirects part of the response to a different output stream than that being set as a value of the 'out' property (see http://groovy.codehaus.org/gapi/groovy/lang/Script.html#println(java.lang.Object))



 Comments   
Comment by Michael Mühlebach [ 04/Nov/15 ]

Given the thousands of other issues we have open that are more highly requested, we won't be able to address this issue in the foreseeable future. Instead we will focus on issues with a higher impact, and more votes.
Thanks for taking the time to raise this issue. As you are no doubt aware this issue has been on our backlog for some time now with very little movement.
I'm going to close this to set expectations so the issue doesn't stay open for years with few updates. If the issue is still relevant please feel free to reopen it or create a new issue.

Generated at Mon Feb 12 05:55:02 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.