diff --git a/.travis.yml b/.travis.yml index 54a0a14..a582432 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,5 +5,5 @@ import: env: jobs: # lock on version 8.x because use Ruby 2.6.0 available from 8.4.0 - - ELASTIC_STACK_VERSION=8.x DOCKER_ENV=dockerjdk17.env - - SNAPSHOT=true ELASTIC_STACK_VERSION=8.x DOCKER_ENV=dockerjdk17.env \ No newline at end of file + - ELASTIC_STACK_VERSION=8.x DOCKER_ENV=dockerjdk21.env + - SNAPSHOT=true ELASTIC_STACK_VERSION=8.x DOCKER_ENV=dockerjdk21.env diff --git a/CHANGELOG.md b/CHANGELOG.md index 1730584..1ef94b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.2.1 + - patch rexml to improve performance of multi-threaded xml parsing [#84](https://github.com/logstash-plugins/logstash-filter-xml/pull/84) +#84 + ## 4.2.0 - Update Nokogiri dependency version [#78](https://github.com/logstash-plugins/logstash-filter-xml/pull/78) diff --git a/lib/logstash/filters/xml.rb b/lib/logstash/filters/xml.rb index af87932..633a484 100644 --- a/lib/logstash/filters/xml.rb +++ b/lib/logstash/filters/xml.rb @@ -1,6 +1,7 @@ # encoding: utf-8 require "logstash/filters/base" require "logstash/namespace" +require "logstash/filters/xml/patch_rexml" # XML filter. Takes a field that contains XML and expands it into # an actual datastructure. diff --git a/lib/logstash/filters/xml/patch_rexml.rb b/lib/logstash/filters/xml/patch_rexml.rb new file mode 100644 index 0000000..8935cb8 --- /dev/null +++ b/lib/logstash/filters/xml/patch_rexml.rb @@ -0,0 +1,27 @@ +require 'xmlsimple' +require 'stringio' + +module REXML + class SourceFactory + # Generates a Source object + # @param arg Either a String, or an IO + # @return a Source, or nil if a bad argument was given + def SourceFactory::create_from(arg) + if arg.respond_to? :read and + arg.respond_to? :readline and + arg.respond_to? :nil? and + arg.respond_to? :eof? + IOSource.new(arg) + elsif arg.respond_to? :to_str + # remove this require to speed up multi-threaded parsing + #require 'stringio' + IOSource.new(StringIO.new(arg)) + elsif arg.kind_of? Source + arg + else + raise "#{arg.class} is not a valid input stream. It must walk \n"+ + "like either a String, an IO, or a Source." + end + end + end +end diff --git a/logstash-filter-xml.gemspec b/logstash-filter-xml.gemspec index 1ff7a1f..a0a16e4 100644 --- a/logstash-filter-xml.gemspec +++ b/logstash-filter-xml.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.name = 'logstash-filter-xml' - s.version = '4.2.0' + s.version = '4.2.1' s.licenses = ['Apache License (2.0)'] s.summary = "Parses XML into fields" s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"