Skip to content

Commit

Permalink
Update to JRuby 9.4 (#14861)
Browse files Browse the repository at this point in the history
Set of changes to make Logstash compatible to JRuby 9.4.
Bundle JRuby 9.4.3.0

- Redefine space token in `LSCL`  and `grammar` treetop from `_` which would generated methods in the form `def _0` (deprecated since `2.7`) to `sc`.
- `I18n.t` method doesn't accept hash as second argument
- `URI.encode` has been replaced with same functionality with `URI::Parser.new.escape`
- `YAML.load` needs explicit `fallback: false` to return false when the yaml string is empty (or contains only comments)
- JRuby's  `JavaClass` has been removed, now it can use `java.lang.Class` directly
- explicitly require gem `thwait` to satisfy `require "thwait"` (In `Gemfile.template` and `logstash-core/logstash-core.gemspec`)
- fix not args `clone` to be `def clone(*args)`
- fix `Enumeration.each_slice` which from `Ruby 3.1` is [chainable](https://rubyreferences.github.io/rubychanges/3.1.html#enumerableeach_cons-and-each_slice-return-a-receiver) and doesn't return `nil`. JRuby fixed in jruby/jruby#7015
- Expanded `Down.download` arguments map ca16bbe
- Avoid to pass `nil` in the list of couples used in `Hash[ <list of couples> ]` which from Ruby `3.0` generates an `ArgumentError`
- Removed space not allowed between method name and parentheses `initialize (` is forbidden. 29b607d
- With [Ruby 2.7 the `Kernel#open`](https://rubyreferences.github.io/rubychanges/2.7.html#network-and-web) doesn't fallback to `URI#open`, fixed test code that used that to verify open port. e5b70de
- Avoid to drop `rdoc/` folder from vendored JRuby else `bin/logstash -i irb` would crash, commit b71f73e

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
  • Loading branch information
andsel and jsvd authored Jun 28, 2023
1 parent 019bb95 commit 26d1c7c
Show file tree
Hide file tree
Showing 37 changed files with 407 additions and 366 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ COPY LICENSE.txt /opt/logstash/LICENSE.txt
COPY NOTICE.TXT /opt/logstash/NOTICE.TXT
COPY licenses /opt/logstash/licenses
COPY CONTRIBUTORS /opt/logstash/CONTRIBUTORS
COPY Gemfile.template Gemfile.jruby-2.6.lock.* /opt/logstash/
COPY Gemfile.template Gemfile.jruby-3.1.lock.* /opt/logstash/
COPY Rakefile /opt/logstash/Rakefile
COPY build.gradle /opt/logstash/build.gradle
COPY rubyUtils.gradle /opt/logstash/rubyUtils.gradle
Expand Down
1 change: 1 addition & 0 deletions Gemfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ gem "rspec", "~> 3.5", :group => :development
gem "webmock", "~> 3", :group => :development
gem "jar-dependencies", "= 0.4.1" # Gem::LoadError with jar-dependencies 0.4.2
gem "murmurhash3", "= 0.1.6" # Pins until version 0.1.7-java is released
gem "thwait"
2 changes: 1 addition & 1 deletion bin/logstash.lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ setup_vendored_jruby() {
fi

if [ -z "$LS_GEM_HOME" ] ; then
export GEM_HOME="${LOGSTASH_HOME}/vendor/bundle/jruby/2.6.0"
export GEM_HOME="${LOGSTASH_HOME}/vendor/bundle/jruby/3.1.0"
else
export GEM_HOME=${LS_GEM_HOME}
fi
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@ def bundlerVersion = "~> 2"

tasks.register("installBundler") {
dependsOn assemblyDeps
outputs.files file("${projectDir}/vendor/bundle/jruby/2.6.0/bin/bundle")
outputs.files file("${projectDir}/vendor/bundle/jruby/3.1.0/bin/bundle")
doLast {
gem(projectDir, buildDir, "bundler", bundlerVersion, "${projectDir}/vendor/bundle/jruby/2.6.0")
gem(projectDir, buildDir, "bundler", bundlerVersion, "${projectDir}/vendor/bundle/jruby/3.1.0")
}
}

Expand Down Expand Up @@ -417,7 +417,7 @@ tasks.register("unpackTarDistribution", Copy) {

def qaBuildPath = "${buildDir}/qa/integration"
def qaVendorPath = "${qaBuildPath}/vendor"
def qaBundledGemPath = "${qaVendorPath}/jruby/2.6.0".toString()
def qaBundledGemPath = "${qaVendorPath}/jruby/3.1.0".toString()
def qaBundleBin = "${qaBundledGemPath}/bin/bundle"

tasks.register("installIntegrationTestBundler"){
Expand Down
2 changes: 1 addition & 1 deletion lib/bootstrap/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def invoke!(options = {})
)
end
# create Gemfile.jruby-1.9.lock from template iff a template exists it itself does not exist
lock_template = ::File.join(ENV["LOGSTASH_HOME"], "Gemfile.jruby-2.6.lock.release")
lock_template = ::File.join(ENV["LOGSTASH_HOME"], "Gemfile.jruby-3.1.lock.release")
if ::File.exists?(lock_template) && !::File.exists?(Environment::LOCKFILE)
FileUtils.copy(lock_template, Environment::LOCKFILE)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/pluginmanager/gem_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module LogStash module PluginManager
# - Generate the specifications
# - Copy the data in the right folders
class GemInstaller
GEM_HOME = Pathname.new(::File.join(LogStash::Environment::BUNDLE_DIR, "jruby", "2.6.0"))
GEM_HOME = Pathname.new(::File.join(LogStash::Environment::BUNDLE_DIR, "jruby", "3.1.0"))
SPECIFICATIONS_DIR = "specifications"
GEMS_DIR = "gems"
CACHE_DIR = "cache"
Expand Down
5 changes: 3 additions & 2 deletions logstash-core/lib/logstash/api/modules/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ class Logging < ::LogStash::Api::Modules::Base
#
# return any unused configurations
def handle_logging(settings)
Hash[settings.map do |key, level|
couplesList = settings.map do |key, level|
if key.start_with?("logger.")
_, path = key.split("logger.")
LogStash::Logging::Logger::configure_logging(level, path)
nil
else
[key, level]
end
end]
end.reject {|value| value.nil?} # skip nil which result in ArgumentError since JRuby 9.4
Hash[couplesList]
end

put "/" do
Expand Down
2 changes: 1 addition & 1 deletion logstash-core/lib/logstash/codecs/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def flush(&block)
end

public
def clone
def clone(*args)
LogStash::Plugins::Contextualizer.initialize_plugin(execution_context, self.class, params).tap do |klone|
klone.metric = @metric if klone.instance_variable_get(:@metric).nil?
end
Expand Down
Loading

0 comments on commit 26d1c7c

Please sign in to comment.