[ 
https://issues.apache.org/jira/browse/AVRO-1532?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Doug Cutting updated AVRO-1532:
-------------------------------

    Attachment: ReflectDataFieldRemovalTest.java

Here's a version of your test that passes.

I changed it so that it uses an alias to permit both versions of the reflected 
schema to exist at once, so that the binary output doesn't need to be stored in 
a constant.  That just makes the test simpler to maintain, and shouldn't affect 
what it tests.

The only substantial change I made was to specify the new schema when 
constructing the DatumReader.  Without that, the runtime had no way of knowing 
what the new schema was and was trying to set the field named 'victim' on a 
class that didn't contain that field.  Perhaps the API should force you to set 
this, e.g., not permitting a call to createDatumReader with a null schema.

> Field deletion not possible for ReflectData: NPE
> ------------------------------------------------
>
>                 Key: AVRO-1532
>                 URL: https://issues.apache.org/jira/browse/AVRO-1532
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.6
>            Reporter: O. Reißig
>              Labels: java, reflection
>         Attachments: AVRO-1532.patch, ReflectDataFieldRemovalTest.java, 
> ReflectDataFieldRemovalTest.java
>
>
> *Actual behaviour:*
> I have a field in my reflection-based schema like this:
> {code}
> @Nullable @AvroDefault("null")
> public Long someField;
> {code}
> When removing this field, parsing the previous serialized blob yields 
> NullPointerException:
> {noformat}
> java.lang.NullPointerException
>       at org.apache.avro.reflect.ReflectData.setField(ReflectData.java:128)
>       at 
> org.apache.avro.generic.GenericDatumReader.readField(GenericDatumReader.java:193)
>       at 
> org.apache.avro.reflect.ReflectDatumReader.readField(ReflectDatumReader.java:230)
>       at 
> org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:183)
>       at 
> org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:151)
>       at 
> org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:142)
>       at org.apache.avro.file.DataFileStream.next(DataFileStream.java:233)
>       at org.apache.avro.file.DataFileStream.next(DataFileStream.java:220)
>       at 
> ReflectDataFieldRemovalTest.testFieldRemoval(ReflectDataFieldRemovalTest.java:41)
> {noformat}
> *Expected behaviour:*
> Field removal is crucial for schema evolution and must be possible with 
> ReflectData.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to