[jira] [Commented] (OAK-8529) Eagerly deregister MBeans on SecurityProviderRegistration deactivation
[ https://issues.apache.org/jira/browse/OAK-8529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16929143#comment-16929143 ] Robert Munteanu commented on OAK-8529: -- [~angela] - I was actually wrong and this was not a race condition. The problem was that the {{deactivate}} method did not close the Closer, which meant that registered services would be dangling after a deactivate in case they did not go through the {{maybeUnregister()}} method. This is the case for instance with the {{AuthenticationConfiguration}} reference. I have updated the pull request with the change and with a failing test (that passes after my change). Please see https://github.com/apache/jackrabbit-oak/pull/139/files . Thanks! > Eagerly deregister MBeans on SecurityProviderRegistration deactivation > -- > > Key: OAK-8529 > URL: https://issues.apache.org/jira/browse/OAK-8529 > Project: Jackrabbit Oak > Issue Type: Improvement > Components: security >Reporter: Robert Munteanu >Assignee: Robert Munteanu >Priority: Major > Fix For: 1.18.0 > > > The SecurityProviderRegistration is prone to being activated and deactivated > during a regular Sling application startup ( for a prolonged discussion see > SLING-7811 ). The instance should fully cleanup after itself to make sure it > will be usable after an activate/deactive cycle. > In practice the MBeans remain registered and prevent a further registration > with errors such as > {noformat}6.08.2019 09:43:51.051 *ERROR* [CM Event Dispatcher (Fire > ConfigurationEvent: > pid=org.apache.jackrabbit.oak.security.authentication.AuthenticationConfigurationImpl)] > org.apache.aries.jmx.whiteboard.MBeanHolder register: Failure registering > MBean > org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean@45011485 > javax.management.InstanceAlreadyExistsException: > org.apache.jackrabbit.oak:name=LoginModule statistics,type=LoginModuleStats > at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324) > at > com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522) > at > org.apache.aries.jmx.whiteboard.MBeanHolder.register(MBeanHolder.java:114) > at > org.apache.aries.jmx.whiteboard.JmxWhiteboardSupport.registerMBean(JmxWhiteboardSupport.java:88) > at > org.apache.aries.jmx.whiteboard.Activator$MBeanTracker.addingService(Activator.java:102) > at > org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:943) > at > org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:871) > at > org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) > at > org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) > at > org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:903) > at > org.apache.felix.framework.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:990) > at > org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:838) > at > org.apache.felix.framework.EventDispatcher.fireServiceEvent(EventDispatcher.java:545) > at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4833) > at org.apache.felix.framework.Felix.registerService(Felix.java:3804) > at > org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:328) > at > org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:302) > at > org.apache.jackrabbit.oak.osgi.OsgiWhiteboard.register(OsgiWhiteboard.java:79) > at > org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.registerMBean(WhiteboardUtils.java:115) > [org.apache.jackrabbit.oak-core-spi:1.16.0] > at > org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.registerMBean(WhiteboardUtils.java:99) > [org.apache.jackrabbit.oak-core-spi:1.16.0] > at > org.apache.jackrabbit.oak.security.internal.SecurityProviderRegistration.maybeRegister(SecurityProviderRegistration.java:539) > at > org.apache.jackrabbit.oak.security.internal.SecurityProviderRegistration.activate(Secu
[jira] [Commented] (OAK-8529) Eagerly deregister MBeans on SecurityProviderRegistration deactivation
[ https://issues.apache.org/jira/browse/OAK-8529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16929122#comment-16929122 ] Robert Munteanu commented on OAK-8529: -- [~angela] - I believe this to be a race condition, so providing a test will not be that easy. However, when reviewing my code I saw that the proposed change is incorrect, as it may close the closer too early. I'll try and come up with an updated patch. > Eagerly deregister MBeans on SecurityProviderRegistration deactivation > -- > > Key: OAK-8529 > URL: https://issues.apache.org/jira/browse/OAK-8529 > Project: Jackrabbit Oak > Issue Type: Improvement > Components: security >Reporter: Robert Munteanu >Assignee: Robert Munteanu >Priority: Major > Fix For: 1.18.0 > > > The SecurityProviderRegistration is prone to being activated and deactivated > during a regular Sling application startup ( for a prolonged discussion see > SLING-7811 ). The instance should fully cleanup after itself to make sure it > will be usable after an activate/deactive cycle. > In practice the MBeans remain registered and prevent a further registration > with errors such as > {noformat}6.08.2019 09:43:51.051 *ERROR* [CM Event Dispatcher (Fire > ConfigurationEvent: > pid=org.apache.jackrabbit.oak.security.authentication.AuthenticationConfigurationImpl)] > org.apache.aries.jmx.whiteboard.MBeanHolder register: Failure registering > MBean > org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean@45011485 > javax.management.InstanceAlreadyExistsException: > org.apache.jackrabbit.oak:name=LoginModule statistics,type=LoginModuleStats > at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324) > at > com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522) > at > org.apache.aries.jmx.whiteboard.MBeanHolder.register(MBeanHolder.java:114) > at > org.apache.aries.jmx.whiteboard.JmxWhiteboardSupport.registerMBean(JmxWhiteboardSupport.java:88) > at > org.apache.aries.jmx.whiteboard.Activator$MBeanTracker.addingService(Activator.java:102) > at > org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:943) > at > org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:871) > at > org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) > at > org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) > at > org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:903) > at > org.apache.felix.framework.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:990) > at > org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:838) > at > org.apache.felix.framework.EventDispatcher.fireServiceEvent(EventDispatcher.java:545) > at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4833) > at org.apache.felix.framework.Felix.registerService(Felix.java:3804) > at > org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:328) > at > org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:302) > at > org.apache.jackrabbit.oak.osgi.OsgiWhiteboard.register(OsgiWhiteboard.java:79) > at > org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.registerMBean(WhiteboardUtils.java:115) > [org.apache.jackrabbit.oak-core-spi:1.16.0] > at > org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.registerMBean(WhiteboardUtils.java:99) > [org.apache.jackrabbit.oak-core-spi:1.16.0] > at > org.apache.jackrabbit.oak.security.internal.SecurityProviderRegistration.maybeRegister(SecurityProviderRegistration.java:539) > at > org.apache.jackrabbit.oak.security.internal.SecurityProviderRegistration.activate(SecurityProviderRegistration.java:191) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
[jira] [Commented] (OAK-8529) Eagerly deregister MBeans on SecurityProviderRegistration deactivation
[ https://issues.apache.org/jira/browse/OAK-8529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16901138#comment-16901138 ] angela commented on OAK-8529: - [~rombert], would it help, if the {{AbstractSecurityTest}} would provide access to the {{NodeStore}} such that you could re-use it for the creation of a second oak repository? in other word: instead of call {{new Oak}} the memory store would be created separately and passed to {{new Oak(testStore)}}. after populating that one, you could call new Oak again with the same store. wdyt? cc: [~stillalex] > Eagerly deregister MBeans on SecurityProviderRegistration deactivation > -- > > Key: OAK-8529 > URL: https://issues.apache.org/jira/browse/OAK-8529 > Project: Jackrabbit Oak > Issue Type: Improvement > Components: security >Reporter: Robert Munteanu >Assignee: Robert Munteanu >Priority: Major > Fix For: 1.18.0 > > > The SecurityProviderRegistration is prone to being activated and deactivated > during a regular Sling application startup ( for a prolonged discussion see > SLING-7811 ). The instance should fully cleanup after itself to make sure it > will be usable after an activate/deactive cycle. > In practice the MBeans remain registered and prevent a further registration > with errors such as > {noformat}6.08.2019 09:43:51.051 *ERROR* [CM Event Dispatcher (Fire > ConfigurationEvent: > pid=org.apache.jackrabbit.oak.security.authentication.AuthenticationConfigurationImpl)] > org.apache.aries.jmx.whiteboard.MBeanHolder register: Failure registering > MBean > org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean@45011485 > javax.management.InstanceAlreadyExistsException: > org.apache.jackrabbit.oak:name=LoginModule statistics,type=LoginModuleStats > at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324) > at > com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522) > at > org.apache.aries.jmx.whiteboard.MBeanHolder.register(MBeanHolder.java:114) > at > org.apache.aries.jmx.whiteboard.JmxWhiteboardSupport.registerMBean(JmxWhiteboardSupport.java:88) > at > org.apache.aries.jmx.whiteboard.Activator$MBeanTracker.addingService(Activator.java:102) > at > org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:943) > at > org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:871) > at > org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) > at > org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) > at > org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:903) > at > org.apache.felix.framework.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:990) > at > org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:838) > at > org.apache.felix.framework.EventDispatcher.fireServiceEvent(EventDispatcher.java:545) > at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4833) > at org.apache.felix.framework.Felix.registerService(Felix.java:3804) > at > org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:328) > at > org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:302) > at > org.apache.jackrabbit.oak.osgi.OsgiWhiteboard.register(OsgiWhiteboard.java:79) > at > org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.registerMBean(WhiteboardUtils.java:115) > [org.apache.jackrabbit.oak-core-spi:1.16.0] > at > org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.registerMBean(WhiteboardUtils.java:99) > [org.apache.jackrabbit.oak-core-spi:1.16.0] > at > org.apache.jackrabbit.oak.security.internal.SecurityProviderRegistration.maybeRegister(SecurityProviderRegistration.java:539) > at > org.apache.jackrabbit.oak.security.internal.SecurityProviderRegistration.activate(SecurityProviderRegistration.java:191) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.
[jira] [Commented] (OAK-8529) Eagerly deregister MBeans on SecurityProviderRegistration deactivation
[ https://issues.apache.org/jira/browse/OAK-8529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16900983#comment-16900983 ] Robert Munteanu commented on OAK-8529: -- [~angela], [~stillalex] - having a test case would be problematic. The way I see this is by starting up Apache Sling with a MongoDB setup which is pre-populated. It definitely has to do with the async nature of the Sling repository registration, which is not that easy to capture in a unit test. I have tried to write a simple {{testReactivate}} test, but that did not trigger the problem {code}diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/internal/SecurityProviderRegistrationTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/internal/SecurityProviderRegistrationTest.java index 95f24d22d8..6df41e744d 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/internal/SecurityProviderRegistrationTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/internal/SecurityProviderRegistrationTest.java @@ -166,6 +166,38 @@ public class SecurityProviderRegistrationTest extends AbstractSecurityTest { assertNotNull(service); } +@Test +public void testReactivate() { +registration.activate(context.bundleContext(), configWithRequiredServiceIds("serviceA", "serviceB")); + +SecurityProvider service = context.getService(SecurityProvider.class); +assertNull(service); + +RestrictionProvider mockRp = mock(RestrictionProvider.class); +ServiceReference sr = when(mock(ServiceReference.class).getProperty(SERVICE_PID)).thenReturn("serviceA").getMock(); + +registration.bindRestrictionProvider(sr, mockRp); + +service = context.getService(SecurityProvider.class); +assertNull(service); + +AuthorizationConfigurationImpl authzConfig = new AuthorizationConfigurationImpl(); +ImmutableMap autzProps = ImmutableMap.of(SERVICE_PID, "serviceB"); + +registration.bindAuthorizationConfiguration(authzConfig, autzProps); +service = context.getService(SecurityProvider.class); +assertNotNull(service); + +registration.unbindAuthorizationConfiguration(authzConfig, autzProps); +service = context.getService(SecurityProvider.class); +assertNull(service); + +registration.bindAuthorizationConfiguration(authzConfig, autzProps); +service = context.getService(SecurityProvider.class); +assertNotNull(service); + +} + @Test public void testActivate() { registration.activate(context.bundleContext(), configWithRequiredServiceIds("serviceA", "serviceB")); {code} > Eagerly deregister MBeans on SecurityProviderRegistration deactivation > -- > > Key: OAK-8529 > URL: https://issues.apache.org/jira/browse/OAK-8529 > Project: Jackrabbit Oak > Issue Type: Improvement > Components: security >Reporter: Robert Munteanu >Assignee: Robert Munteanu >Priority: Major > Fix For: 1.18.0 > > > The SecurityProviderRegistration is prone to being activated and deactivated > during a regular Sling application startup ( for a prolonged discussion see > SLING-7811 ). The instance should fully cleanup after itself to make sure it > will be usable after an activate/deactive cycle. > In practice the MBeans remain registered and prevent a further registration > with errors such as > {noformat}6.08.2019 09:43:51.051 *ERROR* [CM Event Dispatcher (Fire > ConfigurationEvent: > pid=org.apache.jackrabbit.oak.security.authentication.AuthenticationConfigurationImpl)] > org.apache.aries.jmx.whiteboard.MBeanHolder register: Failure registering > MBean > org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean@45011485 > javax.management.InstanceAlreadyExistsException: > org.apache.jackrabbit.oak:name=LoginModule statistics,type=LoginModuleStats > at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324) > at > com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522) > at > org.apache.aries.jmx.whiteboard.MBeanHolder.register(MBeanHolder.java:114) >
[jira] [Commented] (OAK-8529) Eagerly deregister MBeans on SecurityProviderRegistration deactivation
[ https://issues.apache.org/jira/browse/OAK-8529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16900973#comment-16900973 ] angela commented on OAK-8529: - [~rombert], i think [~stillalex] would be better suited to review the proposed change as he added the closeQuietly with OAK-8102. just one obvious observation from my side: can you provide a test case illustrating the issue you want to fix? IMHO that would be important to have. > Eagerly deregister MBeans on SecurityProviderRegistration deactivation > -- > > Key: OAK-8529 > URL: https://issues.apache.org/jira/browse/OAK-8529 > Project: Jackrabbit Oak > Issue Type: Improvement > Components: security >Reporter: Robert Munteanu >Assignee: Robert Munteanu >Priority: Major > Fix For: 1.18.0 > > > The SecurityProviderRegistration is prone to being activated and deactivated > during a regular Sling application startup ( for a prolonged discussion see > SLING-7811 ). The instance should fully cleanup after itself to make sure it > will be usable after an activate/deactive cycle. > In practice the MBeans remain registered and prevent a further registration > with errors such as > {noformat}6.08.2019 09:43:51.051 *ERROR* [CM Event Dispatcher (Fire > ConfigurationEvent: > pid=org.apache.jackrabbit.oak.security.authentication.AuthenticationConfigurationImpl)] > org.apache.aries.jmx.whiteboard.MBeanHolder register: Failure registering > MBean > org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean@45011485 > javax.management.InstanceAlreadyExistsException: > org.apache.jackrabbit.oak:name=LoginModule statistics,type=LoginModuleStats > at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324) > at > com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522) > at > org.apache.aries.jmx.whiteboard.MBeanHolder.register(MBeanHolder.java:114) > at > org.apache.aries.jmx.whiteboard.JmxWhiteboardSupport.registerMBean(JmxWhiteboardSupport.java:88) > at > org.apache.aries.jmx.whiteboard.Activator$MBeanTracker.addingService(Activator.java:102) > at > org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:943) > at > org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:871) > at > org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) > at > org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) > at > org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:903) > at > org.apache.felix.framework.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:990) > at > org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:838) > at > org.apache.felix.framework.EventDispatcher.fireServiceEvent(EventDispatcher.java:545) > at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4833) > at org.apache.felix.framework.Felix.registerService(Felix.java:3804) > at > org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:328) > at > org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:302) > at > org.apache.jackrabbit.oak.osgi.OsgiWhiteboard.register(OsgiWhiteboard.java:79) > at > org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.registerMBean(WhiteboardUtils.java:115) > [org.apache.jackrabbit.oak-core-spi:1.16.0] > at > org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.registerMBean(WhiteboardUtils.java:99) > [org.apache.jackrabbit.oak-core-spi:1.16.0] > at > org.apache.jackrabbit.oak.security.internal.SecurityProviderRegistration.maybeRegister(SecurityProviderRegistration.java:539) > at > org.apache.jackrabbit.oak.security.internal.SecurityProviderRegistration.activate(SecurityProviderRegistration.java:191) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce
[jira] [Commented] (OAK-8529) Eagerly deregister MBeans on SecurityProviderRegistration deactivation
[ https://issues.apache.org/jira/browse/OAK-8529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16900932#comment-16900932 ] Robert Munteanu commented on OAK-8529: -- [~angela] - can you please take a look at the PR from https://github.com/apache/jackrabbit-oak/pull/139? > Eagerly deregister MBeans on SecurityProviderRegistration deactivation > -- > > Key: OAK-8529 > URL: https://issues.apache.org/jira/browse/OAK-8529 > Project: Jackrabbit Oak > Issue Type: Improvement > Components: security >Reporter: Robert Munteanu >Assignee: Robert Munteanu >Priority: Major > Fix For: 1.18.0 > > > The SecurityProviderRegistration is prone to being activated and deactivated > during a regular Sling application startup ( for a prolonged discussion see > SLING-7811 ). The instance should fully cleanup after itself to make sure it > will be usable after an activate/deactive cycle. > In practice the MBeans remain registered and prevent a further registration > with errors such as > {noformat}6.08.2019 09:43:51.051 *ERROR* [CM Event Dispatcher (Fire > ConfigurationEvent: > pid=org.apache.jackrabbit.oak.security.authentication.AuthenticationConfigurationImpl)] > org.apache.aries.jmx.whiteboard.MBeanHolder register: Failure registering > MBean > org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean@45011485 > javax.management.InstanceAlreadyExistsException: > org.apache.jackrabbit.oak:name=LoginModule statistics,type=LoginModuleStats > at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900) > at > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324) > at > com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522) > at > org.apache.aries.jmx.whiteboard.MBeanHolder.register(MBeanHolder.java:114) > at > org.apache.aries.jmx.whiteboard.JmxWhiteboardSupport.registerMBean(JmxWhiteboardSupport.java:88) > at > org.apache.aries.jmx.whiteboard.Activator$MBeanTracker.addingService(Activator.java:102) > at > org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:943) > at > org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:871) > at > org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) > at > org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) > at > org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:903) > at > org.apache.felix.framework.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:990) > at > org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:838) > at > org.apache.felix.framework.EventDispatcher.fireServiceEvent(EventDispatcher.java:545) > at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4833) > at org.apache.felix.framework.Felix.registerService(Felix.java:3804) > at > org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:328) > at > org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:302) > at > org.apache.jackrabbit.oak.osgi.OsgiWhiteboard.register(OsgiWhiteboard.java:79) > at > org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.registerMBean(WhiteboardUtils.java:115) > [org.apache.jackrabbit.oak-core-spi:1.16.0] > at > org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.registerMBean(WhiteboardUtils.java:99) > [org.apache.jackrabbit.oak-core-spi:1.16.0] > at > org.apache.jackrabbit.oak.security.internal.SecurityProviderRegistration.maybeRegister(SecurityProviderRegistration.java:539) > at > org.apache.jackrabbit.oak.security.internal.SecurityProviderRegistration.activate(SecurityProviderRegistration.java:191) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:498) > at > org.apache.felix.scr.impl.inject.methods.BaseMethod.invokeMeth