From fed5cee116bc8428f0d4e881e9d045538668cd22 Mon Sep 17 00:00:00 2001 From: Vitaliy Zavadovskyi Date: Fri, 19 Apr 2024 18:20:40 +0300 Subject: [PATCH 1/3] fix #77 and many oithers with Failed to handshake --- lib/logstash/outputs/bson/big_decimal.rb | 2 +- lib/logstash/outputs/bson/logstash_event.rb | 2 +- lib/logstash/outputs/bson/logstash_timestamp.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/logstash/outputs/bson/big_decimal.rb b/lib/logstash/outputs/bson/big_decimal.rb index 3b5d4ef..89cabe6 100644 --- a/lib/logstash/outputs/bson/big_decimal.rb +++ b/lib/logstash/outputs/bson/big_decimal.rb @@ -43,7 +43,7 @@ module ClassMethods # @param [ BSON ] bson object from Mongo. # @return [ BigDecimal ] The decoded BigDecimal. # @see http://bsonspec.org/#/specification - def from_bson(bson) + def from_bson(bson, **_options) from_bson_double(bson.get_bytes(8)) end diff --git a/lib/logstash/outputs/bson/logstash_event.rb b/lib/logstash/outputs/bson/logstash_event.rb index 9b4e17c..fe6f5cf 100644 --- a/lib/logstash/outputs/bson/logstash_event.rb +++ b/lib/logstash/outputs/bson/logstash_event.rb @@ -55,7 +55,7 @@ module ClassMethods # @param [ ByteBuffer ] buffer The byte buffer. # @return [ Event ] The decoded bson document. # @see http://bsonspec.org/#/specification - def from_bson(buffer) + def from_bson(buffer, **_options) hash = Hash.new buffer.get_int32 # Throw away the size. while (type = buffer.get_byte) != NULL_BYTE diff --git a/lib/logstash/outputs/bson/logstash_timestamp.rb b/lib/logstash/outputs/bson/logstash_timestamp.rb index 6eae0f0..d8f7deb 100644 --- a/lib/logstash/outputs/bson/logstash_timestamp.rb +++ b/lib/logstash/outputs/bson/logstash_timestamp.rb @@ -34,7 +34,7 @@ module ClassMethods # @param [ BSON ] bson encoded time. # @return [ ::LogStash::Timestamp ] The decoded UTC time as a ::LogStash::Timestamp. # @see http://bsonspec.org/#/specification - def from_bson(bson) + def from_bson(bson, **_options) seconds, fragment = BSON::Int64.from_bson(bson).divmod(1000) new(::Time.at(seconds, fragment * 1000).utc) end From 4b62b5fb566a2c1efbda6381654cc2174a09c422 Mon Sep 17 00:00:00 2001 From: Vitaliy Zavadovskyi Date: Fri, 19 Apr 2024 18:44:28 +0300 Subject: [PATCH 2/3] Fix #88 fix not used arguments test failture --- lib/logstash/outputs/bson/big_decimal.rb | 4 ++-- lib/logstash/outputs/bson/logstash_event.rb | 2 +- lib/logstash/outputs/bson/logstash_timestamp.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/logstash/outputs/bson/big_decimal.rb b/lib/logstash/outputs/bson/big_decimal.rb index 89cabe6..d34b373 100644 --- a/lib/logstash/outputs/bson/big_decimal.rb +++ b/lib/logstash/outputs/bson/big_decimal.rb @@ -33,8 +33,8 @@ module BigDecimal # 1.221311.to_bson # @return [ String ] The encoded string. # @see http://bsonspec.org/#/specification - def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) - buffer.put_bytes([ self ].pack(PACK)) + def to_bson(buffer = ByteBuffer.new, _validating_keys = nil) + buffer.put_bytes([ self ].pack(PACK)) end module ClassMethods diff --git a/lib/logstash/outputs/bson/logstash_event.rb b/lib/logstash/outputs/bson/logstash_event.rb index fe6f5cf..7e4c27f 100644 --- a/lib/logstash/outputs/bson/logstash_event.rb +++ b/lib/logstash/outputs/bson/logstash_event.rb @@ -30,7 +30,7 @@ module LogStashEvent # Event.new("field" => "value").to_bson # @return [ String ] The encoded string. # @see http://bsonspec.org/#/specification - def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) + def to_bson(buffer = ByteBuffer.new, _validating_keys = nil) position = buffer.length buffer.put_int32(0) to_hash.each do |field, value| diff --git a/lib/logstash/outputs/bson/logstash_timestamp.rb b/lib/logstash/outputs/bson/logstash_timestamp.rb index d8f7deb..ad1d5f4 100644 --- a/lib/logstash/outputs/bson/logstash_timestamp.rb +++ b/lib/logstash/outputs/bson/logstash_timestamp.rb @@ -25,7 +25,7 @@ module LogStashTimestamp # A time is type 0x09 in the BSON spec. BSON_TYPE = 9.chr.force_encoding(BINARY).freeze - def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) + def to_bson(buffer = ByteBuffer.new, _validating_keys = nil) time.to_bson(buffer) end From f9093e24e3e3df12494d5ec9be86369b5b92942a Mon Sep 17 00:00:00 2001 From: Vitaliy Zavadovskyi Date: Mon, 22 Apr 2024 15:21:38 +0300 Subject: [PATCH 3/3] Bump version to 3.1.8. Updated changelog. --- CHANGELOG.md | 4 +++- CONTRIBUTORS | 1 + logstash-output-mongodb.gemspec | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e03cde..d5752ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ -## #unreleased +## 3.1.8 + - Fix tests failture for ELASTIC_STACK_VERSION=8.x. Fail message: undefined method `validating_keys?' for BSON::Config:Module + - Fix MongoDB connection error - Failed to handshake [#88] https://github.com/logstash-plugins/logstash-output-mongodb/issues/88 - Fix: Fix failing test spec on jruby-9.3.4.0 [#81](https://github.com/logstash-plugins/logstash-output-mongodb/pull/81) ## 3.1.7 diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 49e2484..c153bdd 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -16,6 +16,7 @@ Contributors: * bitsofinfo (bitsofinfo) * Guy Boertje (guyboertje) * Colin Surprenant (colinsurprenant) +* Vitalii Zavadovskyy Note: If you've sent us patches, bug reports, or otherwise contributed to Logstash, and you aren't on the list above and want to be, please let us know diff --git a/logstash-output-mongodb.gemspec b/logstash-output-mongodb.gemspec index b2cd699..f9d1c2c 100644 --- a/logstash-output-mongodb.gemspec +++ b/logstash-output-mongodb.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = 'logstash-output-mongodb' - s.version = '3.1.7' + s.version = '3.1.8' s.licenses = ['Apache License (2.0)'] s.summary = "Writes events to MongoDB" 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"