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

remove usage of jruby-stdin-channel #19

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 3.3.0
- Removed usage of jruby-stdin-channel which is not required anymore [#19](https://github.com/logstash-plugins/logstash-input-stdin/pull/19)

## 3.2.6
- Docs: Set the default_codec doc attribute.

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ The following is a list of people who have contributed ideas, code, bug
reports, or in general have helped logstash along its way.

Contributors:
* Colin Surprenant (colinsurprenant)
* Fredrik Gustafsson (jagheterfredrik)
* John E. Vincent (lusis)
* Jordan Sissel (jordansissel)
Expand Down
31 changes: 2 additions & 29 deletions lib/logstash/inputs/stdin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require "logstash/namespace"
require "concurrent/atomics"
require "socket" # for Socket.gethostname
require "jruby-stdin-channel"

# Read events from standard input.
#
Expand All @@ -17,16 +16,6 @@ class LogStash::Inputs::Stdin < LogStash::Inputs::Base
READ_SIZE = 16384

def register
begin
@stdin = StdinChannel::Reader.new
self.class.module_exec { alias_method :stdin_read, :channel_read }
self.class.module_exec { alias_method :stop, :channel_stop}
rescue => e
@logger.debug("fallback to reading from regular $stdin", :exception => e)
self.class.module_exec { alias_method :stdin_read, :default_read }
self.class.module_exec { alias_method :stop, :default_stop }
end

@host = Socket.gethostname
fix_streaming_codecs
end
Expand All @@ -52,15 +41,11 @@ def self.reloadable?

private

def default_stop
def stop
$stdin.close rescue nil
end

def channel_stop
@stdin.close rescue nil
end

def default_read
def stdin_read
begin
return $stdin.sysread(READ_SIZE)
rescue IOError, EOFError
Expand All @@ -71,16 +56,4 @@ def default_read
end
nil
end

def channel_read
begin
return @stdin.read(READ_SIZE)
rescue IOError, EOFError, StdinChannel::ClosedChannelError
do_stop
rescue => e
# ignore any exception in the shutdown process
raise(e) unless stop?
end
nil
end
end
3 changes: 1 addition & 2 deletions logstash-input-stdin.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|

s.name = 'logstash-input-stdin'
s.version = '3.2.6'
s.version = '3.3.0'
s.licenses = ['Apache License (2.0)']
s.summary = "Reads events from standard input"
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 All @@ -23,7 +23,6 @@ Gem::Specification.new do |s|
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
s.add_runtime_dependency "logstash-codec-line"
s.add_runtime_dependency "concurrent-ruby"
s.add_runtime_dependency "jruby-stdin-channel"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know precisely which version of Logstash and/or Jruby is needed in order to preclude the need for jruby-stdin-channel? If so we should add that as a requirement so that this update isn't pulled in on Logstashes/Jrubies that still need it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 believe the changes are due to the JRuby 9K IO sub-system rewrite.
so any 9.x should do, either logstash-core >= 6.0 or simply s.required_ruby_version '>= 2.3'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is still an open issue on jruby about stdin's interruptibility, noting that support may have gotten better on linux/darwin, but that there may still be issues with Windows: jruby/jruby#2024

missed this one, I think it's still an issue - even on Linux/Mac.
we might need a spec checking for in.read followed by an in.close not causing a hang (till a char is received).


s.add_development_dependency "logstash-codec-plain"
s.add_development_dependency "logstash-codec-json"
Expand Down