EndzeitBegins commented on code in PR #9151:
URL: https://github.com/apache/nifi/pull/9151#discussion_r1707508872


##########
nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/bigquery/proto/ProtoUtils.java:
##########
@@ -46,8 +48,22 @@ public static DynamicMessage 
createMessage(Descriptors.Descriptor descriptor, Ma
            switch (field.getType()) {
            case MESSAGE:
                if (field.isRepeated()) {
-                   Collection collection = value.getClass().isArray() ? 
Arrays.asList((Object[]) value) : (Collection) value;
-                   collection.forEach(act -> builder.addRepeatedField(field, 
createMessage(field.getMessageType(), (Map<String, Object>) act, tableSchema)));
+                   final Collection<Map<String, Object>> valueMaps;
+                   if (value instanceof Object[] arrayValue) {
+                       valueMaps = Arrays.stream(arrayValue)
+                               .map(item -> (Map<String, Object>) 
item).toList();
+                   } else if (value instanceof HashMap<?, ?> hashMapValue) {

Review Comment:
   Good catch @dan-s1 . 
   I also wanted to address that but didn't find the time to answer until now. 
   
   I don't think we should assume that. Also there's no benefit of doing so, as 
we only ever use methods of `Map<?, ?>` anyways. 
   
   ```suggestion
                      } else if (value instanceof Map<?, ?> mapValue) {
   ```
   
   



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to