offthewall123 commented on a change in pull request #30831:
URL: https://github.com/apache/spark/pull/30831#discussion_r546375103
##########
File path:
launcher/src/main/java/org/apache/spark/launcher/AbstractCommandBuilder.java
##########
@@ -92,18 +92,11 @@
List<String> buildJavaCommand(String extraClassPath) throws IOException {
List<String> cmd = new ArrayList<>();
- String[] candidateJavaHomes = new String[] {
- javaHome,
+ String firstJavaHome = firstNonEmpty(javaHome,
childEnv.get("JAVA_HOME"),
System.getenv("JAVA_HOME"),
- System.getProperty("java.home")
- };
- for (String javaHome : candidateJavaHomes) {
- if (javaHome != null) {
- cmd.add(join(File.separator, javaHome, "bin", "java"));
- break;
- }
- }
+ System.getProperty("java.home"));
+ cmd.add(join(File.separator, firstJavaHome, "bin", "java"));
Review comment:
Yes, i have considered of `firstJavaHome == null`, but origin code logic
not deal this situation here, it will throw exception at higher caller, so not
add `if (fisrstJavaHome == null)` to keep the origin code logic.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]