Author: kwin
Date: Tue Sep 15 13:08:05 2015
New Revision: 1703188

URL: http://svn.apache.org/r1703188
Log:
SLING-5025 throw ISE in case the resource resolver factory was closed, clarify 
Javadocs of the ResourceResolver interface with respect to closed 
ResourceResolvers

Modified:
    
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
    
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java

Modified: 
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java?rev=1703188&r1=1703187&r2=1703188&view=diff
==============================================================================
--- 
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
 (original)
+++ 
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
 Tue Sep 15 13:08:05 2015
@@ -84,7 +84,10 @@ import aQute.bnd.annotation.ProviderType
  * Resource Resolver using any of the factory methods and ends with calling the
  * {@link #close()} method. It is very important to call the {@link #close()}
  * method once the resource resolver is not used any more to ensure any system
- * resources are properly cleaned up.
+ * resources are properly cleaned up. 
+ * 
+ * A Resource Resolver may also be closed implicitly if the {@link 
ResourceResolverFactory}
+ * which was used to create this resolver is no longer active.
  * <p>
  * To check whether a Resource Resolver can still be used, the {@link 
#isLive()}
  * method can be called.
@@ -542,8 +545,12 @@ public interface ResourceResolver extend
      * called, the resource resolver is considered unusable and will throw
      * exceptions if still used - with the exception of this method, which
      * can be called several times with no ill effects.
+     * 
+     * A resource may also be closed implicitly in case when the {@link 
ResourceResolverFactory}
+     * which was used to create this resolver is no longer active.
      *
      * @since 2.1 (Sling API Bundle 2.1.0)
+     * @see ResourceResolver Resource Resolver (section lifecycle)
      */
     @Override
     void close();

Modified: 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java?rev=1703188&r1=1703187&r2=1703188&view=diff
==============================================================================
--- 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
 (original)
+++ 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
 Tue Sep 15 13:08:05 2015
@@ -38,6 +38,7 @@ import org.apache.sling.adapter.annotati
 import org.apache.sling.adapter.annotations.Adapter;
 import org.apache.sling.api.SlingException;
 import org.apache.sling.api.adapter.SlingAdaptable;
+import org.apache.sling.api.resource.DynamicResourceProvider;
 import org.apache.sling.api.resource.LoginException;
 import org.apache.sling.api.resource.NonExistingResource;
 import org.apache.sling.api.resource.PersistenceException;
@@ -155,15 +156,18 @@ public class ResourceResolverImpl extend
     }
 
     /**
-     * Check if the resource resolver is already closed.
+     * Check if the resource resolver is already closed or the factory which 
created this resolver is no longer live.
      *
      * @throws IllegalStateException
-     *             If the resolver is already closed
+     *             If the resolver is already closed or the factory is no 
longer live.
      */
     private void checkClosed() {
         if (this.isClosed.get()) {
             throw new IllegalStateException("Resource resolver is already 
closed.");
         }
+        if (!this.factory.isLive()) {
+            throw new IllegalStateException("Resource resolver factory which 
created this resolver is no longer active.");
+        }
     }
 
     // ---------- attributes


Reply via email to