HeartSaVioR commented on a change in pull request #30831:
URL: https://github.com/apache/spark/pull/30831#discussion_r545843794
##########
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:
Technically saying, this is not 100% same. We need to deal with the
condition `firstJavaHome == null`. I wouldn't say it's a normal case, but just
to be safe.
----------------------------------------------------------------
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]