sijie commented on a change in pull request #4177: [pulsar-clients]Support 
nested struct for GenericRecord
URL: https://github.com/apache/pulsar/pull/4177#discussion_r279652039
 
 

 ##########
 File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/AvroRecordBuilderImpl.java
 ##########
 @@ -45,7 +47,12 @@
      */
     @Override
     public GenericRecordBuilder set(String fieldName, Object value) {
-        avroRecordBuilder.set(fieldName, value);
+        if (value instanceof GenericRecord) {
 
 Review comment:
   I think the logic here is a bit wrong. I think you can just retrieve the 
avro record.
   
   ```
   if (value of instanceof GenericRecord) {
       if (value of instanceof GenericAvroRecord) {
           avroRecordBuilder.set(fieldName, 
((GenericAvroRecord)value).getAvroRecord());
       } else {
           throw new IllegalArgumentException("Avro Record Builder doesn't 
support non-avro record as a field");
       }
   } else {
       avroRecordBuilder.set(fieldName, value);
   }
   ```

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to