simonbence commented on a change in pull request #5437:
URL: https://github.com/apache/nifi/pull/5437#discussion_r725847502



##########
File path: 
nifi-nar-bundles/nifi-extension-utils/nifi-hadoop-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractHadoopProcessor.java
##########
@@ -674,39 +681,33 @@ protected Path getNormalizedPath(ProcessContext context, 
PropertyDescriptor prop
     }
 
     protected Path getNormalizedPath(final String rawPath) {
-        final Path path = new Path(rawPath);
-        final URI uri = path.toUri();
-
-        final URI fileSystemUri = getFileSystem().getUri();
-
-        if (uri.getScheme() != null) {
-            if (!uri.getScheme().equals(fileSystemUri.getScheme()) || 
!uri.getAuthority().equals(fileSystemUri.getAuthority())) {
-                getLogger().warn("The filesystem component of the URI 
configured ({}) does not match the filesystem URI from the Hadoop configuration 
file ({}) " +
-                        "and will be ignored.", uri, fileSystemUri);
-            }
-
-            return new Path(uri.getPath());
-        } else {
-            return path;
-        }
+       return getNormalizedPath(rawPath, Optional.empty());
     }
 
     protected Path getNormalizedPath(final ProcessContext context, final 
PropertyDescriptor property, final FlowFile flowFile) {
         final String propertyValue = 
context.getProperty(property).evaluateAttributeExpressions(flowFile).getValue();
-        final Path path = new Path(propertyValue);
-        final URI uri = path.toUri();
+        return getNormalizedPath(propertyValue, 
Optional.of(property.getDisplayName()));
+    }
 
+    private Path getNormalizedPath(final String rawPath, final 
Optional<String> propertyName) {

Review comment:
       I understand your point, but in general designing for null as an input I 
find unlucky on multiple levels. Within the project, methods usually assume 
that the input is not null, expect for the boundies of the system. Introducing 
this would set a dangerous example and might continue to roll. (Note: I do not 
state that you cannot find a concept like this in the codebase, but in general 
it should be something to avoid) Optional shows intent and forces the client to 
make a conscious decision. As of leaving the methods duplicated as of this 
point would come with too much duplication, this left us with `Optional` as an 
optimal looking solution. Please also not this is someting will not appear in 
the "API" of the class, thus it will not propogate.




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