cleaned some code in GenericJsonRecord
@@ -102,29 +102,29 @@ public class GenericJsonRecord extends VersionedGenericRecord {
}
private boolean isBinaryValue(String fieldName) {
- boolean isBinary = false;
-
- do {
if (schemaInfo == null) {
- break;
+ return false;
}
+ boolean isBinary = false;
try {
org.apache.avro.Schema schema = parseAvroSchema(schemaInfo.getSchemaDefinition());
org.apache.avro.Schema.Field field = schema.getField(fieldName);
+ if (field == null) {
+ return false;
+ }
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readTree(field.schema().toString());
for (JsonNode node : jsonNode) {
JsonNode jn = node.get("type");
if (jn != null && ("bytes".equals(jn.asText()) || "byte".equals(jn.asText()))) {
isBinary = true;
+ break;
}
}
} catch (Exception e) {
log.error("parse schemaInfo failed. ", e);
}
- } while (false);
-
return isBinary;
}
