Skip to content

Commit

Permalink
Do not return an empty metadata key hash when calling to_hash_with_me…
Browse files Browse the repository at this point in the history
…tadata

Fixes elastic#3034
  • Loading branch information
ph authored and jordansissel committed Apr 20, 2015
1 parent 0b72d06 commit cc3f9d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 1 addition & 5 deletions lib/logstash/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,7 @@ def init_timestamp(o)

public
def to_hash_with_metadata
if @metadata.nil?
to_hash
else
to_hash.merge(METADATA => @metadata)
end
@metadata.empty? ? to_hash : to_hash.merge(METADATA => @metadata)
end

public
Expand Down
4 changes: 4 additions & 0 deletions spec/core/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@
it "should still allow normal field access" do
expect(subject["foo"]).to eq("bar")
end

it "should not include the @metadata key" do
expect(subject.to_hash_with_metadata).not_to include("@metadata")
end
end
end

Expand Down

0 comments on commit cc3f9d6

Please sign in to comment.