simonbence commented on code in PR #7588:
URL: https://github.com/apache/nifi/pull/7588#discussion_r1298378646


##########
nifi-nar-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/flow/resource/hadoop/HDFSExternalResourceProvider.java:
##########
@@ -140,13 +146,16 @@ public InputStream fetchExternalResource(final 
ExternalResourceDescriptor descri
         final HdfsResources hdfsResources = getHdfsResources();
 
         try {
-            return 
hdfsResources.getUserGroupInformation().doAs((PrivilegedExceptionAction<FSDataInputStream>)
 () -> {
-                if (!hdfsResources.getFileSystem().exists(path)) {
-                    throw new IOException("Cannot find file in HDFS at 
location " + location);
-                }
-
-                return hdfsResources.getFileSystem().open(path, 
BUFFER_SIZE_DEFAULT);
-            });
+            final FSDataInputStream fsDataInputStream =
+                    
hdfsResources.getUserGroupInformation().doAs((PrivilegedExceptionAction<FSDataInputStream>)
 () -> {
+                        if (!hdfsResources.getFileSystem().exists(path)) {
+                            throw new IOException("Cannot find file in HDFS at 
location " + location);
+                        }
+
+                        return hdfsResources.getFileSystem().open(path, 
BUFFER_SIZE_DEFAULT);
+                    });
+            // The acquired InputStream is used by the client and cannot be 
closed here. The decorator is responsible for that.

Review Comment:
   I think one of the benefits for using a pattern is sharing the intention 
with one or two words more precisely. I tried to keep answering the "why"-s in 
the comment and do not focus on the "how" and I think it is a reasonable 
expectation to have an understanding of decorator if someone is willing to 
change this :)



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