You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2020/09/16 12:07:12 UTC

[cxf] branch 3.3.x-fixes updated: Removing JMX getServerPort as it's not necessary

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

coheigea pushed a commit to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/3.3.x-fixes by this push:
     new e3aeb7c  Removing JMX getServerPort as it's not necessary
e3aeb7c is described below

commit e3aeb7c937ef382d2d3271e7e6f6b4c5743d38f7
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Wed Sep 16 12:53:12 2020 +0100

    Removing JMX getServerPort as it's not necessary
---
 .../cxf/management/jmx/MBServerConnectorFactory.java     | 16 +---------------
 .../cxf/management/jmx/MBServerConnectorFactoryTest.java |  9 ---------
 2 files changed, 1 insertion(+), 24 deletions(-)

diff --git a/rt/management/src/main/java/org/apache/cxf/management/jmx/MBServerConnectorFactory.java b/rt/management/src/main/java/org/apache/cxf/management/jmx/MBServerConnectorFactory.java
index 5eb7059..a4f102b 100644
--- a/rt/management/src/main/java/org/apache/cxf/management/jmx/MBServerConnectorFactory.java
+++ b/rt/management/src/main/java/org/apache/cxf/management/jmx/MBServerConnectorFactory.java
@@ -82,20 +82,6 @@ public final class MBServerConnectorFactory {
 
     }
 
-    static int getServerPort(final String url) {
-        int portStart = url.indexOf("localhost") + 10;
-        int portEnd;
-        int port = 0;
-        if (portStart > 0) {
-            portEnd = indexNotOfNumber(url, portStart);
-            if (portEnd > portStart) {
-                final String portString = url.substring(portStart, portEnd);
-                port = Integer.parseInt(portString);
-            }
-        }
-        return port;
-    }
-
     private static int indexNotOfNumber(String str, int index) {
         int i = 0;
         for (i = index; i < str.length(); i++) {
@@ -152,7 +138,7 @@ public final class MBServerConnectorFactory {
             }
         }
 
-        rmiServer = new RMIJRMPServerImpl(getServerPort(serviceUrl), null, null, environment);
+        rmiServer = new RMIJRMPServerImpl(url.getPort(), null, null, environment);
 
         // Create the connector server now.
         connectorServer = new RMIConnectorServer(url, environment, rmiServer, server);
diff --git a/rt/management/src/test/java/org/apache/cxf/management/jmx/MBServerConnectorFactoryTest.java b/rt/management/src/test/java/org/apache/cxf/management/jmx/MBServerConnectorFactoryTest.java
index 468ec0c..083b575 100644
--- a/rt/management/src/test/java/org/apache/cxf/management/jmx/MBServerConnectorFactoryTest.java
+++ b/rt/management/src/test/java/org/apache/cxf/management/jmx/MBServerConnectorFactoryTest.java
@@ -27,15 +27,6 @@ import org.junit.Test;
 public class MBServerConnectorFactoryTest {
 
     @Test
-    public void testGetServerPort() throws Exception {
-        Assert.assertEquals(9914, MBServerConnectorFactory.getServerPort(
-                "service:jmx:rmi:///jndi/rmi://localhost:9914/jmxrmi"));
-
-        Assert.assertEquals(10002, MBServerConnectorFactory.getServerPort(
-                "service:jmx:rmi://localhost:10002/jndi/rmi://localhost:10001/jmxrmi"));
-    }
-
-    @Test
     public void testGetRegistryPort() throws Exception {
         Assert.assertEquals(9914, MBServerConnectorFactory.getRegistryPort(
                 "service:jmx:rmi:///jndi/rmi://localhost:9914/jmxrmi"));