You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2018/07/04 15:58:01 UTC
[29/41] qpid-proton git commit: PROTON-1861: [ruby] offered/desired
capabilities should be decoded as "multiple" fields
PROTON-1861: [ruby] offered/desired capabilities should be decoded as "multiple" fields
capabilities are encoded as a "multiple" symbol field. "multiple" fields can be
encoded either as an array or a single value. The connection accessors return an
Array in all cases.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/27f9aec2
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/27f9aec2
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/27f9aec2
Branch: refs/heads/go1
Commit: 27f9aec21d737279f117282f136ba9b1b0fd1c06
Parents: af93c80
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Jun 13 18:24:06 2018 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Jun 13 18:24:06 2018 -0400
----------------------------------------------------------------------
ruby/examples/server.rb | 2 +-
ruby/lib/codec/data.rb | 10 +++++++++-
ruby/lib/core/connection.rb | 6 ++++--
3 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/27f9aec2/ruby/examples/server.rb
----------------------------------------------------------------------
diff --git a/ruby/examples/server.rb b/ruby/examples/server.rb
index 7538d61..7ebd807 100644
--- a/ruby/examples/server.rb
+++ b/ruby/examples/server.rb
@@ -37,7 +37,7 @@ class Server < Qpid::Proton::MessagingHandler
def on_connection_open(connection)
if connection.offered_capabilities &&
- connection.offered_capabilities.contain?("ANONYMOUS-RELAY")
+ connection.offered_capabilities.include?(:"ANONYMOUS-RELAY")
@relay = connection.open_sender({:target => nil})
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/27f9aec2/ruby/lib/codec/data.rb
----------------------------------------------------------------------
diff --git a/ruby/lib/codec/data.rb b/ruby/lib/codec/data.rb
index ec74756..b6ce869 100644
--- a/ruby/lib/codec/data.rb
+++ b/ruby/lib/codec/data.rb
@@ -42,6 +42,15 @@ module Qpid::Proton
end
# @private
+ # Convert a pn_data_t* containing an AMQP "multiple" field to an Array or nil.
+ # A "multiple" field can be encoded as an array or a single value - always return Array.
+ # @return [Array, nil] The ruby Array extracted from +impl+ or nil if impl is empty
+ def self.to_multiple(impl)
+ o = self.to_object(impl)
+ Array(o) if o
+ end
+
+ # @private
# Clear a pn_data_t* and convert a ruby object into it. If x==nil leave it empty.
def self.from_object(impl, x)
d = Data.new(impl)
@@ -676,7 +685,6 @@ module Qpid::Proton
return err
end
end
-
end
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/27f9aec2/ruby/lib/core/connection.rb
----------------------------------------------------------------------
diff --git a/ruby/lib/core/connection.rb b/ruby/lib/core/connection.rb
index e54ce16..3586790 100644
--- a/ruby/lib/core/connection.rb
+++ b/ruby/lib/core/connection.rb
@@ -77,13 +77,15 @@ module Qpid::Proton
# @return [Array<Symbol>] offered capabilities provided by the remote peer
def offered_capabilities
- Codec::Data.to_object(Cproton.pn_connection_remote_offered_capabilities(@impl))
+ # Provide capabilities consistently as an array, even if encoded as a single symbol
+ Codec::Data.to_multiple(Cproton.pn_connection_remote_offered_capabilities(@impl))
end
deprecated_alias :remote_offered_capabilities, :offered_capabilities
# @return [Array<Symbol>] desired capabilities provided by the remote peer
def desired_capabilities
- Codec::Data.to_object(Cproton.pn_connection_remote_desired_capabilities(@impl))
+ # Provide capabilities consistently as an array, even if encoded as a single symbol
+ Codec::Data.to_multiple(Cproton.pn_connection_remote_desired_capabilities(@impl))
end
deprecated_alias :remote_desired_capabilities, :desired_capabilities
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org