Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exceptions thrown by Ruby not propagated to calling Ruby when some Java involved in between #2232

Closed
gmalkas opened this Issue Nov 24, 2014 · 0 comments

Comments

Projects
None yet
3 participants
@gmalkas
Copy link

commented Nov 24, 2014

It seems that exceptions thrown by Ruby code are not propagated to the calling Ruby method when some Java code is involved in between.

Proof of concept: https://github.com/gmalkas/jruby-uncaught-exception-issue/blob/master/not_working.rb

Run the test:

  $ git clone git@github.com:gmalkas/jruby-uncaught-exception-issue.git && cd jruby-uncaught-exception-issue
  $ bundle && ./not_working.rb

The previous code should print Rescued StandardError twice but does not.

On the other hand, if the rescuing Ruby code is calling the failing code directly (without involving Java code), it works as expected: https://github.com/gmalkas/jruby-uncaught-exception-issue/blob/master/working.rb

Version information: jruby 1.7.16 (1.9.3p392) 2014-09-25 575b395 on Java HotSpot(TM) 64-Bit Server VM 1.8.0_25-b17 +jit [linux-amd64]

Let me know if you need any additional information.

Thank you!

@kares kares changed the title Uncaught Ruby Exception on JRuby 1.7.16 exceptions thrown by Ruby not propagated to calling Ruby when some Java involved in between Aug 16, 2015

@kares kares self-assigned this Aug 17, 2015

kares added a commit to kares/jruby that referenced this issue Aug 17, 2015

base compareTo should not silence all Ruby raised exceptions (fixes j…
…ruby#2232)

this no longer makese sense - and leads to confusing behavior when Ruby objects are used within Java (delegating to <=> which might be user-defined)

every-one is expected to handle <=> on 1.9 (and return nil if not comparable)
on 1.8 we still swallow a NoMethodError as Object does not provide <=>

@kares kares added this to the JRuby 1.7.22 milestone Aug 17, 2015

@kares kares closed this in 771afb0 Aug 18, 2015

kares added a commit that referenced this issue Aug 18, 2015

Merge branch 'jruby-1_7'
* jruby-1_7:
  some more comparable asserts including for the Java compareTo part
  native RubySymbol#compareTo since we expect to always be able to sort
  should not-rewrite jump exceptions twice as well (not just raise ones)
  delete un-used imports
  [ji] do not rewrite stack-trace twice for Ruby (raise) exceptions
  base compareTo should not silence all Ruby raised exceptions (fixes #2232)
  re-arrange rescue spec (we're about to spec some more behavior)
  only test nil return from Object cmp on 1.9 (on 1.8.7 its expected to raise)
  more of correct $! restore + use get/setErrorInfo for better predictability
  another incorrect $! with numeric coercion on <=> + cleanup getRuntime()
  Fix some consumers for #1601.  Don't leak out  if we are swallowing the raised exception

Conflicts:
	core/src/main/java/org/jruby/Main.java
	core/src/main/java/org/jruby/RubyBasicObject.java
	core/src/main/java/org/jruby/RubyClass.java
	core/src/main/java/org/jruby/RubyComparable.java
	core/src/main/java/org/jruby/RubyNumeric.java
	core/src/main/java/org/jruby/RubySymbol.java
	core/src/main/java/org/jruby/RubyTime.java
	core/src/main/java/org/jruby/javasupport/JavaCallable.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.