You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Ryan Blue (JIRA)" <ji...@apache.org> on 2016/09/21 17:08:20 UTC
[jira] [Resolved] (AVRO-1915) AvroTypeException decoding from
earlier schema version
[ https://issues.apache.org/jira/browse/AVRO-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ryan Blue resolved AVRO-1915.
-----------------------------
Resolution: Not A Problem
Thanks for letting us know you got past this. I'm going to resolve this issue.
> AvroTypeException decoding from earlier schema version
> ------------------------------------------------------
>
> Key: AVRO-1915
> URL: https://issues.apache.org/jira/browse/AVRO-1915
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.7.7
> Reporter: NPE
>
> We have two services which communicate with one another by sending JSON-encoded Avro-based messages over Kafka. We want to update the schema for messages sent from service A to service B by adding an additional string field with a default value of "" (empty string). We have tested by initially adding the updated schema to service B (the reader) and continuing to send messages in the older format from service A (the writer).
> Simplified example of old schema (some fields omitted):
> {code}
> {
> "type": "record",
> "name": "Envelope",
> "fields": [{
> "name": "appId",
> "type": "string"
> }, {
> "name": "time",
> "type": "long"
> }, {
> "name": "type",
> "type": "string"
> }, {
> "name": "payload",
> "type": [{
> "type": "record",
> "name": "MessagePayload",
> "fields": [{
> "name": "context",
> "type": {
> "type": "record",
> "name": "PayloadContext",
> "fields": [{
> "name": "source",
> "type": "string"
> }, {
> "name": "requestId",
> "type": "string"
> }]
> }
> }, {
> "name": "content",
> "type": "string"
> }, {
> "name": "contentType",
> "type": "string"
> }]
> }]
> }]
> }
> {code}
> Simplified example of new schema (some fields omitted):
> {code}
> {
> "type": "record",
> "name": "Envelope",
> "fields": [{
> "name": "appId",
> "type": "string"
> }, {
> "name": "time",
> "type": "long"
> }, {
> "name": "type",
> "type": "string"
> }, {
> "name": "payload",
> "type": [{
> "type": "record",
> "name": "MessagePayload",
> "fields": [{
> "name": "context",
> "type": {
> "type": "record",
> "name": "PayloadContext",
> "fields": [{
> "name": "source",
> "type": "string"
> }, {
> "name": "requestId",
> "type": "string"
> }, {
> "name": "newField",
> "type": "string",
> "default": ""
> }]
> }
> }, {
> "name": "content",
> "type": "string"
> }, {
> "name": "contentType",
> "type": "string"
> }]
> }]
> }]
> }
> {code}
> Our understanding was that the reader, with the newer schema, should be able to parse messages sent with the older given the default value for the missing field; however, we are getting the following exception:
> {code}
> org.apache.avro.AvroTypeException: Expected string. Got END_OBJECT
> {code}
> Are we missing something here?
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)