Howdy:

The following test program is not working with the 1.8.2 version of apache-avro 
because of a null field.  Am I doing something wrong?  The error I get is:  
"Found null, expecting string" with the record with a null value for the bar 
field.

I've search the Jira bug list but I don't see anything relevant.

Thanks much,
gray

-----------------

public class Foo {

        private static final String AVRO = "{ \"name\": \"User\", \"type\": 
\"record\","
                        + "\"fields\": [ {\"name\": \"bar\", \"type\": 
[\"string\", \"null\"]} ]}";

        public static void main(String[] args) throws Exception {
                File file = new File("users.avro");
                DataFileWriter<User> writer = new DataFileWriter<User>(new 
ReflectDatumWriter<User>(User.class));
                writer.create(new Schema.Parser().parse(AVRO), file);
                writer.append(new User("bar1"));
                writer.append(new User(null));
                writer.close();

                DataFileReader<User> reader = new DataFileReader<User>(file, 
new ReflectDatumReader<>(User.class));
                reader.next(); // works
                reader.next(); // ENOWORK
                reader.close();
        }

        public static class User {
                private String bar;
                public User() {
                        // needed by avro reader
                }
                public User(String bar) {
                        this.bar = bar;
                }
        }
} 


----------
This message was sent from a MailNull anti-spam account.  You can get
your free account and take control over your email by visiting the
following URL.

   http://mailnull.com/

Reply via email to