You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2021/04/21 05:57:57 UTC

[groovy] branch danielsun/tweak-JmxServerConnectorFactoryTest-further updated (8766f42 -> 431e75a)

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a change to branch danielsun/tweak-JmxServerConnectorFactoryTest-further
in repository https://gitbox.apache.org/repos/asf/groovy.git.


 discard 8766f42  Modify hosts.allow and restart network
     new 431e75a  Set `java.rmi.server.hostname`

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (8766f42)
            \
             N -- N -- N   refs/heads/danielsun/tweak-JmxServerConnectorFactoryTest-further (431e75a)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .github/workflows/build-test.yml                   |  4 ----
 .../builder/JmxClientConnectorFactoryTest.groovy   | 26 ++++++++++++++++++++++
 2 files changed, 26 insertions(+), 4 deletions(-)

[groovy] 01/01: Set `java.rmi.server.hostname`

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch danielsun/tweak-JmxServerConnectorFactoryTest-further
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 431e75ad8d7dcc1c0b62871f1a4b5ee07349ff38
Author: Daniel Sun <su...@apache.org>
AuthorDate: Wed Apr 21 13:57:40 2021 +0800

    Set `java.rmi.server.hostname`
---
 .../builder/JmxClientConnectorFactoryTest.groovy   | 26 ++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/subprojects/groovy-jmx/src/test/groovy/groovy/jmx/builder/JmxClientConnectorFactoryTest.groovy b/subprojects/groovy-jmx/src/test/groovy/groovy/jmx/builder/JmxClientConnectorFactoryTest.groovy
index c68511b..fe8ff46 100644
--- a/subprojects/groovy-jmx/src/test/groovy/groovy/jmx/builder/JmxClientConnectorFactoryTest.groovy
+++ b/subprojects/groovy-jmx/src/test/groovy/groovy/jmx/builder/JmxClientConnectorFactoryTest.groovy
@@ -30,6 +30,9 @@ class JmxClientConnectorFactoryTest extends GroovyTestCase {
 
     void setUp() {
         super.setUp()
+        def hostAddress = getHostAddress()
+        println "hostAddress: ${hostAddress}"
+        System.setProperty("java.rmi.server.hostname", hostAddress)
         builder = new JmxBuilder()
         rmi = JmxConnectorHelper.createRmiRegistry(defaultPort)
     }
@@ -71,4 +74,27 @@ class JmxClientConnectorFactoryTest extends GroovyTestCase {
             client.connect()
         }
     }
+
+    static String getHostAddress() {
+        try {
+            Enumeration<NetworkInterface> allNetInterfaces = NetworkInterface.getNetworkInterfaces();
+            while (allNetInterfaces.hasMoreElements()) {
+                NetworkInterface netInterface = (NetworkInterface) allNetInterfaces.nextElement();
+                Enumeration<InetAddress> addresses = netInterface.getInetAddresses();
+                while (addresses.hasMoreElements()) {
+                    InetAddress ip = (InetAddress) addresses.nextElement();
+                    if (ip != null
+                            && ip instanceof Inet4Address
+                            && !ip.isLoopbackAddress()
+                            && ip.getHostAddress().indexOf(":") == -1) {
+                        return ip.getHostAddress()
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace()
+        }
+        return null
+    }
+
 }
\ No newline at end of file