mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
Fix bug LOGSTASH-1225 "Cannot Clone Fixnum"
The clone {} filter will throw an exception if any of the values in the event map are numbers. Problem is that numbers are not clonable. This is a single-line fix that wraps the .clone call in a try block and does a simple set-by-value if the clone raises an exception. Included under spec/filters/clone.rb is a test case that fails without the change in lib/logstash/event.rb and passes with the fix applied.
This commit is contained in:
parent
fa27dc9fcf
commit
b783f9ded8
2 changed files with 17 additions and 1 deletions
|
@ -85,7 +85,7 @@ class LogStash::Event
|
|||
copy = {}
|
||||
@data.each do |k,v|
|
||||
# TODO(sissel): Recurse if this is a hash/array?
|
||||
copy[k] = v.clone
|
||||
copy[k] = begin v.clone rescue v end
|
||||
end
|
||||
return self.class.new(copy)
|
||||
end # def clone
|
||||
|
|
|
@ -64,4 +64,20 @@ describe LogStash::Filters::Clone do
|
|||
|
||||
end
|
||||
end
|
||||
|
||||
describe "Bug LOGSTASH-1225" do
|
||||
### LOGSTASH-1225: Cannot clone events containing numbers.
|
||||
config <<-CONFIG
|
||||
filter {
|
||||
clone {
|
||||
clones => [ 'clone1' ]
|
||||
}
|
||||
}
|
||||
CONFIG
|
||||
|
||||
sample("type" => "bug-1225", "message" => "unused", "number" => 5) do
|
||||
insist { subject[0]["number"] } == 5
|
||||
insist { subject[1]["number"] } == 5
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue