You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/05/11 09:50:59 UTC

[GitHub] [pulsar] abhilashmandaliya commented on a change in pull request #10527: cleaned some code in GenericJsonRecord

abhilashmandaliya commented on a change in pull request #10527:
URL: https://github.com/apache/pulsar/pull/10527#discussion_r630020391



##########
File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericJsonRecord.java
##########
@@ -102,29 +102,26 @@ public Object getField(String fieldName) {
     }
 
     private boolean isBinaryValue(String fieldName) {
-        boolean isBinary = false;
-
-        do {
-            if (schemaInfo == null) {
-                break;
-            }
+        if (schemaInfo == 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;
-                    }
+        boolean isBinary = false;
+        try {
+            org.apache.avro.Schema schema = parseAvroSchema(schemaInfo.getSchemaDefinition());
+            org.apache.avro.Schema.Field field = schema.getField(fieldName);
+            ObjectMapper objectMapper = new ObjectMapper();

Review comment:
       done. I had observed this but didn't make change. I thought PR might get rejected. anyways. Thanks :-) 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org