Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix race condition in CommandMap#prefix #322

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ appear at the top.
[PR #319](https://github.com/capistrano/sshkit/pull/319) @mattbrictson
* Add `SSHKit.config.default_runner` options that allows to override default command runner.
This option also accepts a name of the custom runner class.
* Fix a race condition experienced in JRuby that could cause multi-server
deploys to fail. [PR #322](https://github.com/capistrano/sshkit/pull/322)
@mattbrictson

## 1.8.1

Expand Down
2 changes: 0 additions & 2 deletions lib/sshkit/command_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ def initialize

def [](command)
@storage[command] ||= []

@storage[command]
end
end

Expand Down
9 changes: 9 additions & 0 deletions test/unit/test_command_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,14 @@ def test_indifferent_prefix
assert_equal map[:rake], "/home/vagrant/.rbenv/bin/rbenv exec bundle exec rake"
end

def test_prefix_initialization_is_thread_safe
map = CommandMap.new
threads = Array.new(3) do
Thread.new do
(1..1_000).each { |i| assert_equal([], map.prefix[i.to_s]) }
end
end
threads.each(&:join)
end
end
end