Github user rmetzger commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1920#discussion_r61437731
  
    --- Diff: 
flink-batch-connectors/flink-avro/src/main/java/org/apache/flink/api/java/io/AvroInputFormat.java
 ---
    @@ -119,12 +138,14 @@ public E nextRecord(E reuseValue) throws IOException {
                if (reachedEnd()) {
                        return null;
                }
    -           
    -           if (!reuseAvroValue) {
    -                   reuseValue = 
InstantiationUtil.instantiate(avroValueType, Object.class);
    +           if (org.apache.avro.generic.GenericRecord.class == 
avroValueType) {
    +                   return reuseAvroValue ? dataFileReader.next(reuseValue) 
: dataFileReader.next();
    +           } else {
    +                   if (!reuseAvroValue) {
    +                           reuseValue = 
InstantiationUtil.instantiate(avroValueType, Object.class);
    +                   }
    +                   reuseValue = dataFileReader.next(reuseValue);
    --- End diff --
    
    The use of the ternary operator seems to be very inconsistent here.
    Either use it for the return value and the assignment or not at all.
    
    I personally prefer to avoid it whenever possible.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to