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:
Colin Surprenant 2015-11-25 02:09:21 -05:00
parent ab2eae0c5a
commit 3690944e49
3 changed files with 13 additions and 0 deletions

View file

@ -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

View file

@ -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());
}

View file

@ -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