Skip to content

Commit

Permalink
add Java 9+ support to ChildProcess dependency
Browse files Browse the repository at this point in the history
this can safely be removed when the childprocess gem supports Java9+
enkessler/childprocess#141
  • Loading branch information
yaauie committed Jan 20, 2019
1 parent 4222da8 commit 91fbacd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions qa/integration/patch/childprocess-modern-java.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# encoding: utf-8

# Implementation of ChildProcess::JRuby::Process#pid depends heavily on
# what Java SDK is being used; here, we look it up once at load, then
# override that method with an implementation that works on modern Javas
# if necessary.
#
# This patch can be removed when the upstream childprocess gem supports Java 9+
# https://github.com/enkessler/childprocess/pull/141
normalised_java_version_major = java.lang.System.get_property("java.version")
.slice(/^(1\.)?([0-9]+)/, 2)
.to_i

if normalised_java_version_major >= 9
$stderr.puts("patching childprocess for Java9+ support...")
ChildProcess::JRuby::Process.class_exec do
def pid
@process.pid
rescue java.lang.UnsupportedOperationException => e
raise NotImplementedError, "pid is not supported on this platform: #{e.message}"
end
end
end
1 change: 1 addition & 0 deletions qa/integration/services/logstash_service.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require_relative "monitoring_api"

require "childprocess"
require_relative "../patch/childprocess-modern-java"
require "bundler"
require "socket"
require "tempfile"
Expand Down

0 comments on commit 91fbacd

Please sign in to comment.