You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2019/02/01 16:41:25 UTC

[GitHub] mattyb149 commented on a change in pull request #3282: NIFI-5983: handling parse problems in recordReader implementations

mattyb149 commented on a change in pull request #3282: NIFI-5983: handling parse problems in recordReader implementations
URL: https://github.com/apache/nifi/pull/3282#discussion_r253117606
 
 

 ##########
 File path: nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/avro/AvroRecordReader.java
 ##########
 @@ -33,14 +35,18 @@
 
     @Override
     public Record nextRecord(final boolean coerceTypes, final boolean dropUnknownFields) throws IOException, MalformedRecordException {
-        GenericRecord record = nextAvroRecord();
-        if (record == null) {
-            return null;
+        try {
+            GenericRecord record = nextAvroRecord();
+            if (record == null) {
+                return null;
+            }
+
+            final RecordSchema schema = getSchema();
+            final Map<String, Object> values = AvroTypeUtil.convertAvroRecordToMap(record, schema);
+            return new MapRecord(schema, values);
+        } catch (RuntimeException e) {
 
 Review comment:
   Fair enough, but you can apply the `catch(Throwable)` to all the readers, just don't need a catch/rethrow for checked exceptions that aren't thrown. Seems a bit more future-proof than catching the RuntimeException we just found out about, in the future who knows what libraries will throw? :)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services