[
https://issues.apache.org/jira/browse/AVRO-3520?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17539022#comment-17539022
]
Colin edited comment on AVRO-3520 at 5/18/22 7:20 PM:
------------------------------------------------------
Hi [~clesaec]
The issue encountered was in a setup similar to the following, where existing
custom encoded binaries are out in the wild and a schema change was made in the
latest release, adding new information. The new version of the service needs to
maintain backwards compatibility, and be able to detect if a schema on disk
being read doesn't match the current in-memory schema.
{code:java}
class Wrapper {
@AvroEncode(using = MyCustomEncoder.class)
private MyCustom myCustom;
}
{code}
and
{code:java}
class MyCustomEncoder extends CustomEncoding<MyCustom> {
{
// consider an existing schema in version 1.0 of the service, and then
version 1.1 added a new field to this schema.
schema = Schema.createRecord(...)
}
@Override
protected void write(Object object, Encoder out) {}
@Override
protected MyCustom read(Object object, Decoder in) {
// currently no way to detect if the object being read here matches the
current schema, which is required for maintaining backwards compatibility.
}
}
{code}
I hope this helps illustrate the issue.
was (Author: JIRAUSER289565):
Hi [~clesaec]
The issue encountered was in a setup similar to the following, where existing
custom encoded binaries are out in the wild and a schema change was made in the
latest release, adding new information. The new version of the service needs to
maintain backwards compatibility, and be able to detect if a schema on disk
being read doesn't match the current in-memory schema.
{code:java}
class Wrapper {
@AvroEncode(using = MyCustomEncoder.class)
private MyCustom myCustom;
}
{code}
and
{code:java}
class MyCustomEncoder extends CustomEncoding<MyCustom> {
{
// consider an existing schema in version 1.0 of the service, and then
version 1.1 added a new field to this schema.
schema = Schema.createRecord(...)
}
@Override
protected void write(Object object, Encoder out) {}
@Override
protected MyCustom(Object object, Decoder in) {
// currently no way to detect if the object being read here matches the
current schema, which is required for maintaining backwards compatibility.
}
}
{code}
I hope this helps illustrate the issue.
> CustomEncoding doesn't expose the read schema
> ---------------------------------------------
>
> Key: AVRO-3520
> URL: https://issues.apache.org/jira/browse/AVRO-3520
> Project: Apache Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.11.0
> Reporter: Colin
> Priority: Major
>
> Currently it is not possible to detect a schema change when using
> `CustomEncoding<T>`.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)