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

 ##########
 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:
   Hopefully done in the latest commit.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to