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

patch rexml to improve performance of multi-threaded xml parsing #84

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- ELASTIC_STACK_VERSION=8.x DOCKER_ENV=dockerjdk21.env
- SNAPSHOT=true ELASTIC_STACK_VERSION=8.x DOCKER_ENV=dockerjdk21.env
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
1 change: 1 addition & 0 deletions lib/logstash/filters/xml.rb
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
27 changes: 27 additions & 0 deletions lib/logstash/filters/xml/patch_rexml.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion logstash-filter-xml.gemspec
Original file line number Diff line number Diff line change
@@ -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"
Expand Down