From 5c9f50f64b7e5ab4fb52697829568fff22c294d3 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Fri, 1 Aug 2014 10:12:13 +0200 Subject: [PATCH] SONAR-4898 fix IP interface of JMX ports --- .../main/java/org/sonar/process/ProcessWrapper.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java b/server/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java index 12aef533d93..54c242e8e57 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java +++ b/server/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java @@ -219,7 +219,7 @@ public class ProcessWrapper extends Thread implements Terminable { "-Dcom.sun.management.jmxremote.port=" + jmxPort, "-Dcom.sun.management.jmxremote.authenticate=false", "-Dcom.sun.management.jmxremote.ssl=false", - "-Djava.rmi.server.hostname=" + InetAddress.getLocalHost().getHostAddress()); + "-Djava.rmi.server.hostname=" + localhost()); } private List buildClasspath() { @@ -246,8 +246,8 @@ public class ProcessWrapper extends Thread implements Terminable { */ @CheckForNull private ProcessMXBean waitForJMX() throws UnknownHostException, MalformedURLException { - String path = "/jndi/rmi://" + InetAddress.getLocalHost().getHostAddress() + ":" + jmxPort + "/jmxrmi"; - JMXServiceURL jmxUrl = new JMXServiceURL("rmi", InetAddress.getLocalHost().getHostAddress(), jmxPort, path); + String path = "/jndi/rmi://" + localhost() + ":" + jmxPort + "/jmxrmi"; + JMXServiceURL jmxUrl = new JMXServiceURL("rmi", localhost(), jmxPort, path); for (int i = 0; i < 5; i++) { try { @@ -265,6 +265,10 @@ public class ProcessWrapper extends Thread implements Terminable { return null; } + private String localhost() { + return InetAddress.getLoopbackAddress().getHostAddress(); + } + @Override public void terminate() { if (processMXBean != null && process != null) { -- 2.39.5