mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
fix nil value field reference assignment in Java Event
fix fieldref nil value assignment add fieldref nil value assignment spec better spec description and better expectation
This commit is contained in:
parent
ab2eae0c5a
commit
3690944e49
3 changed files with 13 additions and 0 deletions
|
@ -90,6 +90,12 @@ describe LogStash::Event do
|
|||
expect(e["[foo][2]"]).to eq(1.0)
|
||||
expect(e["[foo][3]"]).to be_nil
|
||||
end
|
||||
|
||||
it "should add key when setting nil value" do
|
||||
e = LogStash::Event.new()
|
||||
e["[foo]"] = nil
|
||||
expect(e.to_hash).to include("foo" => nil)
|
||||
end
|
||||
end
|
||||
|
||||
context "timestamp" do
|
||||
|
|
|
@ -155,6 +155,8 @@ public class JrubyEventExtLibrary implements Library {
|
|||
this.event.setField(r, RubyToJavaConverter.convertToList((RubyArray) value));
|
||||
} else if (value instanceof RubyHash) {
|
||||
this.event.setField(r, RubyToJavaConverter.convertToMap((RubyHash) value));
|
||||
} else if (value.isNil()) {
|
||||
this.event.setField(r, null);
|
||||
} else {
|
||||
throw context.runtime.newTypeError("wrong argument type " + value.getMetaClass());
|
||||
}
|
||||
|
|
|
@ -44,6 +44,11 @@ describe LogStash::Event do
|
|||
subject["@metadata"] = { "action" => "index" }
|
||||
expect(subject["[@metadata][action]"]).to eq("index")
|
||||
end
|
||||
|
||||
it "should add key when setting nil value" do
|
||||
subject["[baz]"] = nil
|
||||
expect(subject.to_hash).to include("baz" => nil)
|
||||
end
|
||||
end
|
||||
|
||||
context "#sprintf" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue