mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
Initialize the metadata_accessors
when setting the @metadata with a hash
Fixes #3198
This commit is contained in:
parent
1f7d3f550e
commit
fe99f45499
2 changed files with 6 additions and 0 deletions
|
@ -141,6 +141,7 @@ class LogStash::Event
|
|||
@metadata_accessors.set(fieldref[METADATA_BRACKETS.length .. -1], value)
|
||||
elsif fieldref == METADATA
|
||||
@metadata = value
|
||||
@metadata_accessors = LogStash::Util::Accessors.new(@metadata)
|
||||
else
|
||||
@accessors.set(fieldref, value)
|
||||
end
|
||||
|
|
|
@ -38,6 +38,11 @@ describe LogStash::Event do
|
|||
expect(subject["[foo][bar]"] = "zab").to eq("zab")
|
||||
expect(subject["[foo][bar]"]).to eq("zab")
|
||||
end
|
||||
|
||||
it "allow to set the @metadata key to a hash" do
|
||||
subject["@metadata"] = { "action" => "index" }
|
||||
expect(subject["[@metadata][action]"]).to eq("index")
|
||||
end
|
||||
end
|
||||
|
||||
context "#sprintf" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue