Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.6.1, JRuby 1.6.5
    • Fix Version/s: JRuby 1.6.6, JRuby 1.7.0.pre1
    • Component/s: Embedding
    • Labels:
      None
    • Number of attachments :
      0

      Description

      The following test:

          @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
              }
          }
      

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

      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
      

      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.

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        I think it's reasonable to assume that "exit" within an embedded script will simply bubble out the exit status as the script's result. Yoko: I'm interested in your thoughts. Meanwhile, I'm fixing it this way.

        Show
        Charles Oliver Nutter added a comment - I think it's reasonable to assume that "exit" within an embedded script will simply bubble out the exit status as the script's result. Yoko: I'm interested in your thoughts. Meanwhile, I'm fixing it this way.
        Hide
        Charles Oliver Nutter added a comment -

        master@a039e80 and jruby-1_6@62b67c7

        Show
        Charles Oliver Nutter added a comment - master@a039e80 and jruby-1_6@62b67c7
        Hide
        Yoko Harada added a comment -

        Thanks Charlie. I agree with you about exit status. Nobody mentioned before, so I didn't notice that.

        Show
        Yoko Harada added a comment - Thanks Charlie. I agree with you about exit status. Nobody mentioned before, so I didn't notice that.

          People

          • Assignee:
            Yoko Harada
            Reporter:
            Trejkaz
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: