I am working with Avro and in my avro schema I have one field like this:
{
"name" : "userId",
"type" : [ "null", "string" ],
"doc" : "some doc"
},
This is how I am extracting userId field from GenericRecord:
GenericRecord payload = decoder.decode(record.value());
String userid = String.valueOf(payload.get("userId"));
// sometimes userid comes as null string meaning like this "null"
System.out.println(Strings.isNullOrEmpty(userid));
And because of that "null" string, my sysout prints out as false. Is there
any way to extract userid as null instead of "null" String?
Bcoz when I check for null string it fails and if I have to accommodate
this fix, I have to add extra check with ".equals" which I want to avoid if
possible? Is there any way?