Skip to content

Commit 606fcb8

Browse files
author
Guy Boertje
authored
Critical fixes for two show stopper bugs #180 and #182 (#183)
* Fix JAR_VERSION read problem, add test and fix /dev/null write IO error * bump version and add changelog entry Fix #182 Fix #180
1 parent eb1f016 commit 606fcb8

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

Diff for: CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 4.1.1
2+
- Fix JAR_VERSION read problem, prevented Logstash from starting.
3+
[Issue #180](https://github.com/logstash-plugins/logstash-input-file/issues/180)
4+
- Fix sincedb write error when using /dev/null, repeatedly causes a plugin restart.
5+
[Issue #182](https://github.com/logstash-plugins/logstash-input-file/issues/182)
6+
17
## 4.1.0
28
- Move Filewatch code into the plugin folder, rework Filewatch code to use
39
Logstash facilities like logging and environment.

Diff for: lib/filewatch/bootstrap.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def prepare_inode(path, stat)
3030
end
3131
end
3232

33-
jar_version = IO.read("JAR_VERSION").strip
33+
jar_version = Pathname.new(__FILE__).dirname.join("../../JAR_VERSION").realpath.read.strip
3434

3535
require "java"
3636
require_relative "../../lib/jars/filewatch-#{jar_version}.jar"

Diff for: lib/filewatch/sincedb_collection.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def atomic_write
207207
end
208208

209209
def non_atomic_write
210-
IO.open(@full_path, 0) do |io|
210+
IO.open(IO.sysopen(@full_path, "w+")) do |io|
211211
@serializer.serialize(@sincedb, io)
212212
end
213213
end

Diff for: logstash-input-file.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |s|
22

33
s.name = 'logstash-input-file'
4-
s.version = '4.1.0'
4+
s.version = '4.1.1'
55
s.licenses = ['Apache-2.0']
66
s.summary = "Streams events from files"
77
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"

Diff for: spec/filewatch/reading_spec.rb

+16
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,22 @@ module FileWatch
5555
end
5656
end
5757

58+
context "when watching a directory with files and sincedb_path is /dev/null or NUL" do
59+
let(:directory) { Stud::Temporary.directory }
60+
let(:sincedb_path) { File::NULL }
61+
let(:watch_dir) { ::File.join(directory, "*.log") }
62+
let(:file_path) { ::File.join(directory, "1.log") }
63+
64+
it "the file is read" do
65+
File.open(file_path, "wb") { |file| file.write("line1\nline2\n") }
66+
actions.activate
67+
reading.watch_this(watch_dir)
68+
reading.subscribe(observer)
69+
expect(observer.listener_for(file_path).calls).to eq([:open, :accept, :accept, :eof, :delete])
70+
expect(observer.listener_for(file_path).lines).to eq(["line1", "line2"])
71+
end
72+
end
73+
5874
context "when watching a directory with files using striped reading" do
5975
let(:directory) { Stud::Temporary.directory }
6076
let(:watch_dir) { ::File.join(directory, "*.log") }

0 commit comments

Comments
 (0)