Skip to content

Commit

Permalink
cleaned some code in GenericJsonRecord (apache#10527)
Browse files Browse the repository at this point in the history
(cherry picked from commit 24b0d06)
  • Loading branch information
abhilashmandaliya authored and eolivelli committed May 12, 2021
1 parent b1ee56c commit 56c2f6b
Showing 1 changed file with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,29 +98,29 @@ public Object getField(String fieldName) {
}

private boolean isBinaryValue(String fieldName) {
boolean isBinary = false;
if (schemaInfo == null) {
return false;
}

do {
if (schemaInfo == null) {
break;
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;
}

try {
org.apache.avro.Schema schema = parseAvroSchema(schemaInfo.getSchemaDefinition());
org.apache.avro.Schema.Field field = schema.getField(fieldName);
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;
}
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);

} catch (Exception e) {
log.error("parse schemaInfo failed. ", e);
}
return isBinary;
}

Expand Down

0 comments on commit 56c2f6b

Please sign in to comment.