logstash-core-event-java 5.0.0.alpha6.snapshot5-java → 5.0.0-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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86c3829defeae0811a51be672c8d40d25375b88b
4
- data.tar.gz: 8463e3c3aec224ced8ff2ab472d3270e7b0a19bf
3
+ metadata.gz: 5e91246ebcab4d5729e3b452816a10fe8025a7b0
4
+ data.tar.gz: 1b01a6229f0c1103d45c3b1ec1ef52f9309c4a47
5
5
  SHA512:
6
- metadata.gz: 78dde0a65932fb1cd6fde3e38e0ca3a89612c6cc33b868ec5b4a25df5dbb0626e6ba26c945f8b8a47f0e5784001dc4cc5f859bd3b0527dddc30beec7e1a691fe
7
- data.tar.gz: c0bc8bc63d98ce24dddcf0c948cbef2857cb8549846b6badbf540a4fe820705fb1c3c0b22d8c358e43c020e0f85b44de10f04407ce46cf26542250c583c0d02c
6
+ metadata.gz: 8636ce4953e1ca650f13527d6e60021db69675d70c7c359659a43ee7711bbf944c5b5dca2a15fc6e7d58ebaaabd1eb274b90295c414993f5e71b6b7a0409e266
7
+ data.tar.gz: 393c31cc0c9e2abd277983d1f9a0321475f179131f5e120a55d07e4eb4c7db9c9a948cf3115411cabe7d9c21983fb5fd9fdcdb81f2bc8c189dfe8ed0e268a788
@@ -25,4 +25,4 @@ end
25
25
  require "jruby_event_ext"
26
26
  require "jruby_timestamp_ext"
27
27
  require "logstash/event"
28
- require "logstash/timestamp"
28
+ require "logstash/timestamp"
@@ -5,4 +5,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.
7
7
 
8
- LOGSTASH_CORE_EVENT_JAVA_VERSION = "5.0.0.alpha6.snapshot5"
8
+ LOGSTASH_CORE_EVENT_JAVA_VERSION = "5.0.0"
@@ -29,9 +29,26 @@ module LogStash
29
29
 
30
30
  # LogStash::SHUTDOWN is used by plugins
31
31
  SHUTDOWN = ShutdownEvent.new
32
+
33
+ class Event
34
+ MSG_BRACKETS_METHOD_MISSING = "Direct event field references (i.e. event['field']) have been disabled in favor of using event get and set methods (e.g. event.get('field')). Please consult the Logstash 5.0 breaking changes documentation for more details.".freeze
35
+ MSG_BRACKETS_EQUALS_METHOD_MISSING = "Direct event field references (i.e. event['field'] = 'value') have been disabled in favor of using event get and set methods (e.g. event.set('field', 'value')). Please consult the Logstash 5.0 breaking changes documentation for more details.".freeze
36
+ RE_BRACKETS_METHOD = /^\[\]$/.freeze
37
+ RE_BRACKETS_EQUALS_METHOD = /^\[\]=$/.freeze
38
+
39
+ def method_missing(method_name, *arguments, &block)
40
+ if RE_BRACKETS_METHOD.match(method_name.to_s)
41
+ raise NoMethodError.new(MSG_BRACKETS_METHOD_MISSING)
42
+ end
43
+ if RE_BRACKETS_EQUALS_METHOD.match(method_name.to_s)
44
+ raise NoMethodError.new(MSG_BRACKETS_EQUALS_METHOD_MISSING)
45
+ end
46
+ super
47
+ end
48
+ end
32
49
  end
33
50
 
34
51
  # for backward compatibility, require "logstash/event" is used a lots of places so let's bootstrap the
35
52
  # Java code loading from here.
36
53
  # TODO: (colin) I think we should mass replace require "logstash/event" with require "logstash-core-event"
37
- require "logstash-core-event"
54
+ require "logstash-core-event"
@@ -6,12 +6,12 @@ module LogStash
6
6
 
7
7
  # clear the global compiled templates cache
8
8
  def clear_cache
9
- Java::ComLogstash::StringInterpolation.get_instance.clear_cache;
9
+ Java::OrgLogstash::StringInterpolation.get_instance.clear_cache;
10
10
  end
11
11
 
12
12
  # @return [Fixnum] the compiled templates cache size
13
13
  def cache_size
14
- Java::ComLogstash::StringInterpolation.get_instance.cache_size;
14
+ Java::OrgLogstash::StringInterpolation.get_instance.cache_size;
15
15
  end
16
16
  end
17
17
  end
@@ -5,7 +5,6 @@ require "logstash/util"
5
5
  require "logstash/event"
6
6
  require "json"
7
7
  require "java"
8
- # java_import 'com.logstash.Util'
9
8
 
10
9
  TIMESTAMP = "@timestamp"
11
10
 
@@ -36,7 +35,7 @@ describe LogStash::Event do
36
35
  end
37
36
  end
38
37
 
39
- context "[]" do
38
+ context "#get" do
40
39
  it "should get simple values" do
41
40
  e = LogStash::Event.new({"foo" => "bar", "bar" => 1, "baz" => 1.0, TIMESTAMP => "2015-05-28T23:02:05.350Z"})
42
41
  expect(e.get("foo")).to eq("bar")
@@ -64,7 +63,7 @@ describe LogStash::Event do
64
63
  end
65
64
  end
66
65
 
67
- context "[]=" do
66
+ context "#set" do
68
67
  it "should set simple values" do
69
68
  e = LogStash::Event.new()
70
69
  expect(e.set("foo", "bar")).to eq("bar")
@@ -123,7 +122,7 @@ describe LogStash::Event do
123
122
  end
124
123
 
125
124
  it "should set XXJavaProxy Jackson crafted" do
126
- proxy = com.logstash.Util.getMapFixtureJackson()
125
+ proxy = org.logstash.Util.getMapFixtureJackson()
127
126
  # proxy is {"string": "foo", "int": 42, "float": 42.42, "array": ["bar","baz"], "hash": {"string":"quux"} }
128
127
  e = LogStash::Event.new()
129
128
  e.set("[proxy]", proxy)
@@ -136,7 +135,7 @@ describe LogStash::Event do
136
135
  end
137
136
 
138
137
  it "should set XXJavaProxy hand crafted" do
139
- proxy = com.logstash.Util.getMapFixtureHandcrafted()
138
+ proxy = org.logstash.Util.getMapFixtureHandcrafted()
140
139
  # proxy is {"string": "foo", "int": 42, "float": 42.42, "array": ["bar","baz"], "hash": {"string":"quux"} }
141
140
  e = LogStash::Event.new()
142
141
  e.set("[proxy]", proxy)
@@ -159,12 +158,12 @@ describe LogStash::Event do
159
158
  it "to_hash should inject a Ruby LogStash::Timestamp" do
160
159
  e = LogStash::Event.new()
161
160
 
162
- expect(e.to_java).to be_kind_of(Java::ComLogstash::Event)
163
- expect(e.to_java.get_field(TIMESTAMP)).to be_kind_of(Java::ComLogstash::Timestamp)
161
+ expect(e.to_java).to be_kind_of(Java::OrgLogstash::Event)
162
+ expect(e.to_java.get_field(TIMESTAMP)).to be_kind_of(Java::OrgLogstash::Timestamp)
164
163
 
165
164
  expect(e.to_hash[TIMESTAMP]).to be_kind_of(LogStash::Timestamp)
166
165
  # now make sure the original map was not touched
167
- expect(e.to_java.get_field(TIMESTAMP)).to be_kind_of(Java::ComLogstash::Timestamp)
166
+ expect(e.to_java.get_field(TIMESTAMP)).to be_kind_of(Java::OrgLogstash::Timestamp)
168
167
  end
169
168
 
170
169
  it "should set timestamp" do
@@ -307,4 +306,20 @@ describe LogStash::Event do
307
306
  end
308
307
 
309
308
  end
309
+
310
+ context "method missing exception messages" do
311
+ subject { LogStash::Event.new({"foo" => "bar"}) }
312
+
313
+ it "#[] method raises a better exception message" do
314
+ expect { subject["foo"] }.to raise_error(NoMethodError, /Direct event field references \(i\.e\. event\['field'\]\)/)
315
+ end
316
+
317
+ it "#[]= method raises a better exception message" do
318
+ expect { subject["foo"] = "baz" }.to raise_error(NoMethodError, /Direct event field references \(i\.e\. event\['field'\] = 'value'\)/)
319
+ end
320
+
321
+ it "other missing method raises normal exception message" do
322
+ expect { subject.baz() }.to raise_error(NoMethodError, /undefined method `baz' for/)
323
+ end
324
+ end
310
325
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-core-event-java
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.alpha6.snapshot5
4
+ version: 5.0.0
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-26 00:00:00.000000000 Z
11
+ date: 2016-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -46,9 +46,7 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - lib/com/fasterxml/jackson/core/jackson-annotations/2.7.0/jackson-annotations-2.7.0.jar
49
- - lib/com/fasterxml/jackson/core/jackson-core/2.7.1/jackson-core-2.7.1.jar
50
49
  - lib/com/fasterxml/jackson/core/jackson-core/2.7.3/jackson-core-2.7.3.jar
51
- - lib/com/fasterxml/jackson/core/jackson-databind/2.7.1-1/jackson-databind-2.7.1-1.jar
52
50
  - lib/com/fasterxml/jackson/core/jackson-databind/2.7.3/jackson-databind-2.7.3.jar
53
51
  - lib/logstash-core-event-java.rb
54
52
  - lib/logstash-core-event-java/logstash-core-event-java.jar
@@ -77,9 +75,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
75
  version: '0'
78
76
  required_rubygems_version: !ruby/object:Gem::Requirement
79
77
  requirements:
80
- - - ">"
78
+ - - ">="
81
79
  - !ruby/object:Gem::Version
82
- version: 1.3.1
80
+ version: '0'
83
81
  requirements:
84
82
  - jar com.fasterxml.jackson.core:jackson-core, 2.7.3
85
83
  - jar com.fasterxml.jackson.core:jackson-databind, 2.7.3