You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by pe...@apache.org on 2021/06/26 13:11:41 UTC
[pulsar] 03/05: cleaned some code in GenericJsonRecord (#10527)
This is an automated email from the ASF dual-hosted git repository.
penghui pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit af16ee51aa9599a0b6ade0618c670339fd8cc817
Author: Abhilash Mandaliya <ab...@gmail.com>
AuthorDate: Wed May 12 16:50:18 2021 +0530
cleaned some code in GenericJsonRecord (#10527)
(cherry picked from commit 24b0d064e377dedda2049f6177028f4c26a870bf)
---
.../impl/schema/generic/GenericJsonRecord.java | 38 +++++++++++-----------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericJsonRecord.java b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericJsonRecord.java
index 85d3e8e..da4515a 100644
--- a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericJsonRecord.java
+++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericJsonRecord.java
@@ -98,29 +98,29 @@ public class GenericJsonRecord extends VersionedGenericRecord {
}
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;
}