exceptionfactory commented on code in PR #8922:
URL: https://github.com/apache/nifi/pull/8922#discussion_r1643292966


##########
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");

Review Comment:
   The root cause should be passed for troubleshooting.
   ```suggestion
               throw new IllegalStateException("Unable to parse repeated 
field", e);
   ```



##########
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:
   Recommend refactoring this method slightly to have a single `return` 
statement. The return value could be set in the appropriate conditional, making 
it `final` in the initial declaration.



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