Author: cziegeler
Date: Tue Feb  2 20:17:01 2016
New Revision: 1728202

URL: http://svn.apache.org/viewvc?rev=1728202&view=rev
Log:
SLING-5470 : Resource providers might not be closed

Added:
    
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/AbstractIterator.java
      - copied, changed from r1728201, 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/AbstractIterator.java
    
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ChainedIterator.java
   (with props)
    
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/UniqueResourceIterator.java
   (with props)
Removed:
    
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/AbstractIterator.java
Modified:
    
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverContext.java
    
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/SecureResourceProviderDecorator.java

Copied: 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/AbstractIterator.java
 (from r1728201, 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/AbstractIterator.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/AbstractIterator.java?p2=sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/AbstractIterator.java&p1=sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/AbstractIterator.java&r1=1728201&r2=1728202&rev=1728202&view=diff
==============================================================================
--- 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/AbstractIterator.java
 (original)
+++ 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/AbstractIterator.java
 Tue Feb  2 20:17:01 2016
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.resourceresolver.impl.providers.stateful;
+package org.apache.sling.resourceresolver.impl.helper;
 
 import java.util.Iterator;
 import java.util.NoSuchElementException;

Added: 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ChainedIterator.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ChainedIterator.java?rev=1728202&view=auto
==============================================================================
--- 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ChainedIterator.java
 (added)
+++ 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ChainedIterator.java
 Tue Feb  2 20:17:01 2016
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.resourceresolver.impl.helper;
+
+import java.util.Iterator;
+
+public class ChainedIterator<T> extends AbstractIterator<T> {
+
+    private final Iterator<Iterator<T>> iterators;
+
+    private Iterator<T> currentIterator;
+
+    public ChainedIterator(Iterator<Iterator<T>> iterators) {
+        this.iterators = iterators;
+    }
+
+    @Override
+    protected T seek() {
+        while (true) {
+            if (currentIterator == null) {
+                if (!iterators.hasNext()) {
+                    return null;
+                }
+                currentIterator = iterators.next();
+                continue;
+            }
+            if (currentIterator.hasNext()) {
+                return currentIterator.next();
+            } else {
+                currentIterator = null;
+            }
+        }
+    }
+}

Propchange: 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ChainedIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ChainedIterator.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Modified: 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverContext.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverContext.java?rev=1728202&r1=1728201&r2=1728202&view=diff
==============================================================================
--- 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverContext.java
 (original)
+++ 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverContext.java
 Tue Feb  2 20:17:01 2016
@@ -17,9 +17,6 @@
  */
 package org.apache.sling.resourceresolver.impl.helper;
 
-import static org.apache.sling.api.resource.ResourceUtil.getName;
-import static 
org.apache.sling.spi.resource.provider.ResourceProvider.RESOURCE_TYPE_SYNTHETIC;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -50,7 +47,6 @@ import org.apache.sling.resource.path.Pa
 import 
org.apache.sling.resourceresolver.impl.providers.ResourceProviderHandler;
 import org.apache.sling.resourceresolver.impl.providers.ResourceProviderInfo;
 import 
org.apache.sling.resourceresolver.impl.providers.ResourceProviderStorage;
-import 
org.apache.sling.resourceresolver.impl.providers.stateful.AbstractIterator;
 import 
org.apache.sling.resourceresolver.impl.providers.stateful.ResourceProviderAuthenticator;
 import 
org.apache.sling.resourceresolver.impl.providers.stateful.StatefulResourceProvider;
 import org.apache.sling.resourceresolver.impl.providers.tree.Node;
@@ -268,7 +264,7 @@ public class ResourceResolverContext {
                 pathBuilder.append(name);
                 final String childPath = pathBuilder.toString();
                 if (handler == null) {
-                    syntheticList.add(new SyntheticResource(resolver, 
childPath, RESOURCE_TYPE_SYNTHETIC));
+                    syntheticList.add(new SyntheticResource(resolver, 
childPath, ResourceProvider.RESOURCE_TYPE_SYNTHETIC));
                 } else {
                     Resource rsrc = null;
                     try {
@@ -282,7 +278,7 @@ public class ResourceResolverContext {
                         // if there is a child provider underneath, we need to 
create a synthetic resource
                         // otherwise we need to make sure that no one else is 
providing this child
                         if ( entry.getValue().getChildren().isEmpty() ) {
-                            syntheticList.add(new SyntheticResource(resolver, 
childPath, RESOURCE_TYPE_SYNTHETIC));
+                            syntheticList.add(new SyntheticResource(resolver, 
childPath, ResourceProvider.RESOURCE_TYPE_SYNTHETIC));
                         } else {
                             visitedNames.add(name);
                         }
@@ -299,7 +295,7 @@ public class ResourceResolverContext {
         if ( chain.size() == 0 ) {
             return Collections.EMPTY_LIST.iterator();
         }
-        return new UniqueIterator(visitedNames, chain);
+        return new UniqueResourceIterator(visitedNames, chain);
     }
 
     /**
@@ -352,7 +348,7 @@ public class ResourceResolverContext {
         } catch (LoginException le) {
             // ignore and throw (see below)
         }
-        throw new UnsupportedOperationException("create '" + getName(path) + 
"' at " + ResourceUtil.getParent(path));
+        throw new UnsupportedOperationException("create '" + 
ResourceUtil.getName(path) + "' at " + ResourceUtil.getParent(path));
     }
 
     /**
@@ -633,68 +629,6 @@ public class ResourceResolverContext {
         return null;
     }
 
-    private static class ChainedIterator<T> extends AbstractIterator<T> {
-
-        private final Iterator<Iterator<T>> iterators;
-
-        private Iterator<T> currentIterator;
-
-        public ChainedIterator(Iterator<Iterator<T>> iterators) {
-            this.iterators = iterators;
-        }
-
-        @Override
-        protected T seek() {
-            while (true) {
-                if (currentIterator == null) {
-                    if (!iterators.hasNext()) {
-                        return null;
-                    }
-                    currentIterator = iterators.next();
-                    continue;
-                }
-                if (currentIterator.hasNext()) {
-                    return currentIterator.next();
-                } else {
-                    currentIterator = null;
-                }
-            }
-        }
-    }
-
-    /**
-     * This iterator removes duplicated Resource entries. Regular resources
-     * overrides the synthetic ones.
-     */
-    private static class UniqueIterator extends AbstractIterator<Resource> {
-
-        private final Iterator<Resource> input;
-
-        private final Set<String> visited;
-
-        public UniqueIterator(final Set<String> visited, final 
Iterator<Resource> input) {
-            this.input = input;
-            this.visited = visited;
-        }
-
-        @Override
-        protected Resource seek() {
-            while (input.hasNext()) {
-                final Resource next = input.next();
-                final String name = next.getName();
-
-                if (visited.contains(name)) {
-                    continue;
-                } else {
-                    visited.add(name);
-                    
next.getResourceMetadata().setResolutionPath(next.getPath());
-                    return next;
-                }
-            }
-
-            return null;
-        }
-    }
 
     /**
      * Close all dynamic resource providers.

Added: 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/UniqueResourceIterator.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/UniqueResourceIterator.java?rev=1728202&view=auto
==============================================================================
--- 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/UniqueResourceIterator.java
 (added)
+++ 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/UniqueResourceIterator.java
 Tue Feb  2 20:17:01 2016
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.resourceresolver.impl.helper;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.sling.api.resource.Resource;
+
+/**
+ * This iterator removes duplicated Resource entries. Regular resources
+ * overrides the synthetic ones.
+ */
+public class UniqueResourceIterator extends AbstractIterator<Resource> {
+
+    private final Iterator<Resource> input;
+
+    private final Set<String> visited;
+
+    public UniqueResourceIterator(final Set<String> visited, final 
Iterator<Resource> input) {
+        this.input = input;
+        this.visited = visited;
+    }
+
+    @Override
+    protected Resource seek() {
+        while (input.hasNext()) {
+            final Resource next = input.next();
+            final String name = next.getName();
+
+            if (visited.contains(name)) {
+                continue;
+            } else {
+                visited.add(name);
+                next.getResourceMetadata().setResolutionPath(next.getPath());
+                return next;
+            }
+        }
+
+        return null;
+    }
+}
+

Propchange: 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/UniqueResourceIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/UniqueResourceIterator.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Modified: 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/SecureResourceProviderDecorator.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/SecureResourceProviderDecorator.java?rev=1728202&r1=1728201&r2=1728202&view=diff
==============================================================================
--- 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/SecureResourceProviderDecorator.java
 (original)
+++ 
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/SecureResourceProviderDecorator.java
 Tue Feb  2 20:17:01 2016
@@ -29,6 +29,7 @@ import org.apache.sling.api.resource.Res
 import org.apache.sling.api.security.ResourceAccessSecurity;
 import org.apache.sling.resourceresolver.impl.ResourceAccessSecurityTracker;
 import org.apache.sling.resourceresolver.impl.ResourceResolverImpl;
+import org.apache.sling.resourceresolver.impl.helper.AbstractIterator;
 import org.apache.sling.spi.resource.provider.ResolverContext;
 import org.apache.sling.spi.resource.provider.ResourceProvider;
 import org.slf4j.Logger;


Reply via email to