mirror of
https://github.com/dkam/suo.git
synced 2025-01-29 07:42:43 +00:00
handle invalid lock data
This commit is contained in:
@@ -123,7 +123,7 @@ module Suo
|
||||
fail NotImplementedError
|
||||
end
|
||||
|
||||
def initial_set(key) # rubocop:disable Lint/UnusedMethodArgument
|
||||
def initial_set(key, val = "") # rubocop:disable Lint/UnusedMethodArgument
|
||||
fail NotImplementedError
|
||||
end
|
||||
|
||||
@@ -162,7 +162,7 @@ module Suo
|
||||
unpacked.map do |time, token|
|
||||
[Time.at(time), token]
|
||||
end
|
||||
rescue EOFError => _
|
||||
rescue EOFError, MessagePack::MalformedFormatError => _
|
||||
[]
|
||||
end
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ module Suo
|
||||
@client.set_cas(key, newval, cas)
|
||||
end
|
||||
|
||||
def initial_set(key)
|
||||
@client.set(key, "")
|
||||
def initial_set(key, val = "")
|
||||
@client.set(key, val)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,8 +32,8 @@ module Suo
|
||||
@client.unwatch
|
||||
end
|
||||
|
||||
def initial_set(key)
|
||||
@client.set(key, "")
|
||||
def initial_set(key, val = "")
|
||||
@client.set(key, val)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,6 +31,12 @@ module ClientTests
|
||||
assert_equal false, locked
|
||||
end
|
||||
|
||||
def test_empty_lock_on_invalid_data
|
||||
@client.send(:initial_set, TEST_KEY, "bad value")
|
||||
locked = @client.locked?(TEST_KEY)
|
||||
assert_equal false, locked
|
||||
end
|
||||
|
||||
def test_clear
|
||||
lock1 = @client.lock(TEST_KEY, 1)
|
||||
refute_nil lock1
|
||||
|
||||
Reference in New Issue
Block a user