bobpaulin commented on code in PR #8961:
URL: https://github.com/apache/nifi/pull/8961#discussion_r1641391058


##########
nifi-extension-bundles/nifi-py4j-bundle/nifi-py4j-bridge/src/main/java/org/apache/nifi/py4j/PythonProcess.java:
##########
@@ -302,8 +302,14 @@ String resolvePythonCommand() throws IOException {
         } else if (virtualEnvDirectories.length == 1) {
             commandExecutableDirectory = virtualEnvDirectories[0].getName();
         } else {
-            // Default to bin directory for macOS and Linux
-            commandExecutableDirectory = "bin";
+            // We should get at most 2 directories.  Check for python command.
+            if (virtualEnvDirectories[0].list((file, name) -> 
name.startsWith(pythonCmd)).length >= 1) {

Review Comment:
   Yes I agree it is safer if I make it null safe and cleaner with a new 
method.  The challenge was working with the virtualEnvDirectories array in a 
for loop and ensuring commandExecutableDirectory is only set exactly once.  If 
I break I don't guarantee it's set if I loop without breaking it may be set 
multiple.  So I've replaced this with a stream which is not the most efficient 
but  does make the code readable and keeps the final guarantee or throws an 
exception.



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