mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
Clean backport of #13603 to branch 7.17
(cherry picked from commit e27fdeb252
)
----
Original commit message:
Sometime the deep_replace could be invoked by plugins, using the LogStash::Config::Mixin#validate.
This method receives a Ruby hash which could contains Java ArrayList instead of Ruby Array.
The iteration method `each_index` is not available for ArrayList, so resort to some form of "plain old way".
The reason why an ArrayList is recognized as a Ruby Array is due to the override classes, like RubyJavaIntegration.JavaCollectionOverride that monkey patches Ruby Array, so that a Java Collection could be seen as a RubyArray but it doesn't implement all the abstractions, like `each_index`.
Co-authored-by: Karol Bucek <kares@users.noreply.github.com>
Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>
This commit is contained in:
parent
d1e2816c47
commit
236cbcaade
1 changed files with 3 additions and 2 deletions
|
@ -37,8 +37,9 @@ module ::LogStash::Util::SubstitutionVariables
|
|||
end
|
||||
else
|
||||
if value.is_a?(Array)
|
||||
value.each_index do | valueArrayIndex|
|
||||
value[valueArrayIndex] = deep_replace(value[valueArrayIndex])
|
||||
value_array_index = 0
|
||||
value.each_with_index do |single_value, i|
|
||||
value[i] = deep_replace(single_value)
|
||||
end
|
||||
else
|
||||
return replace_placeholders(value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue