Skip to content

Useless and error code logic which leads to bad performance #1721

Open
@wilder-misfit

Description

@wilder-misfit

Steps to reproduce

Please add the following test case to active_record_test.rb

def test_cache
      first_comment = Comment.new(id: 1, content: 'ZOMG A COMMENT')
      comment_first_serializer = CommentSerializer.new(first_comment)
      x = comment_first_serializer.as_json
      sec_comment = Comment.new(id: 2, content: 'ZOMG B COMMENT')
      comment_sec_serializer = CommentSerializer.new(sec_comment)
      y =comment_sec_serializer.as_json
end

Additonal helpful information

When the test case calls the method as_json and then it calls instrument, there is a statement as following,

payload = instrumentation_keys.inject({ serializer: self.class.name }) do |payload, key|
        payload[:payload] = self.instance_variable_get(:"@#{key}")
        payload
end

this statement will set the field :payload of payload hash to be the last value of instrumentation_keys.

This problem exists in v0.9.4 & 0.9.5

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions