lkuchars commented on code in PR #10291:
URL: https://github.com/apache/nifi/pull/10291#discussion_r2373496640


##########
nifi-extension-bundles/nifi-protobuf-bundle/nifi-protobuf-services/src/main/java/org/apache/nifi/services/protobuf/StandardProtobufReader.java:
##########
@@ -170,6 +174,84 @@ protected PropertyDescriptor buildSchemaTextProperty() {
         return PROTOBUF_SCHEMA_TEXT;
     }
 
+    @Override
+    protected Collection<ValidationResult> customValidate(final 
ValidationContext validationContext) {
+        final List<ValidationResult> problems = new 
ArrayList<>(super.customValidate(validationContext));
+        final String schemaAccessStrategyValue = 
validationContext.getProperty(SCHEMA_ACCESS_STRATEGY).getValue();
+
+        // Only validate when using Schema Text property strategy
+        if (SCHEMA_TEXT_PROPERTY.getValue().equals(schemaAccessStrategyValue)) 
{
+            final PropertyValue schemaTextProperty = 
validationContext.getProperty(SCHEMA_TEXT);
+            final String schemaTextValue = schemaTextProperty.getValue();
+
+            if 
(validationContext.isExpressionLanguageSupported(SCHEMA_TEXT.getName())
+                && 
validationContext.isExpressionLanguagePresent(schemaTextValue)) {
+                return Collections.emptyList();

Review Comment:
   If we refactor to have a single return, we would need to use nested if-else 
statements or boolean flags, which would actually make the code less readable 
and more complex. The early returns here serve a legitimate purpose - they 
represent different validation scenarios where further validation is either 
unnecessary or impossible.



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