mark-bathori commented on code in PR #8922:
URL: https://github.com/apache/nifi/pull/8922#discussion_r1644279336


##########
nifi-extension-bundles/nifi-protobuf-bundle/nifi-protobuf-services/src/main/java/org/apache/nifi/services/protobuf/converter/ProtobufDataConverter.java:
##########
@@ -368,4 +410,30 @@ private RecordSchema generateRecordSchema(String typeName) 
{
     private String getQualifiedTypeName(String typeName) {
         return typeName.substring(typeName.lastIndexOf('/') + 1);
     }
+
+    private <T> List<T> processRepeatedValues(CodedInputStream input, 
ValueReader<CodedInputStream, T> valueReader) {
+        List<T> result = new ArrayList<>();
+        try {
+            while (input.getBytesUntilLimit() > 0) {
+                result.add(valueReader.apply(input));
+            }
+        } catch (Exception e) {
+            throw new IllegalStateException("Unable to parse repeated field");
+        }
+        return result;
+    }
+
+    private boolean isLengthDelimitedType(ProtoField protoField) {
+        final ProtoType protoType = protoField.getProtoType();
+        if (schema.getType(protoType) instanceof MessageType) {
+            return true;
+        }
+
+        if (protoType.isScalar()) {
+            FieldType fieldType = 
FieldType.findValue(protoType.getSimpleName());
+            return fieldType.equals(STRING) || fieldType.equals(BYTES);
+        } else {
+            return false;
+        }

Review Comment:
   I've refactored the method, let me know what do you think about it.



-- 
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: issues-unsubscr...@nifi.apache.org

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

Reply via email to