[MGNLGROOVY-160] Scripts run in console cannot use print/println unless they run for a long time Created: 02/Feb/17  Updated: 02/Feb/17

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

Type: Bug Priority: Neutral
Reporter: Philipp Bärfuss Assignee: Unassigned
Resolution: Unresolved 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

 Description   

Printing to the console does not work in scripts when using the run command.

What is interesting is that as soon the script runs long enough (migration) then it works. So it looks like a timing issue.

Won't work

println "test"

Works

println "test"
sleep(3000)

What happens when the execution is delayed (and writing to the console works) is that I get a Pulse Message (not ideal for scripts)



 Comments   
Comment by Philipp Bärfuss [ 02/Feb/17 ]

Just in case anybody runs into the same issue. You can use the following hack to log to the system console (won't show in groovy console though)

void println(str){
    System.out.println str
}
Generated at Mon Feb 12 05:56:10 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.