Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleaned some code in GenericJsonRecord #10527

Merged
merged 2 commits into from
May 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,29 +102,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();
eolivelli marked this conversation as resolved.
Show resolved Hide resolved
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