Skip to content

Commit

Permalink
Fix #23804: xdg-open can return a 0 exit code when a browser doesn'…
Browse files Browse the repository at this point in the history
…t open

This is alleviated by switching the default order of `browser.unix` to be
`#DESTKOP` then `xdg-open`. `#DESKTOP` is our magic value for using built-in
Java methods for opening a browser.

It ''appears'' that there is a race condition somewhere for the Brave browser.
I ''suspect'' that the process returned by the Runtime.exec and xdg-open isn't
actually complete when it says it is, and so the process is cleaned up prior to
Brave actually launching.

git-svn-id: https://josm.openstreetmap.de/svn/trunk@19143 0c6e7542-c601-0410-84e7-c038aed88b3b
  • Loading branch information
taylor.smock committed Jul 15, 2024
1 parent 4b82821 commit 25eecc0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,17 @@ public void startupHook(JavaExpirationCallback javaCallback, SanityCheckCallback

@Override
public void openUrl(String url) throws IOException {
// Note: xdg-open may not always give "expected" results, see #23804.
// At the time, it appeared to be primarily a Brave browser problem.
for (String program : Config.getPref().getList("browser.unix",
Arrays.asList("xdg-open", "#DESKTOP#", "$BROWSER", "gnome-open", "kfmclient openURL", "firefox"))) {
Arrays.asList("#DESKTOP#", "xdg-open", "$BROWSER", "gnome-open", "kfmclient openURL", "firefox"))) {
try {
if ("#DESKTOP#".equals(program)) {
Desktop.getDesktop().browse(Utils.urlToURI(url));
} else if (program.startsWith("$")) {
program = System.getenv().get(program.substring(1));
Runtime.getRuntime().exec(new String[]{program, url});
} else {
if (program.startsWith("$")) {
program = System.getenv().get(program.substring(1));
}
Runtime.getRuntime().exec(new String[]{program, url});
}
return;
Expand Down

0 comments on commit 25eecc0

Please sign in to comment.