forked from elastic/logstash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Java 9+ support to ChildProcess dependency
this can safely be removed when the childprocess gem supports Java9+ enkessler/childprocess#141
- Loading branch information
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters