From 91fbacd330439b77b06813eab08f666a2fb6f785 Mon Sep 17 00:00:00 2001 From: Ry Biesemeyer Date: Sun, 20 Jan 2019 18:07:39 +0000 Subject: [PATCH] add Java 9+ support to ChildProcess dependency this can safely be removed when the childprocess gem supports Java9+ https://github.com/enkessler/childprocess/pull/141 --- .../patch/childprocess-modern-java.rb | 23 +++++++++++++++++++ qa/integration/services/logstash_service.rb | 1 + 2 files changed, 24 insertions(+) create mode 100644 qa/integration/patch/childprocess-modern-java.rb diff --git a/qa/integration/patch/childprocess-modern-java.rb b/qa/integration/patch/childprocess-modern-java.rb new file mode 100644 index 00000000000..7a2125d3769 --- /dev/null +++ b/qa/integration/patch/childprocess-modern-java.rb @@ -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 \ No newline at end of file diff --git a/qa/integration/services/logstash_service.rb b/qa/integration/services/logstash_service.rb index 5f0f603cfb8..ca1729787c1 100644 --- a/qa/integration/services/logstash_service.rb +++ b/qa/integration/services/logstash_service.rb @@ -1,6 +1,7 @@ require_relative "monitoring_api" require "childprocess" +require_relative "../patch/childprocess-modern-java" require "bundler" require "socket" require "tempfile"