Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessors path invalidation problem #5127

Closed
colinsurprenant opened this issue Apr 15, 2016 · 1 comment · Fixed by #5132
Closed

Accessors path invalidation problem #5127

colinsurprenant opened this issue Apr 15, 2016 · 1 comment · Fixed by #5132
Labels

Comments

@colinsurprenant
Copy link
Contributor

This problem was originally reported by @guyboertje in #5212. I am copying the invalidation bug sequence here:

> event = LogStash::Event.new
=> #<LogStash::Event:0x25ce435 @metadata_accessors=#<LogStash::Util::Accessors:0x7ea71fc2 @store={}, @lut={}>, @cancelled=false, @data={"@version"=>"1", "@timestamp"=>"2016-04-15T14:19:31.561Z"}, @metadata={}, @accessors=#<LogStash::Util::Accessors:0x7cd5fcf4 @store={"@version"=>"1", "@timestamp"=>"2016-04-15T14:19:31.561Z"}, @lut={}>>
> event["[a][0]"]
=> nil
> event["[a][0]"] = 42
=> 42
> event["[a]"]
=> {"0"=>42}
> event["[a]"] = [42,24]
=> [42, 24]
> event["[a]"]
=> [42, 24]
> event["[a][0]"]
=> 42
> event["[a]"] = [24,42]
=> [24, 42]
> event["[a][0]"]
=> 42
> event["[a][0]"] = {"a"=> 99, "b" => 98}
=> {"a"=>99, "b"=>98}
> event["[a][0]"]
=> {"a"=>99, "b"=>98}
> event["[a]"]
=> [24, 42]
> event["[a][0]"]
=> {"a"=>99, "b"=>98}
> event["[a][0][b]"]
TypeError: can't convert String into Integer
  from org/jruby/RubyFixnum.java:1143:in `[]'

I wrote a spec with this sequence and confirm the problem on both the Ruby and Java Event implementations.

@colinsurprenant
Copy link
Contributor Author

The following spec sequence is basically the test above.

expect(event["[a][0]"]).to be_nil

expect(event["[a][0]"] = 42).to eq(42)
expect(event["[a][0]"]).to eq(42)
expect(event["[a]"]).to eq({"0" => 42})

expect(event["[a]"] = [42, 24]).to eq([42, 24])
expect(event["[a]"]).to eq([42, 24])

expect(event["[a][0]"]).to eq(42)

expect(event["[a]"] = [24, 42]).to eq([24, 42])
expect(event["[a][0]"]).to eq(24)

expect(event["[a][0]"] = {"a "=> 99, "b" => 98}).to eq({"a "=> 99, "b" => 98})
expect(event["[a][0]"]).to eq({"a "=> 99, "b" => 98})

expect(event["[a]"]).to eq([{"a "=> 99, "b" => 98}, 42])
expect(event["[a][0]"]).to eq({"a "=> 99, "b" => 98})
expect(event["[a][1]"]).to eq(42)
expect(event["[a][0][b]"]).to eq(98)
  • it fails as-is using both Ruby and Java Event implementations
  • it passes by removing the @lut caching in the Ruby Accessors class

I will see if/how we can invalidate the @lut only when required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant