Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.6.4
-
Fix Version/s: JRuby 1.7.0.pre1
-
Component/s: Java Integration
-
Labels:None
-
Environment:JRuby 1.6.4,
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03-384-10M3425)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-384, mixed mode)
-
Testcase included:yes
-
Patch Submitted:Yes
-
Number of attachments :
Description
Discussed this on twitter with @headius and @technomancy a bit. Clojure's STM uses exceptions for retries within a transaction (clojure.lang.LockingTransaction$RetryEx). When these exceptions pass through JRuby, they're wrapped, causing the STM transaction logic higher up the stack to fail since it can't catch the retry exceptions any more.
So, I'm partly just reporting the issue, but I was able to create a fairly simple test case (no Clojure or threads) and very naive solution. It's just a Set of unrescuable exception types in JavaSupport, extendable by Ruby code. I'm sure this is wrong in many ways since I've never looked at the JRuby source before, but it was an interesting exercise ![]()
Example and patch attached.
I think the simplest answer might be to have a JRuby ext that wraps the Clojure STM and allows the exceptions to propagate out. Current Java integration in JRuby can't support propagating the actual exception (because people have dependencies on the wrapper) and there are some tricky issues to move that direction in the future.