fix #1. avoid marking as closed if do_close raise exception

This commit is contained in:
Brian J. Cardiff 2016-06-24 10:54:30 -03:00
parent 933014c1aa
commit 6838784f7b
2 changed files with 33 additions and 1 deletions

View file

@ -8,8 +8,8 @@ module DB
# Closes this object.
def close
return if @closed
@closed = true
do_close
@closed = true
end
# Returns `true` if this object is closed. See `#close`.
@ -18,6 +18,7 @@ module DB
end
# Implementors overrides this method to perform resource cleanup
# If an exception is raised, the resource will not be marked as closed.
protected abstract def do_close
end
end