You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by kc...@apache.org on 2008/06/18 03:14:36 UTC
svn commit: r668989 - in /incubator/thrift/trunk/lib/rb:
lib/thrift/struct.rb spec/struct_spec.rb
Author: kclark
Date: Tue Jun 17 18:14:36 2008
New Revision: 668989
URL: http://svn.apache.org/viewvc?rev=668989&view=rev
Log:
Fix default values of non-primitive types being shared between struct instances (THRIFT-4)
Modified:
incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb
incubator/thrift/trunk/lib/rb/spec/struct_spec.rb
Modified: incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb?rev=668989&r1=668988&r2=668989&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb Tue Jun 17 18:14:36 2008
@@ -4,7 +4,7 @@
module Struct
def initialize(d={})
each_field do |fid, type, name, default|
- instance_variable_set("@#{name}", d[name.to_s] || d[name.intern] || default)
+ instance_variable_set("@#{name}", d[name.to_s] || d[name.intern] || (default.dup rescue default))
end
end
Modified: incubator/thrift/trunk/lib/rb/spec/struct_spec.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/struct_spec.rb?rev=668989&r1=668988&r2=668989&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/struct_spec.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/struct_spec.rb Tue Jun 17 18:14:36 2008
@@ -37,15 +37,13 @@
end
it "should not share default values between instances" do
- pending do
- begin
- struct = Foo.new
- struct.ints << 17
- Foo.new.ints.should == [1,2,2,3]
- ensure
- # ensure no leakage to other tests
- Foo::FIELDS[4][:default] = [1,2,2,3]
- end
+ begin
+ struct = Foo.new
+ struct.ints << 17
+ Foo.new.ints.should == [1,2,2,3]
+ ensure
+ # ensure no leakage to other tests
+ Foo::FIELDS[4][:default] = [1,2,2,3]
end
end