sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1757154 - in /sling/trunk/bundles/resourceresolver/src: main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java
Date Mon, 22 Aug 2016 12:16:57 GMT
Author: cziegeler
Date: Mon Aug 22 12:16:57 2016
New Revision: 1757154

URL: http://svn.apache.org/viewvc?rev=1757154&view=rev
Log:
SLING-5986 : Improve shutdown time when system is stopping

Modified:
    sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java
    sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java

Modified: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java?rev=1757154&r1=1757153&r2=1757154&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java
(original)
+++ sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java
Mon Aug 22 12:16:57 2016
@@ -711,16 +711,20 @@ public class ResourceResolverFactoryActi
         if ( localContext != null ) {
             final boolean result = this.preconds.checkPreconditions(unavailableName, unavailableServicePid);
             if ( result && this.factoryRegistration == null ) {
-                boolean create = true;
-                synchronized ( this ) {
-                    if ( this.factoryRegistration == null ) {
-                        this.factoryRegistration = new FactoryRegistration();
-                    } else {
-                        create = false;
+                // check system bundle state - if stopping, don't register new factory
+                final Bundle systemBundle = localContext.getBundleContext().getBundle(Constants.SYSTEM_BUNDLE_LOCATION);
+                if ( systemBundle != null && systemBundle.getState() != Bundle.STOPPING
) {
+                    boolean create = true;
+                    synchronized ( this ) {
+                        if ( this.factoryRegistration == null ) {
+                            this.factoryRegistration = new FactoryRegistration();
+                        } else {
+                            create = false;
+                        }
+                    }
+                    if ( create ) {
+                        this.registerFactory(localContext);
                     }
-                }
-                if ( create ) {
-                    this.registerFactory(localContext);
                 }
             } else if ( !result && this.factoryRegistration != null ) {
                 this.unregisterFactory();

Modified: sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java?rev=1757154&r1=1757153&r2=1757154&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java
(original)
+++ sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java
Mon Aug 22 12:16:57 2016
@@ -148,6 +148,10 @@ public class MockedResourceResolverImplT
         Mockito.when(componentContext.getBundleContext()).thenReturn(
             bundleContext);
 
+        // system bundle access
+        final Bundle systemBundle = Mockito.mock(Bundle.class);
+        Mockito.when(systemBundle.getState()).thenReturn(Bundle.ACTIVE);
+        Mockito.when(bundleContext.getBundle(Constants.SYSTEM_BUNDLE_LOCATION)).thenReturn(systemBundle);
         activator.resourceAccessSecurityTracker = new ResourceAccessSecurityTracker();
         activator.resourceProviderTracker = resourceProviderTracker;
         activator.changeListenerWhiteboard = resourceChangeListenerWhiteboard;



Mime
View raw message