avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1447958 - in /avro/trunk: CHANGES.txt lang/ruby/lib/avro/io.rb lang/ruby/test/random_data.rb lang/ruby/test/test_io.rb
Date Tue, 19 Feb 2013 23:14:50 GMT
Author: cutting
Date: Tue Feb 19 23:14:49 2013
New Revision: 1447958

URL: http://svn.apache.org/r1447958
Log:
AVRO-1258. Ruby: Fix handing of RPC errors.  Contributed by Martin Kleppmann.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/ruby/lib/avro/io.rb
    avro/trunk/lang/ruby/test/random_data.rb
    avro/trunk/lang/ruby/test/test_io.rb

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1447958&r1=1447957&r2=1447958&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Tue Feb 19 23:14:49 2013
@@ -91,6 +91,8 @@ Trunk (not yet released)
     AVRO-1257. Ruby: Fix UTF-8 encoding in Ruby 1.9.
     (Martin Kleppmann via cutting)
 
+    AVRO-1258. Ruby: Fix handing of RPC errors.  (Martin Kleppmann via cutting)
+
 Avro 1.7.3 (6 December 2012)
 
   NEW FEATURES

Modified: avro/trunk/lang/ruby/lib/avro/io.rb
URL: http://svn.apache.org/viewvc/avro/trunk/lang/ruby/lib/avro/io.rb?rev=1447958&r1=1447957&r2=1447958&view=diff
==============================================================================
--- avro/trunk/lang/ruby/lib/avro/io.rb (original)
+++ avro/trunk/lang/ruby/lib/avro/io.rb Tue Feb 19 23:14:49 2013
@@ -245,7 +245,7 @@ module Avro
           when 'record'
             return check_props(writers_schema, readers_schema, [:fullname])
           when 'error'
-            return check_props(writers_scheam, readers_schema, [:fullname])
+            return check_props(writers_schema, readers_schema, [:fullname])
           when 'request'
             return true
           when 'fixed'
@@ -315,7 +315,7 @@ module Avro
         when 'array';   read_array(writers_schema, readers_schema, decoder)
         when 'map';     read_map(writers_schema, readers_schema, decoder)
         when 'union';   read_union(writers_schema, readers_schema, decoder)
-        when 'record', 'errors', 'request';  read_record(writers_schema, readers_schema,
decoder)
+        when 'record', 'error', 'request';  read_record(writers_schema, readers_schema, decoder)
         else
           raise AvroError, "Cannot read unknown schema type: #{writers_schema.type}"
         end
@@ -443,7 +443,7 @@ module Avro
           return read_map
         when 'union'
           return read_default_value(field_schema.schemas[0], default_value)
-        when 'record'
+        when 'record', 'error'
           read_record = {}
           field_schema.fields.each do |field|
             json_val = default_value[field.name]
@@ -454,7 +454,7 @@ module Avro
           return read_record
         else
           fail_msg = "Unknown type: #{field_schema.type}"
-          raise AvroError(fail_msg)
+          raise AvroError, fail_msg
         end
       end
 
@@ -566,7 +566,7 @@ module Avro
         when 'array';   write_array(writers_schema, datum, encoder)
         when 'map';     write_map(writers_schema, datum, encoder)
         when 'union';   write_union(writers_schema, datum, encoder)
-        when 'record', 'errors', 'request';  write_record(writers_schema, datum, encoder)
+        when 'record', 'error', 'request';  write_record(writers_schema, datum, encoder)
         else
           raise AvroError.new("Unknown type: #{writers_schema.type}")
         end

Modified: avro/trunk/lang/ruby/test/random_data.rb
URL: http://svn.apache.org/viewvc/avro/trunk/lang/ruby/test/random_data.rb?rev=1447958&r1=1447957&r2=1447958&view=diff
==============================================================================
--- avro/trunk/lang/ruby/test/random_data.rb (original)
+++ avro/trunk/lang/ruby/test/random_data.rb Tue Feb 19 23:14:49 2013
@@ -58,7 +58,7 @@ class RandomData
         map[nextdata(Avro::Schema::PrimitiveSchema.new('string'))] = nextdata(schm.values,
d+1)
       end
       map
-    when 'record'
+    when 'record', 'error'
       m = {}
       schm.fields.each do |field|
         m[field.name] = nextdata(field.type, d+1)

Modified: avro/trunk/lang/ruby/test/test_io.rb
URL: http://svn.apache.org/viewvc/avro/trunk/lang/ruby/test/test_io.rb?rev=1447958&r1=1447957&r2=1447958&view=diff
==============================================================================
--- avro/trunk/lang/ruby/test/test_io.rb (original)
+++ avro/trunk/lang/ruby/test/test_io.rb Tue Feb 19 23:14:49 2013
@@ -73,6 +73,16 @@ EOS
     check_default(record_schema, '{"f": 11}', {"f" => 11})
   end
 
+  def test_error
+    error_schema = <<EOS
+      {"type": "error",
+       "name": "TestError",
+       "fields": [{"name": "message",
+                   "type": "string"}]}
+EOS
+    check_default(error_schema, '{"message": "boom"}', {"message" => "boom"})
+  end
+
   def test_enum
     enum_schema = '{"type": "enum", "name": "Test","symbols": ["A", "B"]}'
     check_default(enum_schema, '"B"', "B")



Mime
View raw message