logstash-codec-json_lines 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a1506140c8e501d6674a9240c5e0e943dbad0adc
4
- data.tar.gz: 86a5df4679925793a96dd8d41093c2ca69b6dabc
3
+ metadata.gz: b030a41f7df36a3d8606f34ed585c0985fb90df7
4
+ data.tar.gz: b8219c1875098c8bfdb8bd50035563431edc6864
5
5
  SHA512:
6
- metadata.gz: c1f3ea023534e310a9b3215909118af6b0709f4e20ec34b450b556ac2c97f8f05ae830e46e4ada813ebb4d3b720d1fec3bce83351a9ec4eab2d307321c51084a
7
- data.tar.gz: c97a1312cb5c1f89a0c8763e1da59f25ea2fa942a5da7008422920e51f85578ccc9981b3556bf1649d8699241b5f2b71cc5a36c310e77e2616b373ce9e483835
6
+ metadata.gz: 4f68fda702d25dd2d51492b13fc96f081fe03ae9bf85b34d6a22e1d437b5fd3142b4cbd02844e52634f6cd1ada88b10ca80e8b8aa6000b0ab190781442fc4196
7
+ data.tar.gz: 4bd5013f23e24fe1ceada38d87a23c536bcffd921c35d3e393d24f36664c12f53b256b1b808a483f2fd83893945dbd7efad85db6fb989e3f860486663bb592ed
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
1
  source 'https://rubygems.org'
2
- gemspec
2
+ gemspec
@@ -59,11 +59,14 @@ class LogStash::Codecs::JSONLines < LogStash::Codecs::Base
59
59
 
60
60
  # legacy_parse uses the LogStash::Json class to deserialize json
61
61
  def legacy_parse(json, &block)
62
- yield LogStash::Event.new(LogStash::Json.load(json))
62
+ # ignore empty/blank lines which LogStash::Json#load returns as nil
63
+ o = LogStash::Json.load(json)
64
+ yield(LogStash::Event.new(o)) if o
63
65
  rescue LogStash::Json::ParserError
64
66
  yield LogStash::Event.new("message" => json, "tags" => ["_jsonparsefailure"])
65
67
  end
66
68
 
69
+ # keep compatibility with all v2.x distributions. only in 2.3 will the Event#from_json method be introduced
70
+ # and we need to keep compatibility for all v2 releases.
67
71
  alias_method :parse, LogStash::Event.respond_to?(:from_json) ? :from_json_parse : :legacy_parse
68
-
69
- end # class LogStash::Codecs::JSONLines
72
+ end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-codec-json_lines'
4
- s.version = '2.1.0'
4
+ s.version = '2.1.1'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "This codec will decode streamed JSON that is newline delimited."
7
7
  s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
@@ -78,7 +78,6 @@ describe LogStash::Codecs::JSONLines do
78
78
  end
79
79
 
80
80
  context "when json could not be parsed" do
81
-
82
81
  let(:message) { "random_message\n" }
83
82
 
84
83
  it "add the failure tag" do
@@ -98,8 +97,26 @@ describe LogStash::Codecs::JSONLines do
98
97
  expect(event['tags']).to include "_jsonparsefailure"
99
98
  end
100
99
  end
100
+ end
101
+
102
+ context "blank lines" do
103
+ let(:collector) { Array.new }
101
104
 
105
+ it "should ignore bare blanks" do
106
+ subject.decode("\n\n") do |event|
107
+ collector.push(event)
108
+ end
109
+ expect(collector.size).to eq(0)
110
+ end
111
+
112
+ it "should ignore in between blank lines" do
113
+ subject.decode("\n{\"a\":1}\n\n{\"b\":2}\n\n") do |event|
114
+ collector.push(event)
115
+ end
116
+ expect(collector.size).to eq(2)
117
+ end
102
118
  end
119
+
103
120
  end
104
121
 
105
122
  context "#encode" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-codec-json_lines
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-09 00:00:00.000000000 Z
11
+ date: 2016-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core