[discuss] Event field value mutability
- Dominant language
- Java
- Stars
- 14.9k
- Forks
- 3.5k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 88
Description
I just became aware of issues #7662 and #7663.
In #7662 it was demonstrated that mutating a String field value extracted from the event using `Event.get` did not have a consistent behaviour on both the Ruby and Java sides when re-reading the same field value but without updating it using `Event.set` after the mutation.
When we introduced the new `Event` getter and setter, it was in part to emphasize on the **undefined behaviour** of in-place mutating an `Event` field value.
**Currently** the only way to make sure the `Event` has a consistent field value is to set it back in the `Event`. So for me #7662 does not look like a bug but maybe more a lack of documentation?
The spec in #7662 should be instead:
```
it "should propagate changes using setter" do
e = LogStash::Event.new()
e.to_java.setField("foo", "bar")
expect(e.get("foo")).to eq("bar")
s = e.get("foo")
s.gsub!(/bar/, 'pff')
e.set("foo", s)
expect(e.get("foo")).to eq("pff")
expect(e.to_java.getField("foo")).to eq("pff")
end
```
The **undefined behaviour** of in-place mutation of a field value has been discussed and agreed upon some time ago. I would like us to make sure we are in sync on this before potentially engaging in more work in that area.
@original-brownbear @guyboertje @jsvd @jordansissel
Contributor guide
Research direction
Start by reading issues #7662 and #7663, then inspect the Event.get, Event.set, setField, and getField behavior described in the thread. The issue does not name documentation files or tests; completion would require an agreed statement of the mutation semantics and corresponding documentation or specification update.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, ruby
- Domain
- backend
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100