scylla-jmx: Fix tablemetricsobjectname breakage
Fixes #57
The usage of TableMetricsObjectName-yada-yada relies on translating the
"fake" objectname to a canonical one on remote
publication/serialization. However, the implementation of
ObjectName.getInstance has changed in JDK (micro) updates so it no
longer applies overridable methods -> wrong name published.
Fix by doing explicit ObjectName instansiation.
Message-Id: <20181023132005.23099-1-calle@scylladb.com>
(cherry picked from commit ca3fa8de20
)
This commit is contained in:
parent
dbb3d44d69
commit
426b88b983
@ -53,7 +53,16 @@ public class APIMBeanServer implements MBeanServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static ObjectName prepareForRemote(final ObjectName n) {
|
private static ObjectName prepareForRemote(final ObjectName n) {
|
||||||
return ObjectName.getInstance(n);
|
/*
|
||||||
|
* ObjectName.getInstance has changed in JDK (micro) updates so it no longer applies
|
||||||
|
* overridable methods -> wrong name published.
|
||||||
|
* Fix by doing explicit ObjectName instansiation.
|
||||||
|
*/
|
||||||
|
try {
|
||||||
|
return new ObjectName(n.getCanonicalName());
|
||||||
|
} catch (MalformedObjectNameException e) {
|
||||||
|
throw new IllegalArgumentException(n.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -297,17 +297,16 @@ public class TableMetrics implements Metrics {
|
|||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
static class TableMetricObjectName extends javax.management.ObjectName {
|
static class TableMetricObjectName extends javax.management.ObjectName {
|
||||||
private static final String FAKE_NAME = "a:a=a";
|
|
||||||
|
|
||||||
private final TableMetricStringNameFactory factory;
|
private final TableMetricStringNameFactory factory;
|
||||||
private final String metricName;
|
private final String metricName;
|
||||||
|
|
||||||
public TableMetricObjectName(TableMetricStringNameFactory factory, String metricName) throws MalformedObjectNameException {
|
public TableMetricObjectName(TableMetricStringNameFactory factory, String metricName) throws MalformedObjectNameException {
|
||||||
super(FAKE_NAME);
|
super("");
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
this.metricName = metricName;
|
this.metricName = metricName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPropertyValuePattern(String property) {
|
public boolean isPropertyValuePattern(String property) {
|
||||||
return false;
|
return false;
|
||||||
@ -356,8 +355,7 @@ public class TableMetrics implements Metrics {
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (!(o instanceof TableMetricObjectName)) return false;
|
return getCanonicalName().equals(((ObjectName) o).getCanonicalName());
|
||||||
return getCanonicalName().equals(((TableMetricObjectName) o).getCanonicalName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -372,6 +370,36 @@ public class TableMetrics implements Metrics {
|
|||||||
}
|
}
|
||||||
return getCanonicalName().equals(name.getCanonicalName());
|
return getCanonicalName().equals(name.getCanonicalName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPattern() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDomainPattern() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPropertyPattern() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPropertyListPattern() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPropertyValuePattern() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static interface TableMetricStringNameFactory {
|
static interface TableMetricStringNameFactory {
|
||||||
|
Loading…
Reference in New Issue
Block a user