Permalink
Browse files

fix all embarassing EOL rescues that didn't do what I thought they did

seriously? c'mon Matz! "Principle of Least Surprise" and all that!
  • Loading branch information...
1 parent ef615b4 commit 5f507f7e007c7b0b1b71652c60d0da9197e4ca21 @slyphon slyphon committed May 9, 2012
@@ -13,7 +13,10 @@ def do_something_with(data)
end
def run
- @zk.delete(@path) rescue ZK::Exceptions::NoNode
+ begin
+ @zk.delete(@path)
+ rescue ZK::Exceptions::NoNode
+ end
@zk.register(@path) do |event|
if event.node_changed? or event.node_created?
@@ -23,7 +23,11 @@ def run
end
end
- @zk.delete(@path) rescue ZK::Exceptions::NoNode
+ begin
+ @zk.delete(@path)
+ rescue ZK::Exceptions::NoNode
+ end
+
@zk.stat(@path, watch: true)
@zk.create(@path, 'Hello, events!')
View
@@ -743,7 +743,11 @@ def set_debug_level(level)
num =
case level
when String, Symbol
- ZookeeperBase.const_get(:"ZOO_LOG_LEVEL_#{level.to_s.upcase}") rescue NameError
+ begin
+ ZookeeperBase.const_get(:"ZOO_LOG_LEVEL_#{level.to_s.upcase}")
+ rescue NameError
+ nil
+ end
when Integer
level
end
View
@@ -239,7 +239,8 @@ def vote!
protected
# the inauguration, as it were
def acknowledge_win!
- @zk.create(leader_ack_path, @data, :ephemeral => true) rescue Exceptions::NodeExists
+ @zk.create(leader_ack_path, @data, :ephemeral => true)
+ rescue Exceptions::NodeExists
end
# return the list of ephemeral vote nodes
@@ -256,7 +256,12 @@ def create_lock_path!(prefix='lock')
def cleanup_lock_path!
logger.debug { "removing lock path #{@lock_path}" }
zk.delete(@lock_path)
- zk.delete(root_lock_path) rescue NotEmpty
+
+ begin
+ zk.delete(root_lock_path)
+ rescue NotEmpty
+ end
+
@lock_path = nil
end
end # LockerBase
View
@@ -120,9 +120,17 @@ def destroy!
locks << lock
end
children.each do |path|
- @zk.delete("#{full_queue_path}/#{path}") rescue ZK::Exceptions::NoNode
+ begin
+ @zk.delete("#{full_queue_path}/#{path}")
+ rescue ZK::Exceptions::NoNode
+ end
end
- @zk.delete(full_queue_path) rescue ZK::Exceptions::NoNode
+
+ begin
+ @zk.delete(full_queue_path)
+ rescue ZK::Exceptions::NoNode
+ end
+
locks.each do |lock|
lock.unlock!
end
@@ -69,7 +69,10 @@ def fork_it!
ensure
if pid
_debug "ensuring #{pid} is really dead"
- Process.kill(9, pid) rescue Errno::ESRCH
+ begin
+ Process.kill(9, pid)
+ rescue Errno::ESRCH
+ end
end
end
View
@@ -28,7 +28,10 @@
report_realtime("closing") do
ZK.open("localhost:#{ZK.test_port}") do |zk|
- zk.delete('/test_pool') rescue ZK::Exceptions::NoNode
+ begin
+ zk.delete('/test_pool')
+ rescue ZK::Exceptions::NoNode
+ end
end
end
end
@@ -119,7 +122,10 @@
@path = '/_testWatch'
@connection_pool.with_connection do |zk|
- zk.delete(@path) rescue ZK::Exceptions::NoNode
+ begin
+ zk.delete(@path)
+ rescue ZK::Exceptions::NoNode
+ end
end
@connection_pool.with_connection do |zk|
View
@@ -2,7 +2,10 @@
shared_examples_for 'ZK basic' do
before do
- @zk.create(@base_path) rescue ZK::Exceptions::NodeExists
+ begin
+ @zk.create(@base_path)
+ rescue ZK::Exceptions::NodeExists
+ end
end
describe ZK, "with no paths" do

0 comments on commit 5f507f7

Please sign in to comment.