FSchumacher commented on PR #6680:
URL: https://github.com/apache/jmeter/pull/6680#issuecomment-4126264830

   For the ubuntu wsl case, where I have no browser installed in the distro, 
the following code snippet worked (after installing wslu package):
   
   ```diff
   diff --git 
a/src/core/src/main/java/org/apache/jmeter/gui/action/OpenLinkAction.java 
b/src/core/src/main/java/org/apache/jmeter/gui/action/OpenLinkAction.java
   index be6ea6c430..0613ef91da 100644
   --- a/src/core/src/main/java/org/apache/jmeter/gui/action/OpenLinkAction.java
   +++ b/src/core/src/main/java/org/apache/jmeter/gui/action/OpenLinkAction.java
   @@ -17,6 +17,7 @@
   
    package org.apache.jmeter.gui.action;
   
   +import java.awt.Desktop.Action;
    import java.awt.event.ActionEvent;
    import java.io.IOException;
    import java.util.HashMap;
   @@ -58,6 +59,7 @@ public class OpenLinkAction extends AbstractAction {
            map.put(ActionNames.LINK_RELEASE_NOTES, 
"https://jmeter.apache.org/changes.html";);
            return map;
        }
   +
        /**
         * @see org.apache.jmeter.gui.action.Command#doAction(ActionEvent)
         */
   @@ -72,14 +74,23 @@ public class OpenLinkAction extends AbstractAction {
                if(e.getSource() instanceof String[]) {
                    url += "#"+((String[])e.getSource())[1];
                }
   -            java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
   +            if (java.awt.Desktop.getDesktop().isSupported(Action.BROWSE)) {
   +                
java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
   +            } else {
   +                try {
   +                    Runtime.getRuntime().exec(new String[] { "wslview", url 
});
   +                } catch (IOException rtErr) {
   +                    log.error("Oops", rtErr);
   +                }
   +            }
            } catch (IOException err) {
                log.error(
                        "OpenLinkAction: User default browser is not found, or 
it fails to be launched,"
                        + " or the default handler application failed to be 
launched on {}",
                        url, err);
            } catch (UnsupportedOperationException err) {
   -            log.error("OpenLinkAction: Current platform does not support 
the Desktop.Action.BROWSE action on {}", url, err);
   +            log.error("OpenLinkAction: Current platform does not support 
the Desktop.Action.BROWSE action on {}", url,
   +                    err);
                showBrowserWarning(url);
            } catch (SecurityException err) {
                log.error("OpenLinkAction: Security problem on {}", url, err);
    ``` 
    
    It would perhaps be nicer to move the runtime exec stuff into its own 
function and call it inside the catch UnsupportedOperationException as a 
fallback option, if a system property is set (value would be something like 
wslview).
    
    AND this can be handled in a different issue/PR, as it is not new behavior.


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to