diff --git a/CHANGES.txt b/CHANGES.txt index 705ddbcd..a1ddf824 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,9 @@ CHANGES + +8.3.1 (Mar 22, 2024) +- Fixed ruby process hanging due to failed thread.join command, when calling destroy and a http request still active. +- Fixed streaming notification parser. Issue ref: https://github.com/splitio/ruby-client/issues/511 + 8.3.0 (Dec 11, 2023) - Added support for Flag Sets on the SDK, which enables grouping feature flags and interacting with the group rather than individually (more details in our documentation): - Added new variations of the get treatment methods to support evaluating flags in given flag set/s. diff --git a/LICENSE b/LICENSE index 65f5999d..c022e920 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright © 2023 Split Software, Inc. +Copyright © 2024 Split Software, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/lib/splitclient-rb/exceptions.rb b/lib/splitclient-rb/exceptions.rb index f8b9c62d..054e586a 100644 --- a/lib/splitclient-rb/exceptions.rb +++ b/lib/splitclient-rb/exceptions.rb @@ -1,7 +1,7 @@ module SplitIoClient class SplitIoError < StandardError; end - class SDKShutdownException < SplitIoError; end + class SDKShutdownException < Exception; end class SDKBlockerTimeoutExpiredException < SplitIoError; end diff --git a/lib/splitclient-rb/sse/event_source/event_parser.rb b/lib/splitclient-rb/sse/event_source/event_parser.rb index 2005b522..566cb5c2 100644 --- a/lib/splitclient-rb/sse/event_source/event_parser.rb +++ b/lib/splitclient-rb/sse/event_source/event_parser.rb @@ -43,7 +43,8 @@ def first_event(raw_data) private def parse_event_data(data, type) - event_data = JSON.parse(data.sub('data: ', '')) + data_value = data.sub('data:', '') + event_data = JSON.parse(data_value.strip) client_id = event_data['clientId']&.strip channel = event_data['channel']&.strip parsed_data = JSON.parse(event_data['data']) unless type == 'error' diff --git a/lib/splitclient-rb/version.rb b/lib/splitclient-rb/version.rb index 65859346..b330c8de 100644 --- a/lib/splitclient-rb/version.rb +++ b/lib/splitclient-rb/version.rb @@ -1,3 +1,3 @@ module SplitIoClient - VERSION = '8.3.0' + VERSION = '8.3.1' end diff --git a/spec/integrations/push_client_spec.rb b/spec/integrations/push_client_spec.rb index 51b4b0ba..6c28960b 100644 --- a/spec/integrations/push_client_spec.rb +++ b/spec/integrations/push_client_spec.rb @@ -168,8 +168,16 @@ client = factory.client client.block_until_ready - sleep(2) - expect(client.get_treatment('admin', 'bilal_split')).to eq('off') + + treatment = 'control' + for i in 1..5 do + p i + sleep(1) + treatment = client.get_treatment('admin', 'bilal_split') + break if treatment != 'control' + end + + expect(treatment).to eq('off') end end diff --git a/spec/sse/event_source/event_parser_spec.rb b/spec/sse/event_source/event_parser_spec.rb index da2c136e..f0d61c0c 100644 --- a/spec/sse/event_source/event_parser_spec.rb +++ b/spec/sse/event_source/event_parser_spec.rb @@ -7,6 +7,7 @@ let(:log) { StringIO.new } let(:config) { SplitIoClient::SplitConfig.new(logger: Logger.new(log)) } + let(:event_split_update_ws) { "fb\r\nid:123\nevent:message\ndata:{\"id\":\"1\",\"clientId\":\"emptyClientId\",\"connectionId\":\"1\",\"timestamp\":1582045421733,\"channel\":\"channel-test\",\"data\":\"{\\\"type\\\" : \\\"SPLIT_UPDATE\\\",\\\"changeNumber\\\": 5564531221}\",\"name\":\"asdasd\"}\n\n\r\n" } let(:event_split_update) { "fb\r\nid: 123\nevent: message\ndata: {\"id\":\"1\",\"clientId\":\"emptyClientId\",\"connectionId\":\"1\",\"timestamp\":1582045421733,\"channel\":\"channel-test\",\"data\":\"{\\\"type\\\" : \\\"SPLIT_UPDATE\\\",\\\"changeNumber\\\": 5564531221}\",\"name\":\"asdasd\"}\n\n\r\n" } let(:event_split_kill) { "fb\r\nid: 123\nevent: message\ndata: {\"id\":\"1\",\"clientId\":\"emptyClientId\",\"connectionId\":\"1\",\"timestamp\":1582045421733,\"channel\":\"channel-test\",\"data\":\"{\\\"type\\\" : \\\"SPLIT_KILL\\\",\\\"changeNumber\\\": 5564531221, \\\"defaultTreatment\\\" : \\\"off\\\", \\\"splitName\\\" : \\\"split-test\\\"}\",\"name\":\"asdasd\"}\n\n\r\n" } let(:event_segment_update) { "fb\r\nid: 123\nevent: message\ndata: {\"id\":\"1\",\"clientId\":\"emptyClientId\",\"connectionId\":\"1\",\"timestamp\":1582045421733,\"channel\":\"channel-test\",\"data\":\"{\\\"type\\\" : \\\"SEGMENT_UPDATE\\\",\\\"changeNumber\\\": 5564531221, \\\"segmentName\\\" : \\\"segment-test\\\"}\",\"name\":\"asdasd\"}\n\n\r\n" } @@ -25,6 +26,16 @@ expect(event.channel).to eq('channel-test') end + it 'split update event - fixing event parser' do + parser = subject.new(config) + + event = parser.parse(event_split_update_ws)[0] + expect(event.event_type).to eq('message') + expect(event.data['type']).to eq('SPLIT_UPDATE') + expect(event.data['changeNumber']).to eq(5_564_531_221) + expect(event.channel).to eq('channel-test') + end + it 'split kill event' do parser = subject.new(config)