Trejkaz created JRUBY-6284:
------------------------------

             Summary: Calls to Kernel#exit result in an exception printed on 
stderr
                 Key: JRUBY-6284
                 URL: https://jira.codehaus.org/browse/JRUBY-6284
             Project: JRuby
          Issue Type: Bug
          Components: Embedding
    Affects Versions: JRuby 1.6.5, JRuby 1.6.1
            Reporter: Trejkaz


The following test:

{code}
    @Test
    public void testJRubyExitBehaviour() throws Exception
    {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByExtension("rb");

        try
        {
            engine.eval("exit 3");
            fail("Expected ScriptException");
        }
        catch (ScriptException e)
        {
            // Expected
        }
    }
{code}

The test itself does actually pass, but what's bad here is that it logs the 
following to stderr:

{code}
SystemExit: exit
    exit at org/jruby/RubyKernel.java:867
    exit at org/jruby/RubyKernel.java:836
  (root) at <script>:1
org.jruby.embed.EvalFailedException: (SystemExit) exit
        at 
org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:127)
        at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:90)
        at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:153)
        at 
com.nuix.script.TestScriptUtils.testJRubyExitBehaviour(TestScriptUtils.java:25)
        ...26 lines elided...
Caused by: org.jruby.exceptions.RaiseException: (SystemExit) exit
{code}

This makes it difficult if you're trying to write a command-line application 
which wants to display a nice usage message to the user and then exit - they 
can't read the usage message because they get a page full of errors after it.

The main jruby runtime itself doesn't appear to do this with the same kind of 
script, so I figure the error is limited to when you're embedding.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to