diff --git a/gems/smithy-client/lib/smithy-client/features.rb b/gems/smithy-client/lib/smithy-client/features.rb index f60321fd6..262e312f8 100644 --- a/gems/smithy-client/lib/smithy-client/features.rb +++ b/gems/smithy-client/lib/smithy-client/features.rb @@ -6,15 +6,16 @@ module Client module Features class << self def track(*features, &block) - Thread.current[:smithy_ruby_features] ||= [] - Thread.current[:smithy_ruby_features].concat(features) + Thread.current[:smithy_ruby_features] ||= Set.new + added = features.map { |f| Thread.current[:smithy_ruby_features].add?(f) } block.call ensure - Thread.current[:smithy_ruby_features].pop(features.size) + features.each_with_index { |f, i| Thread.current[:smithy_ruby_features].delete(f) if added[i] } end def tracked - Thread.current[:smithy_ruby_features] || [] + Thread.current[:smithy_ruby_features] || Set.new + Thread.current[:smithy_ruby_features].to_a end end end diff --git a/gems/smithy-client/spec/smithy-client/features_spec.rb b/gems/smithy-client/spec/smithy-client/features_spec.rb index 6f89bbaed..df0f21839 100644 --- a/gems/smithy-client/spec/smithy-client/features_spec.rb +++ b/gems/smithy-client/spec/smithy-client/features_spec.rb @@ -57,6 +57,17 @@ module Client end expect(Features.tracked).to be_empty end + + it 'does not track duplicate features' do + Features.track('A', 'B') do + expect(Features.tracked).to eq(%w[A B]) + Features.track('A') do + expect(Features.tracked).to eq(%w[A B]) + end + expect(Features.tracked).to eq(%w[A B]) + end + expect(Features.tracked).to be_empty + end end end end diff --git a/projections/shapes/lib/shapes/client.rb b/projections/shapes/lib/shapes/client.rb index 455cceec2..68c72a96e 100644 --- a/projections/shapes/lib/shapes/client.rb +++ b/projections/shapes/lib/shapes/client.rb @@ -161,8 +161,7 @@ class Client < Smithy::Client::Base # @option options [Boolean] :stub_responses # When `true`, the client will return stubbed responses instead of networking requests. # By default fake responses are generated and returned. You can specify the response data - # to return or errors to raise by calling {Stubs#stub_responses}. - # @see Stubs + # to return or errors to raise by calling {Smithy::Client::Stubs#stub_responses}. # @option options [String] :user_agent_suffix # An optional string that is appended to the User-Agent header. # The default User-Agent includes the smithy-client version, diff --git a/projections/weather/lib/weather/client.rb b/projections/weather/lib/weather/client.rb index 059e2f5cc..1136a3d93 100644 --- a/projections/weather/lib/weather/client.rb +++ b/projections/weather/lib/weather/client.rb @@ -161,8 +161,7 @@ class Client < Smithy::Client::Base # @option options [Boolean] :stub_responses # When `true`, the client will return stubbed responses instead of networking requests. # By default fake responses are generated and returned. You can specify the response data - # to return or errors to raise by calling {Stubs#stub_responses}. - # @see Stubs + # to return or errors to raise by calling {Smithy::Client::Stubs#stub_responses}. # @option options [String] :user_agent_suffix # An optional string that is appended to the User-Agent header. # The default User-Agent includes the smithy-client version,