You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Jaroslav Tulach (Jira)" <ji...@apache.org> on 2019/09/17 12:44:00 UTC
[jira] [Commented] (NETBEANS-3101) Can't launch (and connect)
NetBeans from node
[ https://issues.apache.org/jira/browse/NETBEANS-3101?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16931396#comment-16931396 ]
Jaroslav Tulach commented on NETBEANS-3101:
-------------------------------------------
For the record, my original plan to fix this was to prefer IPv4 address in {{CLIHandler}}:
{code:java}
netbeans$ git show
commit 02434b973c88d06b1cf30d821a6f8a9d5d5d7877 (HEAD -> jtulach/PreferIPv4, alm/jtulach/PreferIPv4)
Author: Jaroslav Tulach <ja...@oracle.com>
Date: Mon Sep 16 12:46:57 2019 +0200 Prefer IPv4 address for localhostdiff --git a/platform/o.n.bootstrap/src/org/netbeans/CLIHandler.java b/platform/o.n.bootstrap/src/org/netbeans/CLIHandler.java
index 12abdec2e591..7c2ffd1df4b1 100644
--- a/platform/o.n.bootstrap/src/org/netbeans/CLIHandler.java
+++ b/platform/o.n.bootstrap/src/org/netbeans/CLIHandler.java
@@ -31,6 +31,7 @@ import java.io.InterruptedIOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.RandomAccessFile;
+import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
@@ -44,6 +45,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.Enumeration;
import java.util.List;
import java.util.Random;
import java.util.logging.Level;
@@ -459,16 +461,29 @@ public abstract class CLIHandler extends Object {
/** Enhanced search for localhost address that works also behind VPN
*/
- private static InetAddress localHostAddress () throws IOException {
+ private static InetAddress localHostAddress() throws IOException {
+ return localHostAddresses().get(0);
+ }
+
+ private static List<InetAddress> localHostAddresses() throws IOException {
java.net.NetworkInterface net = java.net.NetworkInterface.getByName ("lo");
if (net == null || !net.getInetAddresses().hasMoreElements()) {
net = java.net.NetworkInterface.getByInetAddress(InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }));
}
if (net == null || !net.getInetAddresses().hasMoreElements()) {
- return InetAddress.getLocalHost();
- }
- else {
- return net.getInetAddresses().nextElement();
+ return Collections.singletonList(InetAddress.getLocalHost());
+ } else {
+ List<InetAddress> arr = new ArrayList<>();
+ Enumeration<InetAddress> en = net.getInetAddresses();
+ while (en.hasMoreElements()) {
+ InetAddress addr = en.nextElement();
+ if (addr instanceof Inet4Address) {
+ arr.add(0, addr);
+ } else {
+ arr.add(addr);
+ }
+ }
+ return arr;
}
}
{code}
> Can't launch (and connect) NetBeans from node
> ---------------------------------------------
>
> Key: NETBEANS-3101
> URL: https://issues.apache.org/jira/browse/NETBEANS-3101
> Project: NetBeans
> Issue Type: Bug
> Components: platform - Launchers&CLI
> Reporter: Jaroslav Tulach
> Priority: Minor
>
>
> I am trying to connect to a *NetBeans* based application from _Visual Studio_ - aka _Electron_ - aka *node*. Somehow the *node* mangles network setup and the InetAddress.getHostAddress() isn't the same. To reproduce create following structure of files:
> {code:java}
> $ ls -l | cut -c50-
> dump.hprof
> nb.js
> nb.sh
> netbeans -> /home/devel/bin/netbeans/bin/netbeans
> $ cat nb.sh
> ./netbeans 'dump.hprof'
> $ cat nb.js
> var exec = require("child_process").execFile;
> let path = './netbeans';let vvm = exec(path, [ 'dump.hprof' ]){code}
> Then start *./netbeans* on background and wait for the GUI to launch. Then do following from command line:
> {code:java}
> ./jvm.sh
> {code}
> The dump.hprof file opens in the the GUI. Close it and try the same via *node.js*:
> {code:java}
> node ./jvm.js
> {code}
> The heap dump isn't shown (on my computer), rather a warning dialog appears. Result of node and shell script disagreeing on what is local host address. One is using IPv6 and one IPv4.
>
--
This message was sent by Atlassian Jira
(v8.3.2#803003)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists