Skip to content
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
2 changes: 1 addition & 1 deletion lib/appmap/value_inspector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module ValueInspector

def detect_size(value)
# Don't risk calling #size on things like data-access objects, which can and will issue queries for this information.
if value.is_a?(Array) || value.is_a?(Hash)
if (value.is_a?(Array) || value.is_a?(Hash)) && value.respond_to?(:size)
value.size
end
end
Expand Down
18 changes: 18 additions & 0 deletions spec/value_inspector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,22 @@
)
end
end

describe "Array that doesn't implement :size" do
it 'does not try and invoke :size' do
ary = []
class << ary
def respond_to?(method)
return false if method.to_sym == :size

super
end
end

inspector = Struct.new(:id) do
include AppMap::ValueInspector
end.new
expect(inspector.detect_size(ary)).to be_nil
end
end
end