logstash-core 1.5.0.snapshot1-java → 1.5.1-java
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.
Potentially problematic release.
This version of logstash-core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/logstash/agent.rb +10 -2
- data/lib/logstash/config/config_ast.rb +7 -3
- data/lib/logstash/inputs/base.rb +2 -2
- data/lib/logstash/patches/bugfix_jruby_2558.rb +2 -2
- data/lib/logstash/patches/bundler.rb +15 -0
- data/lib/logstash/pipeline.rb +3 -4
- data/lib/logstash/util/accessors.rb +72 -42
- data/lib/logstash/version.rb +1 -1
- data/locales/en.yml +6 -0
- data/logstash-core.gemspec +2 -0
- data/spec/core/conditionals_spec.rb +1 -1
- data/spec/core/config_spec.rb +38 -0
- data/spec/core/event_spec.rb +11 -11
- data/spec/core/pipeline_spec.rb +7 -10
- data/spec/lib/logstash/bundler_spec.rb +1 -0
- data/spec/lib/logstash/java_integration_spec.rb +16 -16
- data/spec/util/accessors_spec.rb +0 -45
- data/spec/util/json_spec.rb +5 -6
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fafba05d878e14fa01c8fc5a8b25ab4417fdecb3
|
4
|
+
data.tar.gz: 40ecd05d0b96587607bdb8d3f8d4ac8c51e921d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a96dcfa7d2f103ef370095269e3e6091411cd55634ad665517232097fd0907bf10a6313648823d5d682beaeecbcc4b9e20eb4c78c9f5dcd578698d75dcf3ae0f
|
7
|
+
data.tar.gz: 1a7485abfbd935277984f66a8bead8425b7ed7d389845751325eff72922755ea1eb8fcad1a09e9d2fc7e67fb5211a0ea01083be7f60df6b67ed975a69a3a8cb6
|
data/lib/logstash/agent.rb
CHANGED
@@ -113,8 +113,16 @@ class LogStash::Agent < Clamp::Command
|
|
113
113
|
|
114
114
|
# Make SIGINT shutdown the pipeline.
|
115
115
|
sigint_id = Stud::trap("INT") do
|
116
|
-
|
117
|
-
|
116
|
+
|
117
|
+
if @interrupted_once
|
118
|
+
@logger.fatal(I18n.t("logstash.agent.forced_sigint"))
|
119
|
+
exit
|
120
|
+
else
|
121
|
+
@logger.warn(I18n.t("logstash.agent.sigint"))
|
122
|
+
Thread.new(@logger) {|logger| sleep 5; logger.warn(I18n.t("logstash.agent.slow_shutdown")) }
|
123
|
+
@interrupted_once = true
|
124
|
+
pipeline.shutdown
|
125
|
+
end
|
118
126
|
end
|
119
127
|
|
120
128
|
# Make SIGTERM shutdown the pipeline.
|
@@ -76,7 +76,11 @@ module LogStash; module Config; module AST
|
|
76
76
|
@defered_conditionals_index = val
|
77
77
|
end
|
78
78
|
|
79
|
-
class Node < Treetop::Runtime::SyntaxNode
|
79
|
+
class Node < Treetop::Runtime::SyntaxNode
|
80
|
+
def text_value_for_comments
|
81
|
+
text_value.gsub(/[\r\n]/, " ")
|
82
|
+
end
|
83
|
+
end
|
80
84
|
|
81
85
|
class Config < Node
|
82
86
|
def compile
|
@@ -412,14 +416,14 @@ module LogStash; module Config; module AST
|
|
412
416
|
class If < BranchEntry
|
413
417
|
def compile
|
414
418
|
children = recursive_inject { |e| e.is_a?(Branch) || e.is_a?(Plugin) }
|
415
|
-
return "if #{condition.compile} # if #{condition.
|
419
|
+
return "if #{condition.compile} # if #{condition.text_value_for_comments}\n" \
|
416
420
|
<< children.collect(&:compile).map { |s| s.split("\n", -1).map { |l| " " + l }.join("\n") }.join("") << "\n"
|
417
421
|
end
|
418
422
|
end
|
419
423
|
class Elsif < BranchEntry
|
420
424
|
def compile
|
421
425
|
children = recursive_inject { |e| e.is_a?(Branch) || e.is_a?(Plugin) }
|
422
|
-
return "elsif #{condition.compile} # else if #{condition.
|
426
|
+
return "elsif #{condition.compile} # else if #{condition.text_value_for_comments}\n" \
|
423
427
|
<< children.collect(&:compile).map { |s| s.split("\n", -1).map { |l| " " + l }.join("\n") }.join("") << "\n"
|
424
428
|
end
|
425
429
|
end
|
data/lib/logstash/inputs/base.rb
CHANGED
@@ -40,7 +40,7 @@ class LogStash::Inputs::Base < LogStash::Plugin
|
|
40
40
|
# or in another character set other than `UTF-8`.
|
41
41
|
#
|
42
42
|
# This only affects `plain` format logs since json is `UTF-8` already.
|
43
|
-
config :charset, :
|
43
|
+
config :charset, :deprecated => "Use the codec setting instead. For example: input { %PLUGIN% { codec => plain { charset => \"UTF-8\" } }"
|
44
44
|
|
45
45
|
# If format is `json`, an event `sprintf` string to build what
|
46
46
|
# the display `@message` should be given (defaults to the raw JSON).
|
@@ -101,7 +101,7 @@ class LogStash::Inputs::Base < LogStash::Plugin
|
|
101
101
|
|
102
102
|
protected
|
103
103
|
def to_event(raw, source)
|
104
|
-
raise LogStash::ThisMethodWasRemoved("LogStash::Inputs::Base#to_event - you should use codecs now instead of to_event. Not sure what this means? Get help on logstash
|
104
|
+
raise LogStash::ThisMethodWasRemoved("LogStash::Inputs::Base#to_event - you should use codecs now instead of to_event. Not sure what this means? Get help on https://discuss.elastic.co/c/logstash")
|
105
105
|
end # def to_event
|
106
106
|
|
107
107
|
protected
|
@@ -3,8 +3,8 @@ require "logstash/environment"
|
|
3
3
|
if LogStash::Environment.windows? && LogStash::Environment.jruby?
|
4
4
|
require "socket"
|
5
5
|
module JRubyBug2558SocketPeerAddrBugFix
|
6
|
-
def peeraddr
|
7
|
-
orig_peeraddr.map do |v|
|
6
|
+
def peeraddr(*args)
|
7
|
+
orig_peeraddr(*args).map do |v|
|
8
8
|
case v
|
9
9
|
when String
|
10
10
|
v.force_encoding(Encoding::UTF_8)
|
@@ -9,6 +9,21 @@ module ::Bundler
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
# Patch to prevent Bundler to save a .bundle/config file in the root
|
13
|
+
# of the application
|
14
|
+
class Settings
|
15
|
+
def set_key(key, value, hash, file)
|
16
|
+
key = key_for(key)
|
17
|
+
|
18
|
+
unless hash[key] == value
|
19
|
+
hash[key] = value
|
20
|
+
hash.delete(key) if value.nil?
|
21
|
+
end
|
22
|
+
|
23
|
+
value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
12
27
|
# Add the Bundler.reset! method which has been added in master but is not in 1.7.9.
|
13
28
|
class << self
|
14
29
|
unless self.method_defined?("reset!")
|
data/lib/logstash/pipeline.rb
CHANGED
@@ -115,7 +115,7 @@ class LogStash::Pipeline
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def shutdown_filters
|
118
|
-
@
|
118
|
+
@flusher_thread.kill
|
119
119
|
@input_to_filter.push(LogStash::SHUTDOWN)
|
120
120
|
end
|
121
121
|
|
@@ -156,8 +156,7 @@ class LogStash::Pipeline
|
|
156
156
|
Thread.new { filterworker }
|
157
157
|
end
|
158
158
|
|
159
|
-
@
|
160
|
-
@flusher_thread = Thread.new { Stud.interval(5) { @flusher_lock.synchronize { @input_to_filter.push(LogStash::FLUSH) } } }
|
159
|
+
@flusher_thread = Thread.new { Stud.interval(5) { @input_to_filter.push(LogStash::FLUSH) } }
|
161
160
|
end
|
162
161
|
|
163
162
|
def start_outputs
|
@@ -220,7 +219,7 @@ class LogStash::Pipeline
|
|
220
219
|
when LogStash::FlushEvent
|
221
220
|
# handle filter flushing here so that non threadsafe filters (thus only running one filterworker)
|
222
221
|
# don't have to deal with thread safety implementing the flush method
|
223
|
-
|
222
|
+
flush_filters_to_output!
|
224
223
|
when LogStash::ShutdownEvent
|
225
224
|
# pass it down to any other filterworker and stop this worker
|
226
225
|
@input_to_filter.push(event)
|
@@ -2,90 +2,120 @@
|
|
2
2
|
|
3
3
|
require "logstash/namespace"
|
4
4
|
require "logstash/util"
|
5
|
+
require "thread_safe"
|
5
6
|
|
6
7
|
module LogStash::Util
|
7
8
|
|
8
|
-
# PathCache is a singleton which globally caches
|
9
|
-
#
|
9
|
+
# PathCache is a singleton which globally caches the relation between a field reference and its
|
10
|
+
# decomposition into a [key, path array] tuple. For example the field reference [foo][bar][baz]
|
11
|
+
# is decomposed into ["baz", ["foo", "bar"]].
|
10
12
|
module PathCache
|
11
13
|
extend self
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
15
|
+
# requiring libraries and defining constants is thread safe in JRuby so
|
16
|
+
# PathCache::CACHE will be corretly initialized, once, when accessors.rb
|
17
|
+
# will be first required
|
18
|
+
CACHE = ThreadSafe::Cache.new
|
19
|
+
|
20
|
+
def get(field_reference)
|
21
|
+
# the "get_or_default(x, nil) || put(x, parse(x))" is ~2x faster than "get || put" because the get call is
|
22
|
+
# proxied through the JRuby JavaProxy op_aref method. the correct idiom here would be to use
|
23
|
+
# "compute_if_absent(x){parse(x)}" but because of the closure creation, it is ~1.5x slower than
|
24
|
+
# "get_or_default || put".
|
25
|
+
# this "get_or_default || put" is obviously non-atomic which is not really important here
|
26
|
+
# since all threads will set the same value and this cache will stabilize very quickly after the first
|
27
|
+
# few events.
|
28
|
+
CACHE.get_or_default(field_reference, nil) || CACHE.put(field_reference, parse(field_reference))
|
16
29
|
end
|
17
30
|
|
18
|
-
def parse(
|
19
|
-
path =
|
31
|
+
def parse(field_reference)
|
32
|
+
path = field_reference.split(/[\[\]]/).select{|s| !s.empty?}
|
20
33
|
[path.pop, path]
|
21
34
|
end
|
22
35
|
end
|
23
36
|
|
24
|
-
# Accessors uses a lookup table to speedup access of
|
37
|
+
# Accessors uses a lookup table to speedup access of a field reference of the form
|
25
38
|
# "[hello][world]" to the underlying store hash into {"hello" => {"world" => "foo"}}
|
26
39
|
class Accessors
|
27
40
|
|
41
|
+
# @param store [Hash] the backing data store field refereces point to
|
28
42
|
def initialize(store)
|
29
43
|
@store = store
|
44
|
+
|
45
|
+
# @lut is a lookup table between a field reference and a [target, key] tuple
|
46
|
+
# where target is the containing Hash or Array for key in @store.
|
47
|
+
# this allows us to directly access the containing object for key instead of
|
48
|
+
# walking the field reference path into the inner @store objects
|
30
49
|
@lut = {}
|
31
50
|
end
|
32
51
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
52
|
+
# @param field_reference [String] the field reference
|
53
|
+
# @return [Object] the value in @store for this field reference
|
54
|
+
def get(field_reference)
|
55
|
+
target, key = lookup(field_reference)
|
56
|
+
return nil unless target
|
57
|
+
target.is_a?(Array) ? target[key.to_i] : target[key]
|
38
58
|
end
|
39
59
|
|
40
|
-
|
41
|
-
|
60
|
+
# @param field_reference [String] the field reference
|
61
|
+
# @param value [Object] the value to set in @store for this field reference
|
62
|
+
# @return [Object] the value set
|
63
|
+
def set(field_reference, value)
|
64
|
+
target, key = lookup_or_create(field_reference)
|
42
65
|
target[target.is_a?(Array) ? key.to_i : key] = value
|
43
66
|
end
|
44
67
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
target
|
51
|
-
unless target.nil?
|
52
|
-
target.is_a?(Array) ? target.delete_at(key.to_i) : target.delete(key)
|
53
|
-
end
|
68
|
+
# @param field_reference [String] the field reference to remove
|
69
|
+
# @return [Object] the removed value in @store for this field reference
|
70
|
+
def del(field_reference)
|
71
|
+
target, key = lookup(field_reference)
|
72
|
+
return nil unless target
|
73
|
+
target.is_a?(Array) ? target.delete_at(key.to_i) : target.delete(key)
|
54
74
|
end
|
55
75
|
|
56
|
-
|
57
|
-
|
76
|
+
# @param field_reference [String] the field reference to test for inclusion in the store
|
77
|
+
# @return [Boolean] true if the store contains a value for this field reference
|
78
|
+
def include?(field_reference)
|
79
|
+
target, key = lookup(field_reference)
|
58
80
|
return false unless target
|
81
|
+
|
59
82
|
target.is_a?(Array) ? !target[key.to_i].nil? : target.include?(key)
|
60
83
|
end
|
61
84
|
|
62
85
|
private
|
63
86
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
@lut[accessor] = [target, key]
|
70
|
-
end
|
87
|
+
# retrieve the [target, key] tuple associated with this field reference
|
88
|
+
# @param field_reference [String] the field referece
|
89
|
+
# @return [[Object, String]] the [target, key] tuple associated with this field reference
|
90
|
+
def lookup(field_reference)
|
91
|
+
@lut[field_reference] ||= find_target(field_reference)
|
71
92
|
end
|
72
93
|
|
73
|
-
|
74
|
-
|
94
|
+
# retrieve the [target, key] tuple associated with this field reference and create inner
|
95
|
+
# container objects if they do not exists
|
96
|
+
# @param field_reference [String] the field referece
|
97
|
+
# @return [[Object, String]] the [target, key] tuple associated with this field reference
|
98
|
+
def lookup_or_create(field_reference)
|
99
|
+
@lut[field_reference] ||= find_or_create_target(field_reference)
|
75
100
|
end
|
76
101
|
|
77
|
-
|
78
|
-
|
102
|
+
# find the target container object in store for this field reference
|
103
|
+
# @param field_reference [String] the field referece
|
104
|
+
# @return [Object] the target container object in store associated with this field reference
|
105
|
+
def find_target(field_reference)
|
106
|
+
key, path = PathCache.get(field_reference)
|
79
107
|
target = path.inject(@store) do |r, k|
|
80
|
-
|
81
|
-
return nil
|
82
|
-
end
|
108
|
+
return nil unless r
|
83
109
|
r[r.is_a?(Array) ? k.to_i : k]
|
84
110
|
end
|
85
|
-
[target, key]
|
111
|
+
target ? [target, key] : nil
|
86
112
|
end
|
87
113
|
|
88
|
-
|
114
|
+
# find the target container object in store for this field reference and create inner
|
115
|
+
# container objects if they do not exists
|
116
|
+
# @param field_reference [String] the field referece
|
117
|
+
# @return [Object] the target container object in store associated with this field reference
|
118
|
+
def find_or_create_target(accessor)
|
89
119
|
key, path = PathCache.get(accessor)
|
90
120
|
target = path.inject(@store) {|r, k| r[r.is_a?(Array) ? k.to_i : k] ||= {}}
|
91
121
|
[target, key]
|
data/lib/logstash/version.rb
CHANGED
data/locales/en.yml
CHANGED
@@ -66,6 +66,12 @@ en:
|
|
66
66
|
SIGINT received. Shutting down the pipeline.
|
67
67
|
sigterm: >-
|
68
68
|
SIGTERM received. Shutting down the pipeline.
|
69
|
+
slow_shutdown: |-
|
70
|
+
Received shutdown signal, but pipeline is still waiting for in-flight events
|
71
|
+
to be processed. Sending another ^C will force quit Logstash, but this may cause
|
72
|
+
data loss.
|
73
|
+
forced_sigint: >-
|
74
|
+
SIGINT received. Terminating immediately..
|
69
75
|
configtest-flag-information: |-
|
70
76
|
You may be interested in the '--configtest' flag which you can
|
71
77
|
use to validate logstash's configuration before you choose
|
data/logstash-core.gemspec
CHANGED
@@ -33,6 +33,8 @@ Gem::Specification.new do |gem|
|
|
33
33
|
# filetools and rakelib
|
34
34
|
gem.add_runtime_dependency "minitar", "~> 0.5.4"
|
35
35
|
|
36
|
+
gem.add_runtime_dependency "thread_safe", "~> 0.3.5" #(Apache 2.0 license)
|
37
|
+
|
36
38
|
if RUBY_PLATFORM == 'java'
|
37
39
|
gem.platform = RUBY_PLATFORM
|
38
40
|
gem.add_runtime_dependency "jrjackson", "~> 0.2.8" #(Apache 2.0 license)
|
data/spec/core/config_spec.rb
CHANGED
@@ -48,6 +48,44 @@ describe LogStashConfigParser do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
context "#compile" do
|
51
|
+
context "if with multiline conditionals" do
|
52
|
+
let(:config) { <<-CONFIG }
|
53
|
+
filter {
|
54
|
+
if [something]
|
55
|
+
or [anotherthing]
|
56
|
+
or [onemorething] {
|
57
|
+
}
|
58
|
+
}
|
59
|
+
CONFIG
|
60
|
+
subject { LogStashConfigParser.new }
|
61
|
+
|
62
|
+
it "should compile successfully" do
|
63
|
+
result = subject.parse(config)
|
64
|
+
expect(result).not_to(be_nil)
|
65
|
+
expect { eval(result.compile) }.not_to(raise_error)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context "elsif with multiline conditionals" do
|
70
|
+
let(:config) { <<-CONFIG }
|
71
|
+
filter {
|
72
|
+
if [notathing] {
|
73
|
+
} else if [something]
|
74
|
+
or [anotherthing]
|
75
|
+
or [onemorething] {
|
76
|
+
}
|
77
|
+
}
|
78
|
+
CONFIG
|
79
|
+
subject { LogStashConfigParser.new }
|
80
|
+
|
81
|
+
it "should compile successfully" do
|
82
|
+
result = subject.parse(config)
|
83
|
+
expect(result).not_to(be_nil)
|
84
|
+
expect { eval(result.compile) }.not_to(raise_error)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
|
51
89
|
context "invalid configuration" do
|
52
90
|
it "rejects duplicate hash key" do
|
53
91
|
parser = LogStashConfigParser.new
|
data/spec/core/event_spec.rb
CHANGED
@@ -123,32 +123,32 @@ describe LogStash::Event do
|
|
123
123
|
|
124
124
|
context "#include?" do
|
125
125
|
it "should include existing fields" do
|
126
|
-
expect(subject.include?("c")).to
|
127
|
-
expect(subject.include?("[c][d]")).to
|
128
|
-
expect(subject.include?("[j][k4][0][nested]")).to
|
126
|
+
expect(subject.include?("c")).to eq(true)
|
127
|
+
expect(subject.include?("[c][d]")).to eq(true)
|
128
|
+
expect(subject.include?("[j][k4][0][nested]")).to eq(true)
|
129
129
|
end
|
130
130
|
|
131
131
|
it "should include field with nil value" do
|
132
|
-
expect(subject.include?("nilfield")).to
|
132
|
+
expect(subject.include?("nilfield")).to eq(true)
|
133
133
|
end
|
134
134
|
|
135
135
|
it "should include @metadata field" do
|
136
|
-
expect(subject.include?("@metadata")).to
|
136
|
+
expect(subject.include?("@metadata")).to eq(true)
|
137
137
|
end
|
138
138
|
|
139
139
|
it "should include field within @metadata" do
|
140
|
-
expect(subject.include?("[@metadata][fancy]")).to
|
140
|
+
expect(subject.include?("[@metadata][fancy]")).to eq(true)
|
141
141
|
end
|
142
142
|
|
143
143
|
it "should not include non-existing fields" do
|
144
|
-
expect(subject.include?("doesnotexist")).to
|
145
|
-
expect(subject.include?("[j][doesnotexist]")).to
|
146
|
-
expect(subject.include?("[tag][0][hello][yes]")).to
|
144
|
+
expect(subject.include?("doesnotexist")).to eq(false)
|
145
|
+
expect(subject.include?("[j][doesnotexist]")).to eq(false)
|
146
|
+
expect(subject.include?("[tag][0][hello][yes]")).to eq(false)
|
147
147
|
end
|
148
148
|
|
149
149
|
it "should include within arrays" do
|
150
|
-
expect(subject.include?("[tags][0]")).to
|
151
|
-
expect(subject.include?("[tags][1]")).to
|
150
|
+
expect(subject.include?("[tags][0]")).to eq(true)
|
151
|
+
expect(subject.include?("[tags][1]")).to eq(false)
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
data/spec/core/pipeline_spec.rb
CHANGED
@@ -58,16 +58,13 @@ end
|
|
58
58
|
|
59
59
|
describe LogStash::Pipeline do
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
LogStash::Plugin.stub(:lookup)
|
69
|
-
.with("output", "dummyoutput").and_return(DummyOutput)
|
70
|
-
end
|
61
|
+
context "teardown" do
|
62
|
+
|
63
|
+
before(:each) do
|
64
|
+
allow(LogStash::Plugin).to receive(:lookup).with("input", "dummyinput").and_return(DummyInput)
|
65
|
+
allow(LogStash::Plugin).to receive(:lookup).with("codec", "plain").and_return(DummyCodec)
|
66
|
+
allow(LogStash::Plugin).to receive(:lookup).with("output", "dummyoutput").and_return(DummyOutput)
|
67
|
+
end
|
71
68
|
|
72
69
|
let(:test_config_without_output_workers) {
|
73
70
|
<<-eos
|
@@ -30,6 +30,7 @@ describe LogStash::Bundler do
|
|
30
30
|
original_stderr = $stderr
|
31
31
|
|
32
32
|
subject { LogStash::Bundler.invoke!(options) }
|
33
|
+
|
33
34
|
# by default we want to fail fast on the test
|
34
35
|
let(:options) { { :install => true, :max_tries => 0, :without => [:development]} }
|
35
36
|
let(:bundler_args) { LogStash::Bundler.bundler_arguments(options) }
|
@@ -13,7 +13,7 @@ describe "Java integration" do
|
|
13
13
|
context "Java::JavaUtil::ArrayList" do
|
14
14
|
|
15
15
|
it "should report to be a Ruby Array" do
|
16
|
-
expect(Java::JavaUtil::ArrayList.new.is_a?(Array)).to
|
16
|
+
expect(Java::JavaUtil::ArrayList.new.is_a?(Array)).to eq(true)
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should be class equivalent to Ruby Array" do
|
@@ -26,13 +26,13 @@ describe "Java integration" do
|
|
26
26
|
end
|
27
27
|
end.not_to raise_error
|
28
28
|
|
29
|
-
expect(Array === Java::JavaUtil::ArrayList.new).to
|
29
|
+
expect(Array === Java::JavaUtil::ArrayList.new).to eq(true)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
context "Java::JavaUtil::LinkedHashMap" do
|
34
34
|
it "should report to be a Ruby Hash" do
|
35
|
-
expect(Java::JavaUtil::LinkedHashMap.new.is_a?(Hash)).to
|
35
|
+
expect(Java::JavaUtil::LinkedHashMap.new.is_a?(Hash)).to eq(true)
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should be class equivalent to Ruby Hash" do
|
@@ -45,7 +45,7 @@ describe "Java integration" do
|
|
45
45
|
end
|
46
46
|
end.not_to raise_error
|
47
47
|
|
48
|
-
expect(Hash === Java::JavaUtil::LinkedHashMap.new).to
|
48
|
+
expect(Hash === Java::JavaUtil::LinkedHashMap.new).to eq(true)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -200,57 +200,57 @@ describe "Java integration" do
|
|
200
200
|
context "Java Map interface should report key with nil value as included" do
|
201
201
|
|
202
202
|
it "should support include? method" do
|
203
|
-
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => nil}).include?("foo")).to
|
203
|
+
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => nil}).include?("foo")).to eq(true)
|
204
204
|
end
|
205
205
|
|
206
206
|
it "should support has_key? method" do
|
207
|
-
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => nil}).has_key?("foo")).to
|
207
|
+
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => nil}).has_key?("foo")).to eq(true)
|
208
208
|
end
|
209
209
|
|
210
210
|
it "should support member? method" do
|
211
|
-
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => nil}).member?("foo")).to
|
211
|
+
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => nil}).member?("foo")).to eq(true)
|
212
212
|
end
|
213
213
|
|
214
214
|
it "should support key? method" do
|
215
|
-
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => nil}).key?("foo")).to
|
215
|
+
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => nil}).key?("foo")).to eq(true)
|
216
216
|
end
|
217
217
|
end
|
218
218
|
|
219
219
|
context "Java Map interface should report key with a value as included" do
|
220
220
|
|
221
221
|
it "should support include? method" do
|
222
|
-
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => 1}).include?("foo")).to
|
222
|
+
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => 1}).include?("foo")).to eq(true)
|
223
223
|
end
|
224
224
|
|
225
225
|
it "should support has_key? method" do
|
226
|
-
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => 1}).has_key?("foo")).to
|
226
|
+
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => 1}).has_key?("foo")).to eq(true)
|
227
227
|
end
|
228
228
|
|
229
229
|
it "should support member? method" do
|
230
|
-
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => 1}).member?("foo")).to
|
230
|
+
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => 1}).member?("foo")).to eq(true)
|
231
231
|
end
|
232
232
|
|
233
233
|
it "should support key? method" do
|
234
|
-
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => 1}).key?("foo")).to
|
234
|
+
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => 1}).key?("foo")).to eq(true)
|
235
235
|
end
|
236
236
|
end
|
237
237
|
|
238
238
|
context "Java Map interface should report non existing key as not included" do
|
239
239
|
|
240
240
|
it "should support include? method" do
|
241
|
-
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => 1}).include
|
241
|
+
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => 1})).not_to include("bar")
|
242
242
|
end
|
243
243
|
|
244
244
|
it "should support has_key? method" do
|
245
|
-
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => 1}).has_key?("bar")).to
|
245
|
+
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => 1}).has_key?("bar")).to eq(false)
|
246
246
|
end
|
247
247
|
|
248
248
|
it "should support member? method" do
|
249
|
-
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => 1}).member?("bar")).to
|
249
|
+
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => 1}).member?("bar")).to eq(false)
|
250
250
|
end
|
251
251
|
|
252
252
|
it "should support key? method" do
|
253
|
-
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => 1}).key?("bar")).to
|
253
|
+
expect(Java::JavaUtil::LinkedHashMap.new({"foo" => 1}).key?("bar")).to eq(false)
|
254
254
|
end
|
255
255
|
end
|
256
256
|
end
|
data/spec/util/accessors_spec.rb
CHANGED
@@ -121,14 +121,6 @@ describe LogStash::Util::Accessors, :if => true do
|
|
121
121
|
expect(data).to eq({ "hello" => "foo" })
|
122
122
|
end
|
123
123
|
|
124
|
-
it "should strict_set shallow string value" do
|
125
|
-
str = "[hello]"
|
126
|
-
data = {}
|
127
|
-
accessors = LogStash::Util::Accessors.new(data)
|
128
|
-
expect(accessors.strict_set(str, "foo")).to eq("foo")
|
129
|
-
expect(data).to eq({ "hello" => "foo"})
|
130
|
-
end
|
131
|
-
|
132
124
|
it "should set deep string value" do
|
133
125
|
str = "[hello][world]"
|
134
126
|
data = {}
|
@@ -145,14 +137,6 @@ describe LogStash::Util::Accessors, :if => true do
|
|
145
137
|
expect(data).to eq({ "hello" => { "world" => ["foo", "bar"] } })
|
146
138
|
end
|
147
139
|
|
148
|
-
it "should strict_set deep array value" do
|
149
|
-
str = "[hello][world]"
|
150
|
-
data = {}
|
151
|
-
accessors = LogStash::Util::Accessors.new(data)
|
152
|
-
expect(accessors.strict_set(str, ["foo", "bar"]) ).to eq(["foo", "bar"])
|
153
|
-
expect(data).to eq({ "hello" => { "world" => ["foo", "bar"] } })
|
154
|
-
end
|
155
|
-
|
156
140
|
it "should set element within array value" do
|
157
141
|
str = "[hello][0]"
|
158
142
|
data = {"hello" => ["foo", "bar"]}
|
@@ -181,35 +165,6 @@ describe LogStash::Util::Accessors, :if => true do
|
|
181
165
|
accessors = LogStash::Util::Accessors.new(data)
|
182
166
|
expect(accessors.del(str)).to eq(4)
|
183
167
|
expect(data).to eq({ "geocoords" => [2] })
|
184
|
-
end end
|
185
|
-
|
186
|
-
context "using invalid encoding" do
|
187
|
-
it "strinct_set should raise on non UTF-8 string encoding" do
|
188
|
-
str = "[hello]"
|
189
|
-
data = {}
|
190
|
-
accessors = LogStash::Util::Accessors.new(data)
|
191
|
-
expect { accessors.strict_set(str, "foo".encode("US-ASCII")) }.to raise_error
|
192
|
-
end
|
193
|
-
|
194
|
-
it "strinct_set should raise on non UTF-8 string encoding in array" do
|
195
|
-
str = "[hello]"
|
196
|
-
data = {}
|
197
|
-
accessors = LogStash::Util::Accessors.new(data)
|
198
|
-
expect { accessors.strict_set(str, ["foo", "bar".encode("US-ASCII")]) }.to raise_error
|
199
|
-
end
|
200
|
-
|
201
|
-
it "strinct_set should raise on invalid UTF-8 string encoding" do
|
202
|
-
str = "[hello]"
|
203
|
-
data = {}
|
204
|
-
accessors = LogStash::Util::Accessors.new(data)
|
205
|
-
expect { accessors.strict_set(str, "foo \xED\xB9\x81\xC3") }.to raise_error
|
206
|
-
end
|
207
|
-
|
208
|
-
it "strinct_set should raise on invalid UTF-8 string encoding in array" do
|
209
|
-
str = "[hello]"
|
210
|
-
data = {}
|
211
|
-
accessors = LogStash::Util::Accessors.new(data)
|
212
|
-
expect { accessors.strict_set(str, ["foo", "bar \xED\xB9\x81\xC3"]) }.to raise_error
|
213
168
|
end
|
214
169
|
end
|
215
170
|
end
|
data/spec/util/json_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require "logstash/json"
|
|
4
4
|
require "logstash/environment"
|
5
5
|
require "logstash/util"
|
6
6
|
|
7
|
-
describe LogStash::Json do
|
7
|
+
describe "LogStash::Json" do
|
8
8
|
|
9
9
|
let(:hash) {{"a" => 1}}
|
10
10
|
let(:json_hash) {"{\"a\":1}"}
|
@@ -33,27 +33,26 @@ describe LogStash::Json do
|
|
33
33
|
if LogStash::Environment.jruby?
|
34
34
|
|
35
35
|
### JRuby specific
|
36
|
-
|
36
|
+
# Former expectation in this code were removed because of https://github.com/rspec/rspec-mocks/issues/964
|
37
|
+
# as soon as is fix we can re introduce them if decired, however for now the completeness of the test
|
38
|
+
# is also not affected as the conversion would not work if the expectation where not meet.
|
39
|
+
###
|
37
40
|
context "jruby deserialize" do
|
38
41
|
it "should respond to load and deserialize object" do
|
39
|
-
expect(JrJackson::Raw).to receive(:parse_raw).with(json_hash).and_call_original
|
40
42
|
expect(LogStash::Json.load(json_hash)).to eql(hash)
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
46
|
context "jruby serialize" do
|
45
47
|
it "should respond to dump and serialize object" do
|
46
|
-
expect(JrJackson::Json).to receive(:dump).with(string).and_call_original
|
47
48
|
expect(LogStash::Json.dump(string)).to eql(json_string)
|
48
49
|
end
|
49
50
|
|
50
51
|
it "should call JrJackson::Raw.generate for Hash" do
|
51
|
-
expect(JrJackson::Raw).to receive(:generate).with(hash).and_call_original
|
52
52
|
expect(LogStash::Json.dump(hash)).to eql(json_hash)
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should call JrJackson::Raw.generate for Array" do
|
56
|
-
expect(JrJackson::Raw).to receive(:generate).with(array).and_call_original
|
57
56
|
expect(LogStash::Json.dump(array)).to eql(json_array)
|
58
57
|
end
|
59
58
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Jordan Sissel
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-06-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: cabin
|
@@ -124,6 +124,20 @@ dependencies:
|
|
124
124
|
version: 0.5.4
|
125
125
|
prerelease: false
|
126
126
|
type: :runtime
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: thread_safe
|
129
|
+
version_requirements: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ~>
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 0.3.5
|
134
|
+
requirement: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ~>
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.3.5
|
139
|
+
prerelease: false
|
140
|
+
type: :runtime
|
127
141
|
- !ruby/object:Gem::Dependency
|
128
142
|
name: jrjackson
|
129
143
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -233,9 +247,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
233
247
|
version: '0'
|
234
248
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
235
249
|
requirements:
|
236
|
-
- - '
|
250
|
+
- - '>='
|
237
251
|
- !ruby/object:Gem::Version
|
238
|
-
version:
|
252
|
+
version: '0'
|
239
253
|
requirements: []
|
240
254
|
rubyforge_project:
|
241
255
|
rubygems_version: 2.2.2
|