Timeout::timeout is broken when Java Integration is used
--------------------------------------------------------

                 Key: JRUBY-2148
                 URL: http://jira.codehaus.org/browse/JRUBY-2148
             Project: JRuby
          Issue Type: Bug
          Components: Java Integration
    Affects Versions: JRuby 1.1RC2
         Environment: Solaris10 + JDK6
            Reporter: Igor Minar
         Attachments: LongProcess.class, LongProcess.java

I tried to use Timeout::timeout in my code, to time out an execution of a Java 
code and I noticed that this doesn't work and the behavior differs between 
JRuby 1.1RC2 and JRuby 1.0.3.

Here is the code
{code}
include Java
include_class 'LongProcess'
require 'benchmark'
require 'timeout'

# measure the execution and print results
Benchmark.measure { 
  begin
    # timeout the operation after one second
    Timeout::timeout(1) { LongProcess.run(1000000000) }
  rescue Timeout::Error => e
    puts e
  end 
}.to_s
{code}

JRuby 1.0.3 Result:
{code}
execution expired
=> "  3.612000   0.000000   3.612000 (  3.612000)\n"
{code}

JRuby 1.1RC2 Result:
{code}
=> "  3.842000   0.000000   3.842000 (  3.842833)\n"
{code}
no that the Timeout::Error exception was not thrown


Expected result:
{code}
execution expired
=> "  1.??????   0.000000   1.?????? ( 1.??????)\n"
{code}

Timeout::timeout should interrupt the execution of the Java code, yielding the 
total run time just a bit over one second, but that apparently doesn't happen.

I'm attaching the a simple Java class LongProcess that runs a mathematical 
operations in loop to waste some time. Make sure that this class in on the 
CLASSPATH before running the code above.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.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