Changeset 19143 in josm for trunk


Ignore:
Timestamp:
2024-07-15T23:29:48+02:00 (4 months ago)
Author:
taylor.smock
Message:

Fix #23804: xdg-open can return a 0 exit code when a browser doesn'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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java

    r19103 r19143  
    6969    @Override
    7070    public void openUrl(String url) throws IOException {
     71        // Note: xdg-open may not always give "expected" results, see #23804.
     72        // At the time, it appeared to be primarily a Brave browser problem.
    7173        for (String program : Config.getPref().getList("browser.unix",
    72                 Arrays.asList("xdg-open", "#DESKTOP#", "$BROWSER", "gnome-open", "kfmclient openURL", "firefox"))) {
     74                Arrays.asList("#DESKTOP#", "xdg-open", "$BROWSER", "gnome-open", "kfmclient openURL", "firefox"))) {
    7375            try {
    7476                if ("#DESKTOP#".equals(program)) {
    7577                    Desktop.getDesktop().browse(Utils.urlToURI(url));
    76                 } else if (program.startsWith("$")) {
    77                     program = System.getenv().get(program.substring(1));
    78                     Runtime.getRuntime().exec(new String[]{program, url});
    7978                } else {
     79                    if (program.startsWith("$")) {
     80                        program = System.getenv().get(program.substring(1));
     81                    }
    8082                    Runtime.getRuntime().exec(new String[]{program, url});
    8183                }
Note: See TracChangeset for help on using the changeset viewer.