[logback-dev] svn commit: r1049 - logback/trunk/logback-access/src/main/java/ch/qos/logback/access/filter

noreply.seb at qos.ch noreply.seb at qos.ch
Fri Dec 1 15:30:34 CET 2006


Author: seb
Date: Fri Dec  1 15:30:34 2006
New Revision: 1049

Modified:
   logback/trunk/logback-access/src/main/java/ch/qos/logback/access/filter/CountingFilter.java

Log:
Now checking if a mbean is already registered under the same ObjectName to prevent an javax.management.InstanceAlreadyExistsException when reloading the access configuration

Modified: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/filter/CountingFilter.java
==============================================================================
--- logback/trunk/logback-access/src/main/java/ch/qos/logback/access/filter/CountingFilter.java	(original)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/filter/CountingFilter.java	Fri Dec  1 15:30:34 2006
@@ -1,13 +1,12 @@
  package ch.qos.logback.access.filter;
 
-import java.lang.management.ManagementFactory;
+import ch.qos.logback.core.filter.Filter;
+import ch.qos.logback.core.spi.FilterReply;
 
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 import javax.management.StandardMBean;
-
-import ch.qos.logback.core.filter.Filter;
-import ch.qos.logback.core.spi.FilterReply;
+import java.lang.management.ManagementFactory;
 
 public class CountingFilter extends Filter {
 
@@ -38,6 +37,9 @@
     try {
       ObjectName on = new ObjectName(domain+":Name="+getName());
       StandardMBean mbean = new StandardMBean(accessStatsImpl, StatisticalView.class);
+      if (mbs.isRegistered(on)) {
+          mbs.unregisterMBean(on);
+      }
       mbs.registerMBean(mbean, on);
       super.start();
     } catch (Exception e) {



More information about the logback-dev mailing list