You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by GitBox <gi...@apache.org> on 2020/02/18 17:38:17 UTC

[GitHub] [cxf] jgallimore commented on a change in pull request #641: Prevent RMI registry rebind

jgallimore commented on a change in pull request #641: Prevent RMI registry rebind
URL: https://github.com/apache/cxf/pull/641#discussion_r380828642
 
 

 ##########
 File path: rt/management/src/main/java/org/apache/cxf/management/jmx/MBServerConnectorFactory.java
 ##########
 @@ -169,18 +174,71 @@ public void run() {
         } else {
              // Start the connector server in the same thread.
             connectorServer.start();
+            remoteServerStub = rmiServer.toStub();
         }
 
         if (LOG.isLoggable(Level.INFO)) {
             LOG.info("JMX connector server started: " + connectorServer);
         }
     }
 
+    static int getRegistryPort(final String url) {
+        int serverStart = url.indexOf("/jndi/rmi://");
+        final String serverPart = url.substring(serverStart + 12);
+        int portStart = serverPart.indexOf(':') + 1;
+
+        int portEnd;
+        int port = 0;
+        if (portStart > 0) {
+            portEnd = indexNotOfNumber(serverPart, portStart);
+            if (portEnd > portStart) {
+                final String portString = serverPart.substring(portStart, portEnd);
+                port = Integer.parseInt(portString);
+            }
+        }
+        return port;
+    }
+
     public void destroy() throws IOException {
         connectorServer.stop();
         if (LOG.isLoggable(Level.INFO)) {
             LOG.info("JMX connector server stopped: " + connectorServer);
         }
     }
 
+    /*
+     * Better to use the internal API than re-invent the wheel.
+     */
+    @SuppressWarnings("restriction")
+    private class JmxRegistry extends sun.rmi.registry.RegistryImpl {
+        static final String LOOKUP_NAME = "jmxrmi";
 
 Review comment:
   Good point. Let's see if we can do that in a smarter way.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services