diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ad705f6..5a2a9f6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/sshkit/command_map.rb b/lib/sshkit/command_map.rb index 13dedcd8..fde164b4 100644 --- a/lib/sshkit/command_map.rb +++ b/lib/sshkit/command_map.rb @@ -28,8 +28,6 @@ def initialize def [](command) @storage[command] ||= [] - - @storage[command] end end diff --git a/test/unit/test_command_map.rb b/test/unit/test_command_map.rb index eb0e46d0..65e85f93 100644 --- a/test/unit/test_command_map.rb +++ b/test/unit/test_command_map.rb @@ -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