logstash-core 1.5.0.snapshot1-java → 1.5.1-java

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of logstash-core might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 743d8972e12c8d8eea45b4835d3aa61fd3552670
4
- data.tar.gz: 072a5f662af302799cbb330fb4a61aac962c3355
3
+ metadata.gz: fafba05d878e14fa01c8fc5a8b25ab4417fdecb3
4
+ data.tar.gz: 40ecd05d0b96587607bdb8d3f8d4ac8c51e921d1
5
5
  SHA512:
6
- metadata.gz: 9b491439a41e88c027ecf0c3639d8183b894e38561802b0c1aa40a2c2a6080e6a25fc1203b8878af4dd7ef81ab0c771a43becb040519672f14feb5edd758923d
7
- data.tar.gz: 525d34020708de68d2623eecfed261448864ad0f0818553e5b5d9b2c1c99274ce7f441a96446d99517d80932eb7c88f688afcb53c1b0ff92cd6e3c31098e5f65
6
+ metadata.gz: a96dcfa7d2f103ef370095269e3e6091411cd55634ad665517232097fd0907bf10a6313648823d5d682beaeecbcc4b9e20eb4c78c9f5dcd578698d75dcf3ae0f
7
+ data.tar.gz: 1a7485abfbd935277984f66a8bead8425b7ed7d389845751325eff72922755ea1eb8fcad1a09e9d2fc7e67fb5211a0ea01083be7f60df6b67ed975a69a3a8cb6
@@ -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
- @logger.warn(I18n.t("logstash.agent.sigint"))
117
- pipeline.shutdown
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; end
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.text_value}\n" \
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.text_value}\n" \
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
@@ -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, :validate => ::Encoding.name_list, :deprecated => true
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-users@googlegroups.com!")
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!")
@@ -115,7 +115,7 @@ class LogStash::Pipeline
115
115
  end
116
116
 
117
117
  def shutdown_filters
118
- @flusher_lock.synchronize { @flusher_thread.kill }
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
- @flusher_lock = Mutex.new
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
- @flusher_lock.synchronize { flush_filters_to_output! }
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 a parsed fields path for the path to the
9
- # container hash and key in that hash.
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
- def get(accessor)
14
- @cache ||= {}
15
- @cache[accessor] ||= parse(accessor)
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(accessor)
19
- path = accessor.split(/[\[\]]/).select{|s| !s.empty?}
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 an accessor field of the type
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
- def get(accessor)
34
- target, key = lookup(accessor)
35
- unless target.nil?
36
- target.is_a?(Array) ? target[key.to_i] : target[key]
37
- end
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
- def set(accessor, value)
41
- target, key = store_and_lookup(accessor)
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
- def strict_set(accessor, value)
46
- set(accessor, LogStash::Event.validate_value(value))
47
- end
48
-
49
- def del(accessor)
50
- target, key = lookup(accessor)
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
- def include?(accessor)
57
- target, key = lookup_path(accessor)
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
- def lookup(accessor)
65
- target, key = lookup_path(accessor)
66
- if target.nil?
67
- [target, key]
68
- else
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
- def store_and_lookup(accessor)
74
- @lut[accessor] ||= store_path(accessor)
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
- def lookup_path(accessor)
78
- key, path = PathCache.get(accessor)
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
- if r.nil?
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
- def store_path(accessor)
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]
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  # The version of logstash.
3
- LOGSTASH_VERSION = "1.5.0.snapshot1"
3
+ LOGSTASH_VERSION = "1.5.1"
4
4
 
5
5
  # Note to authors: this should not include dashes because 'gem' barfs if
6
6
  # you include a dash in the version string.
@@ -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
@@ -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)
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  module ConditionalFanciness
4
4
  def description
5
- return example.metadata[:example_group][:description_args][0]
5
+ return self.metadata[:description]
6
6
  end
7
7
 
8
8
  def conditional(expression, &block)
@@ -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
@@ -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 be_true
127
- expect(subject.include?("[c][d]")).to be_true
128
- expect(subject.include?("[j][k4][0][nested]")).to be_true
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 be_true
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 be_true
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 be_true
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 be_false
145
- expect(subject.include?("[j][doesnotexist]")).to be_false
146
- expect(subject.include?("[tag][0][hello][yes]")).to be_false
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 be_true
151
- expect(subject.include?("[tags][1]")).to be_false
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
 
@@ -58,16 +58,13 @@ end
58
58
 
59
59
  describe LogStash::Pipeline do
60
60
 
61
- context "teardown" do
62
-
63
- before(:each) do
64
- LogStash::Plugin.stub(:lookup)
65
- .with("input", "dummyinput").and_return(DummyInput)
66
- LogStash::Plugin.stub(:lookup)
67
- .with("codec", "plain").and_return(DummyCodec)
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 be_true
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 be_true
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 be_true
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 be_true
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 be_true
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 be_true
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 be_true
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 be_true
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 be_true
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 be_true
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 be_true
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 be_true
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?("bar")).to be_false
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 be_false
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 be_false
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 be_false
253
+ expect(Java::JavaUtil::LinkedHashMap.new({"foo" => 1}).key?("bar")).to eq(false)
254
254
  end
255
255
  end
256
256
  end
@@ -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
@@ -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.0.snapshot1
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-05-11 00:00:00.000000000 Z
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: 1.3.1
252
+ version: '0'
239
253
  requirements: []
240
254
  rubyforge_project:
241
255
  rubygems_version: 2.2.2