Permalink
Browse files

fix exception handling for jruby 1.7

  • Loading branch information...
1 parent 7a8b11f commit 7588bf9f5060dfaf01077dd8712732ff4b9cc10d @dynamix dynamix committed Nov 12, 2012
Showing with 20 additions and 12 deletions.
  1. +3 −4 Gemfile
  2. +17 −8 java/java_base.rb
View
@@ -5,11 +5,10 @@ gemspec
gem 'rake', '~> 0.9.0'
group :test do
- gem "rspec", "~> 2.8.0"
- gem 'eventmachine', '1.0.0.beta.4'
+ gem "rspec" , "~> 2.11"
+ gem 'eventmachine', '1.0.0'
gem 'evented-spec', '~> 0.9.0'
-
- gem 'zk-server', '~> 1.0.0'
+ gem 'zk-server', '~> 1.1.4'
end
# ffs, :platform appears to be COMLETELY BROKEN so we just DO THAT HERE
View
@@ -440,17 +440,26 @@ def jzk
@mutex.synchronize { @jzk }
end
- def handle_keeper_exception
- yield
- rescue JZK::KeeperException => e
- if e.respond_to?(:cause) and e.cause and e.cause.respond_to?(:code) and e.cause.code and e.cause.code.respond_to?(:intValue)
- e.cause.code.intValue
- else
- raise e # dunno what happened, just raise it
+ # java exceptions are not wrapped anymore in JRuby 1.7+
+ if JRUBY_VERSION >= '1.7.0'
+ def handle_keeper_exception
+ yield
+ rescue JZK::KeeperException => e
+ # code is an enum and always set -> we don't need any additional checks here
+ e.code.intValue
+ end
+ else
+ def handle_keeper_exception
+ yield
+ rescue JZK::KeeperException => e
+ if e.respond_to?(:cause) and e.cause and e.cause.respond_to?(:code) and e.cause.code and e.cause.code.respond_to?(:intValue)
+ e.cause.code.intValue
+ else
+ raise e # dunno what happened, just raise it
+ end
end
end
-
def call_type(callback, watcher)
if callback
watcher ? :async_watch : :async

0 comments on commit 7588bf9

Please sign in to comment.