mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -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)
|
@metadata_accessors.set(fieldref[METADATA_BRACKETS.length .. -1], value)
|
||||||
elsif fieldref == METADATA
|
elsif fieldref == METADATA
|
||||||
@metadata = value
|
@metadata = value
|
||||||
|
@metadata_accessors = LogStash::Util::Accessors.new(@metadata)
|
||||||
else
|
else
|
||||||
@accessors.set(fieldref, value)
|
@accessors.set(fieldref, value)
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,6 +38,11 @@ describe LogStash::Event do
|
||||||
expect(subject["[foo][bar]"] = "zab").to eq("zab")
|
expect(subject["[foo][bar]"] = "zab").to eq("zab")
|
||||||
expect(subject["[foo][bar]"]).to eq("zab")
|
expect(subject["[foo][bar]"]).to eq("zab")
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context "#sprintf" do
|
context "#sprintf" do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue