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/03/28 16:33:57 UTC

qpid-proton git commit: PROTON-1789: [ruby] Remove incorrect type-adjustments for maps

Repository: qpid-proton
Updated Branches:
  refs/heads/master bbe9195e1 -> 06e931f6e


PROTON-1789: [ruby] Remove incorrect type-adjustments for maps

Removed incorrect code to force the key type of application-properties and
annotation maps to SYMBOL. For now the user is required to use the correct
types. We may add correct validation or conversion code in future.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/06e931f6
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/06e931f6
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/06e931f6

Branch: refs/heads/master
Commit: 06e931f6ee4d0631e68131b21e6f84d83ba8b913
Parents: bbe9195
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Mar 28 12:31:23 2018 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Mar 28 12:31:23 2018 -0400

----------------------------------------------------------------------
 proton-c/bindings/ruby/lib/core/connection.rb  |  9 +++------
 proton-c/bindings/ruby/lib/core/message.rb     | 12 +++---------
 proton-c/bindings/ruby/lib/types/hash.rb       | 17 -----------------
 proton-c/bindings/ruby/tests/test_container.rb |  6 +++---
 4 files changed, 9 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06e931f6/proton-c/bindings/ruby/lib/core/connection.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/connection.rb b/proton-c/bindings/ruby/lib/core/connection.rb
index dc2590f..e54ce16 100644
--- a/proton-c/bindings/ruby/lib/core/connection.rb
+++ b/proton-c/bindings/ruby/lib/core/connection.rb
@@ -134,12 +134,9 @@ module Qpid::Proton
       Cproton.pn_connection_set_password(@impl, opts[:password]) if opts[:password]
       Cproton.pn_connection_set_hostname(@impl, opts[:virtual_host]) if opts[:virtual_host]
       @link_prefix = opts[:link_prefix] || cid
-      Codec::Data.from_object(Cproton.pn_connection_offered_capabilities(@impl),
-                              Types.symbol_array(opts[:offered_capabilities]))
-      Codec::Data.from_object(Cproton.pn_connection_desired_capabilities(@impl),
-                              Types.symbol_array(opts[:desired_capabilities]))
-      Codec::Data.from_object(Cproton.pn_connection_properties(@impl),
-                              Types.symbol_keys(opts[:properties]))
+      Codec::Data.from_object(Cproton.pn_connection_offered_capabilities(@impl), opts[:offered_capabilities])
+      Codec::Data.from_object(Cproton.pn_connection_desired_capabilities(@impl), opts[:desired_capabilities])
+      Codec::Data.from_object(Cproton.pn_connection_properties(@impl), opts[:properties])
     end
 
     # Idle-timeout advertised by the remote peer, in seconds.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06e931f6/proton-c/bindings/ruby/lib/core/message.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/message.rb b/proton-c/bindings/ruby/lib/core/message.rb
index 9afaa0a..9f83cfd 100644
--- a/proton-c/bindings/ruby/lib/core/message.rb
+++ b/proton-c/bindings/ruby/lib/core/message.rb
@@ -70,18 +70,12 @@ module Qpid::Proton
       end
     end
 
+    # @private nill
     # @private
     def pre_encode
       # encode elements from the message
-      Codec::Data.from_object(Cproton::pn_message_properties(@impl),
-                              !@properties.empty? && Types.symbol_keys!(@properties))
-      Codec::Data.from_object(Cproton::pn_message_instructions(@impl),
-                              !@instructions.empty? && Types.symbol_keys!(@instructions))
-      if @annotations           # Make sure keys are symbols
-        @annotations.keys.each do |k|
-          @annotations[k.to_sym] = @annotations.delete(k) unless k.is_a? Symbol
-        end
-      end
+      Codec::Data.from_object(Cproton::pn_message_properties(@impl), !@properties.empty? && @properties)
+      Codec::Data.from_object(Cproton::pn_message_instructions(@impl), !@instructions.empty? && @instructions)
       Codec::Data.from_object(Cproton::pn_message_annotations(@impl), !@annotations.empty? && @annotations)
       Codec::Data.from_object(Cproton::pn_message_body(@impl), @body)
     end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06e931f6/proton-c/bindings/ruby/lib/types/hash.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/types/hash.rb b/proton-c/bindings/ruby/lib/types/hash.rb
index 70d54bd..a4bad8f 100644
--- a/proton-c/bindings/ruby/lib/types/hash.rb
+++ b/proton-c/bindings/ruby/lib/types/hash.rb
@@ -37,20 +37,3 @@ class Hash # :nodoc:
   end
 end
 
-module Qpid::Proton::Types
-  # @private
-  def self.symbol_keys(h)
-    h && h.reduce({}) { |x, (k, v)| x[k.to_sym] = v; x }
-  end
-
-  # @private
-  def self.symbol_keys!(h)
-    h.keys.each { |k| h[k.to_sym] = h.delete(k) unless k.is_a? Symbol } if h
-    h
-  end
-
-  # @private
-  def self.symbol_array(a)
-    a && UniformArray.new(SYMBOL, a.collect { |v| v.to_sym })
-  end
-end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06e931f6/proton-c/bindings/ruby/tests/test_container.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_container.rb b/proton-c/bindings/ruby/tests/test_container.rb
index adce409..1026d46 100644
--- a/proton-c/bindings/ruby/tests/test_container.rb
+++ b/proton-c/bindings/ruby/tests/test_container.rb
@@ -183,9 +183,9 @@ class ContainerTest < MiniTest::Test
     })
     client = cont.connect(cont.url,
       {:virtual_host => "client.to.server",
-        :properties => { :foo => :bar, "str" => "str" },
+        :properties => { "foo" => :bar, "str" => "str" },
         :offered_capabilities => [:c1 ],
-        :desired_capabilities => ["c2" ],
+        :desired_capabilities => [:c2 ],
         :idle_timeout => 42,
         :max_sessions =>100,
         :max_frame_size => 4096,
@@ -195,7 +195,7 @@ class ContainerTest < MiniTest::Test
 
     c = server_handler.connection
     assert_equal "client.to.server", c.virtual_host
-    assert_equal({ :foo => :bar, :str => "str" }, c.properties)
+    assert_equal({ "foo" => :bar, "str" => "str" }, c.properties)
     assert_equal([:c1], c.offered_capabilities)
     assert_equal([:c2], c.desired_capabilities)
     assert_equal 21, c.idle_timeout # Proton divides by 2


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org