jackrabbit-oak-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Munteanu (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OAK-8529) Eagerly deregister MBeans on SecurityProviderRegistration deactivation
Date Tue, 06 Aug 2019 12:33:00 GMT

    [ 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<String, Object> 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)
>         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.invokeMethod(BaseMethod.java:228)
>         at org.apache.felix.scr.impl.inject.methods.BaseMethod.access$500(BaseMethod.java:41)
>         at org.apache.felix.scr.impl.inject.methods.BaseMethod$Resolved.invoke(BaseMethod.java:664)
>         at org.apache.felix.scr.impl.inject.methods.BaseMethod.invoke(BaseMethod.java:510)
>         at org.apache.felix.scr.impl.inject.methods.ActivateMethod.invoke(ActivateMethod.java:317)
>         at org.apache.felix.scr.impl.inject.methods.ActivateMethod.invoke(ActivateMethod.java:307)
>         at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:340)
>         at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:114)
>         at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:982)
>         at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:955)
>         at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:765)
>         at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:1045)
>         at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:999)
>         at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1216)
>         at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1137)
>         at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:944)
>         at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:880)
>         at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1168)
>         at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:125)
>         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.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:906)
>         at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:892)
>         at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:128)
>         at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:959)
>         at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:732)
>         at org.apache.felix.scr.impl.manager.SingleComponentManager.reconfigure(SingleComponentManager.java:734)
>         at org.apache.felix.scr.impl.manager.SingleComponentManager.reconfigure(SingleComponentManager.java:673)
>         at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.configurationUpdated(ConfigurableComponentHolder.java:435)
>         at org.apache.felix.scr.impl.manager.RegionConfigurationSupport.configurationEvent(RegionConfigurationSupport.java:316)
>         at org.apache.felix.scr.impl.manager.RegionConfigurationSupport$2.configurationEvent(RegionConfigurationSupport.java:118)
>         at org.apache.felix.cm.impl.ConfigurationManager$FireConfigurationEvent.sendEvent(ConfigurationManager.java:1704)
>         at org.apache.felix.cm.impl.ConfigurationManager$FireConfigurationEvent.run(ConfigurationManager.java:1646)
>         at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:138)
>         at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:105)
>         at java.lang.Thread.run(Thread.java:748)
> {noformat}
> I will propose a patch shortly.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Mime
View raw message