aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2019-12-13 17:32:51 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2019-12-13 17:32:51 +0100
commit549c3acc5f5ced76b8649630850e00f68798f311 (patch)
treea59368d47582f0af2f5f4d221d3daa6b0aae58ad /org.eclipse.jgit/src
parent42f0c7c9cb1c516603da6f89ae7072989bf4b984 (diff)
downloadjgit-549c3acc5f5ced76b8649630850e00f68798f311.tar.gz
jgit-549c3acc5f5ced76b8649630850e00f68798f311.zip
Fix MBean registration
Change-Id: I6f6b8641f6c3e8ab9f625594085014272305656a Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/Monitoring.java19
2 files changed, 14 insertions, 7 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java
index 6cf5bd948a..797507dd11 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java
@@ -458,7 +458,7 @@ public class WindowCache {
mbean = new StatsRecorderImpl();
statsRecorder = mbean;
- Monitoring.registerMBean(WindowCacheStats.class, "block_cache"); //$NON-NLS-1$
+ Monitoring.registerMBean(mbean, "block_cache"); //$NON-NLS-1$
if (maxFiles < 1)
throw new IllegalArgumentException(JGitText.get().openFilesMustBeAtLeast1);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/Monitoring.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/Monitoring.java
index a3c8f3e047..83bf695f70 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/Monitoring.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/Monitoring.java
@@ -39,19 +39,26 @@ public class Monitoring {
* Register a MBean with the platform MBean server
*
* @param mbean
- * the mbean interface to register
+ * the mbean object to register
* @param metricName
* name of the JGit metric, will be prefixed with
* "org.eclipse.jgit/"
* @return the registered mbean's object instance
*/
- public static @Nullable ObjectInstance registerMBean(Class mbean,
+ public static @Nullable ObjectInstance registerMBean(Object mbean,
String metricName) {
- boolean register;
+ boolean register = false;
try {
- register = SystemReader.getInstance().getUserConfig().getBoolean(
+ Class<?> interfaces[] = mbean.getClass().getInterfaces();
+ for (Class<?> i : interfaces) {
+ register = SystemReader.getInstance().getUserConfig()
+ .getBoolean(
ConfigConstants.CONFIG_JMX_SECTION,
- mbean.getSimpleName(), false);
+ i.getSimpleName(), false);
+ if (register) {
+ break;
+ }
+ }
} catch (IOException | ConfigInvalidException e) {
LOG.error(e.getMessage(), e);
return null;
@@ -61,7 +68,7 @@ public class Monitoring {
}
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
try {
- ObjectName mbeanName = objectName(mbean, metricName);
+ ObjectName mbeanName = objectName(mbean.getClass(), metricName);
if (server.isRegistered(mbeanName)) {
server.unregisterMBean(mbeanName);
}