You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by to...@apache.org on 2015/07/08 16:27:44 UTC
svn commit: r1689884 - in /avro/trunk: CHANGES.txt
lang/ruby/lib/avro/schema.rb lang/ruby/test/test_schema.rb
Author: tomwhite
Date: Wed Jul 8 14:27:44 2015
New Revision: 1689884
URL: http://svn.apache.org/r1689884
Log:
AVRO-1645. Ruby: Improved handling of missing named types. Contributed by Daniel Schierbeck.
Modified:
avro/trunk/CHANGES.txt
avro/trunk/lang/ruby/lib/avro/schema.rb
avro/trunk/lang/ruby/test/test_schema.rb
Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1689884&r1=1689883&r2=1689884&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Wed Jul 8 14:27:44 2015
@@ -87,6 +87,9 @@ Trunk (not yet released)
AVRO-1681. Improve generated JavaDocs.
(Charles Gariépy-Ikeson via tomwhite)
+ AVRO-1645. Ruby: Improved handling of missing named types.
+ (Daniel Schierbeck via tomwhite)
+
BUG FIXES
AVRO-1553. Java: MapReduce never uses MapOutputValueSchema (tomwhite)
Modified: avro/trunk/lang/ruby/lib/avro/schema.rb
URL: http://svn.apache.org/viewvc/avro/trunk/lang/ruby/lib/avro/schema.rb?rev=1689884&r1=1689883&r2=1689884&view=diff
==============================================================================
--- avro/trunk/lang/ruby/lib/avro/schema.rb (original)
+++ avro/trunk/lang/ruby/lib/avro/schema.rb Wed Jul 8 14:27:44 2015
@@ -86,8 +86,7 @@ module Avro
elsif PRIMITIVE_TYPES.include? json_obj
return PrimitiveSchema.new(json_obj)
else
- msg = "#{json_obj.inspect} is not a schema we know about."
- raise SchemaParseError.new(msg)
+ raise UnknownSchemaError.new(json_obj)
end
end
@@ -370,6 +369,15 @@ module Avro
class SchemaParseError < AvroError; end
+ class UnknownSchemaError < SchemaParseError
+ attr_reader :type_name
+
+ def initialize(type)
+ @type_name = type
+ super("#{type.inspect} is not a schema we know about.")
+ end
+ end
+
module Name
def self.extract_namespace(name, namespace)
parts = name.split('.')
Modified: avro/trunk/lang/ruby/test/test_schema.rb
URL: http://svn.apache.org/viewvc/avro/trunk/lang/ruby/test/test_schema.rb?rev=1689884&r1=1689883&r2=1689884&view=diff
==============================================================================
--- avro/trunk/lang/ruby/test/test_schema.rb (original)
+++ avro/trunk/lang/ruby/test/test_schema.rb Wed Jul 8 14:27:44 2015
@@ -131,4 +131,16 @@ class TestSchema < Test::Unit::TestCase
]
}
end
+
+ def test_unknown_named_type
+ error = assert_raise Avro::UnknownSchemaError do
+ Avro::Schema.parse <<-SCHEMA
+ {"type": "record", "name": "my.name.space.Record", "fields": [
+ {"name": "reference", "type": "MissingType"}
+ ]}
+ SCHEMA
+ end
+
+ assert_equal '"MissingType" is not a schema we know about.', error.message
+ end
end