Remove no-op code, protect global space from test code #86
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm working on a different PR (that's potentially contentious) and found some accidentally-working code.
Maybe middleware/sever/unique_jobs.rb#call was intended to release the lock if
However,
(unlocked != 1)
will always be true because (without exceptions)unlocked
will either be integer0
or string"1"
or maybe string"\"1\""
because of the call to.inspect()
This code happened to to leave the lock in place if
option['unique_unlock_order'] == :never
because!defined? unlocked || unlocked != 1
is the same as!defined?(unlocked || unlocked != 1)
not!defined?(unlocked) || (unlocked != 1)
I spent some time thinking about how to write a test case to demonstrate, but I think that may not be possible since even if I stub one of the methods before the
unlocked
assignment to raise,unlocked
is still a defined local_variable.If the design was to unlock on exception, then that logic ought to go into
after_yield?
with a side-effect fromunlock(payload_hash)
and maybe add anever_unlock?
oralways_unlock?
method.as for unique_jobs_spec.rb, "when get_sidekiq_options[:unique_unlock_order] is nil" has an order-dependency on being run before any
.sidekiq_options unique_unlock_order: :before_yield
etc so I made the tests clone UniqueWorker before modifying class_variables