[ 
https://issues.apache.org/jira/browse/GROOVY-7150?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

John Wagenleitner resolved GROOVY-7150.
---------------------------------------
       Resolution: Fixed
         Assignee: John Wagenleitner
    Fix Version/s: 2.4.8

Thanks for reporting the issue.

> Redirection of output in javax.script.ScriptEngine.invokeFunction() doesn't 
> work
> --------------------------------------------------------------------------------
>
>                 Key: GROOVY-7150
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7150
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-jdk
>    Affects Versions: 2.3.6
>         Environment: Java, Windows, Linux
>            Reporter: Shaul Eliyahu
>            Assignee: John Wagenleitner
>             Fix For: 2.4.8
>
>
> The Java code below should return a string "Hello World!". Instead of that it 
> returns an empty string and prints "Hello World!" in the console the 
> application runs. The problem exists only inside functions; texts printed 
> outside functions are redirected properly:
> {code:java}
> javax.script.ScriptEngineManager manager = new ScriptEngineManager();
> javax.script.ScriptEngine engine = manager.getEngineByName("groovy");
> StringWriter stdOut = new StringWriter();
> engine.getContext().setWriter(new PrintWriter(stdOut));
> engine.eval("def myFunction() { print("Hello World!"); }");
> Invocable invoker = (Invocable) engine;
> invoker.invokeFunction("myFunction", new Object[0]);
> return stdOut.getBuffer().toString();
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to