This is an automated email from the ASF dual-hosted git repository.
samt pushed a commit to branch cassandra-2.2
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/cassandra-2.2 by this push:
new 6a6dd8a Disable JMX rebinding
6a6dd8a is described below
commit 6a6dd8ad243cd140f931342ce609821ff2ca12d0
Author: Colm O hEigeartaigh <[email protected]>
AuthorDate: Mon Mar 23 14:05:03 2020 +0000
Disable JMX rebinding
Patch by Colm O hEigeartaigh; reviewed by Sam Tunnicliffe for
CASSANDRA-15653
---
CHANGES.txt | 3 ++
.../apache/cassandra/service/CassandraDaemon.java | 62 +++++++++++++++++++++-
2 files changed, 63 insertions(+), 2 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 246627b..885d33e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,6 @@
+2.2.18
+ * Disable JMX rebinding (CASSANDRA-15653)
+
2.2.17
* Fix Commit log replays when static column clustering keys are collections
(CASSANDRA-14365)
* Fix Red Hat init script on newer systemd versions (CASSANDRA-15273)
diff --git a/src/java/org/apache/cassandra/service/CassandraDaemon.java
b/src/java/org/apache/cassandra/service/CassandraDaemon.java
index c0ba38e..a317ab3 100644
--- a/src/java/org/apache/cassandra/service/CassandraDaemon.java
+++ b/src/java/org/apache/cassandra/service/CassandraDaemon.java
@@ -23,7 +23,14 @@ import java.lang.management.ManagementFactory;
import java.lang.management.MemoryPoolMXBean;
import java.net.InetAddress;
import java.net.UnknownHostException;
+import java.rmi.AccessException;
+import java.rmi.AlreadyBoundException;
+import java.rmi.NotBoundException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.RMIClientSocketFactory;
import java.rmi.server.RMIServerSocketFactory;
import java.util.Collections;
import java.util.List;
@@ -36,6 +43,7 @@ import javax.management.StandardMBean;
import javax.management.remote.JMXConnectorServer;
import javax.management.remote.JMXServiceURL;
import javax.management.remote.rmi.RMIConnectorServer;
+import javax.management.remote.rmi.RMIJRMPServerImpl;
import com.addthis.metrics3.reporter.config.ReporterConfig;
import com.codahale.metrics.Meter;
@@ -122,10 +130,16 @@ public class CassandraDaemon
Map<String, ?> env =
Collections.singletonMap(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE,
serverFactory);
try
{
- LocateRegistry.createRegistry(Integer.valueOf(jmxPort), null,
serverFactory);
+ Registry registry = new JmxRegistry(Integer.valueOf(jmxPort),
null, serverFactory, "jmxrmi");
JMXServiceURL url = new
JMXServiceURL(String.format("service:jmx:rmi://localhost/jndi/rmi://localhost:%s/jmxrmi",
jmxPort));
- jmxServer = new RMIConnectorServer(url, env,
ManagementFactory.getPlatformMBeanServer());
+ @SuppressWarnings("resource")
+ RMIJRMPServerImpl server = new
RMIJRMPServerImpl(Integer.valueOf(jmxPort),
+ null,
+
(RMIServerSocketFactory)
env.get(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE),
+ env);
+ jmxServer = new RMIConnectorServer(url, env, server,
ManagementFactory.getPlatformMBeanServer());
jmxServer.start();
+ ((JmxRegistry)registry).setRemoteServerStub(server.toStub());
}
catch (IOException e)
{
@@ -756,4 +770,48 @@ public class CassandraDaemon
*/
public boolean isRunning();
}
+
+
+ @SuppressWarnings("restriction")
+ private static class JmxRegistry extends sun.rmi.registry.RegistryImpl {
+ private final String lookupName;
+ private Remote remoteServerStub;
+
+ JmxRegistry(final int port,
+ final RMIClientSocketFactory csf,
+ RMIServerSocketFactory ssf,
+ final String lookupName) throws RemoteException
+ {
+ super(port, csf, ssf);
+ this.lookupName = lookupName;
+ }
+
+ @Override
+ public Remote lookup(String s) throws RemoteException,
NotBoundException
+ {
+ return lookupName.equals(s) ? remoteServerStub : null;
+ }
+
+ @Override
+ public void bind(String s, Remote remote) throws RemoteException,
AlreadyBoundException, AccessException
+ {
+ }
+
+ @Override
+ public void unbind(String s) throws RemoteException,
NotBoundException, AccessException {
+ }
+
+ @Override
+ public void rebind(String s, Remote remote) throws RemoteException,
AccessException {
+ }
+
+ @Override
+ public String[] list() throws RemoteException {
+ return new String[] {lookupName};
+ }
+
+ public void setRemoteServerStub(Remote remoteServerStub) {
+ this.remoteServerStub = remoteServerStub;
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]