I'm trying to test the case where a server returns a newer version of a response to make sure an older client can read it. I think I can accomplish that by removing the version out of the namespace altogether in my test case. Francois.
-----Original Message----- From: Doug Cutting [mailto:[email protected]] Sent: Wednesday, December 07, 2011 4:48 PM To: [email protected] Subject: Re: AvroTypeException thrown with version change on optional record I think you have the parameters reversed to SpecificDatumWriter and SpecificDatumReader. If v2 is the new version, then you should construct a SpecificDatumWriter<v1.Response> to write the old version and a SpecificDatumReader<v2.Response> to read the new one. The parameters to SpecificDatumReader's constructor are old-then-new, so you'll need to reverse those too. Doug On 12/07/2011 02:40 PM, Francois Forster wrote: > It seems to work when I do the reverse (add @aliases(["v2.Result"]) to the v1 > schema), but that's not useful when dealing with versioning. > > Francois. > > -----Original Message----- > From: Francois Forster [mailto:[email protected]] > Sent: Wednesday, December 07, 2011 4:34 PM > To: [email protected] > Subject: RE: AvroTypeException thrown with version change on optional record > > Interesting. I tried it but get: > > Exception in thread "main" org.apache.avro.AvroTypeException: Found { > "type" : "record", > "name" : "Review", > "namespace" : "v2", > "fields" : [ { > "name" : "id", > "type" : "string" > }, { > "name" : "text", > "type" : "string" > }, { > "name" : "isRecommended", > "type" : "boolean" > } ], > "aliases" : [ "v1.Review" ] > }, expecting [ "null", { > "type" : "record", > "name" : "Review", > "namespace" : "v1", > "fields" : [ { > "name" : "id", > "type" : "string" > }, { > "name" : "text", > "type" : "string" > }, { > "name" : "isRecommended", > "type" : "boolean" > } ] > } ] > > > -----Original Message----- > From: Doug Cutting [mailto:[email protected]] > Sent: Wednesday, December 07, 2011 4:15 PM > To: [email protected] > Subject: Re: AvroTypeException thrown with version change on optional record > > On 12/07/2011 01:41 PM, Francois Forster wrote: >> Actually, it happens even if I don't add isFeatured. Is there something >> incompatible due to the different namespace? > > Changing the namespace is probably why this is failing. > > If you need to change the namespace then you can use aliases: > > @namespace("v2") > protocol Service { > @aliases(["v1.Result"]) > record Result { ... } > ... > } > > This will make v2 be able to read v1. > > Doug
