Skip to content

Commit

Permalink
Use empty string when path not found to avoid NPE in preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
PyvesB committed Jul 15, 2024
1 parent edd00e1 commit eabe3ae
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019-2022 Pierre-Yves B. and others.
* Copyright (c) 2019-2024 Pierre-Yves B. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -26,13 +26,13 @@ public class CommandHelper {

public static String findDirectory(String executable) {
String executablePath = findPath(executable);
if (executablePath != null) {
if (!executablePath.isEmpty()) {
File executableDirectory = new File(executablePath).getParentFile();
if (executableDirectory != null && executableDirectory.isDirectory()) {
return executableDirectory.getAbsolutePath();
}
}
return null;
return "";
}

public static String findPath(String executable) {
Expand All @@ -48,7 +48,7 @@ public static String findPath(String executable) {
} catch (IOException e) {
LogHelper.error("Failed to find location of " + executable, e);
}
return null;
return "";
}

public static String[] getAbsolutePlatformCommand(String command) {
Expand Down

0 comments on commit eabe3ae

Please sign in to comment.