You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2020/09/16 11:48:53 UTC

[karaf] branch karaf-4.2.x updated: KARAF-6852 - RmiServerPort (44444) does not rise at startup

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

jbonofre pushed a commit to branch karaf-4.2.x
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/karaf-4.2.x by this push:
     new d2d7d2a  KARAF-6852 - RmiServerPort (44444) does not rise at startup
d2d7d2a is described below

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

    KARAF-6852 - RmiServerPort (44444) does not rise at startup
    
    (cherry picked from commit 311da35fdaca72d6ce128d4a8f8c2bb229cf67f7)
---
 .../karaf/management/ConnectorServerFactory.java   | 26 +---------------------
 1 file changed, 1 insertion(+), 25 deletions(-)

diff --git a/management/server/src/main/java/org/apache/karaf/management/ConnectorServerFactory.java b/management/server/src/main/java/org/apache/karaf/management/ConnectorServerFactory.java
index a8be130..9a58ed2 100644
--- a/management/server/src/main/java/org/apache/karaf/management/ConnectorServerFactory.java
+++ b/management/server/src/main/java/org/apache/karaf/management/ConnectorServerFactory.java
@@ -393,7 +393,7 @@ public class ConnectorServerFactory {
         MBeanInvocationHandler handler = new MBeanInvocationHandler(server, guard);
         MBeanServer guardedServer = (MBeanServer) Proxy.newProxyInstance(server.getClass().getClassLoader(), new Class[]{ MBeanServer.class }, handler);
 
-        rmiServer = new RMIJRMPServerImpl(getServerPort(serviceUrl), null, null, environment);
+        rmiServer = new RMIJRMPServerImpl(url.getPort(), null, null, environment);
 
         // Create the connector server now.
         this.connectorServer = new RMIConnectorServer(url, environment, rmiServer, guardedServer);
@@ -471,30 +471,6 @@ public class ConnectorServerFactory {
         return "jmxrmi"; // use the default
     }
 
-    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++) {
-            if (str.charAt(i) < '0' || str.charAt(i) > '9') {
-                return i;
-            }
-        }
-        return -1;
-    }
-
     public void destroy() throws Exception {
         try {
             if (this.connectorServer != null) {