use method-level ensure blocks

Fixes #10872
This commit is contained in:
Dan Hermann 2019-06-28 07:12:15 -05:00
parent 1802869d80
commit 46c1611dff

View file

@ -48,7 +48,6 @@ module LogStash
# @return [Boolean] new pipeline creation success
def create_pipeline(pipeline_id, pipeline, &create_block)
lock = get_lock(pipeline_id)
begin
lock.lock
success = false
@ -71,7 +70,6 @@ module LogStash
ensure
lock.unlock
end
end
# Execute the passed termination logic block
# @param pipeline_id [String, Symbol] the pipeline id
@ -80,7 +78,6 @@ module LogStash
# @yieldparam [Pipeline] the pipeline to terminate
def terminate_pipeline(pipeline_id, &stop_block)
lock = get_lock(pipeline_id)
begin
lock.lock
state = @states.get(pipeline_id)
@ -94,7 +91,6 @@ module LogStash
ensure
lock.unlock
end
end
# Execute the passed reloading logic block in the context of the reloading state and set new pipeline in state
# @param pipeline_id [String, Symbol] the pipeline id
@ -105,7 +101,6 @@ module LogStash
# @return [Boolean] new pipeline creation success
def reload_pipeline(pipeline_id, &reload_block)
lock = get_lock(pipeline_id)
begin
lock.lock
success = false
@ -128,7 +123,6 @@ module LogStash
ensure
lock.unlock
end
end
# @param pipeline_id [String, Symbol] the pipeline id
# @return [Pipeline] the pipeline object or nil if none for pipeline_id