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
|
fail NotImplementedError
|
||||||
end
|
end
|
||||||
|
|
||||||
def initial_set(key) # rubocop:disable Lint/UnusedMethodArgument
|
def initial_set(key, val = "") # rubocop:disable Lint/UnusedMethodArgument
|
||||||
fail NotImplementedError
|
fail NotImplementedError
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ module Suo
|
|||||||
unpacked.map do |time, token|
|
unpacked.map do |time, token|
|
||||||
[Time.at(time), token]
|
[Time.at(time), token]
|
||||||
end
|
end
|
||||||
rescue EOFError => _
|
rescue EOFError, MessagePack::MalformedFormatError => _
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ module Suo
|
|||||||
@client.set_cas(key, newval, cas)
|
@client.set_cas(key, newval, cas)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initial_set(key)
|
def initial_set(key, val = "")
|
||||||
@client.set(key, "")
|
@client.set(key, val)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ module Suo
|
|||||||
@client.unwatch
|
@client.unwatch
|
||||||
end
|
end
|
||||||
|
|
||||||
def initial_set(key)
|
def initial_set(key, val = "")
|
||||||
@client.set(key, "")
|
@client.set(key, val)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -31,6 +31,12 @@ module ClientTests
|
|||||||
assert_equal false, locked
|
assert_equal false, locked
|
||||||
end
|
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
|
def test_clear
|
||||||
lock1 = @client.lock(TEST_KEY, 1)
|
lock1 = @client.lock(TEST_KEY, 1)
|
||||||
refute_nil lock1
|
refute_nil lock1
|
||||||
|
|||||||
Reference in New Issue
Block a user