You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by pa...@apache.org on 2018/01/10 16:44:44 UTC
[sling-org-apache-sling-resourceresolver] branch SLING-7371
updated: SLING-7371: synchronize access to the handlers inside
ResourceProviderTracker to avoid a ConcurrentModificationException.
This is an automated email from the ASF dual-hosted git repository.
pauls pushed a commit to branch SLING-7371
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
The following commit(s) were added to refs/heads/SLING-7371 by this push:
new ca9bf3a SLING-7371: synchronize access to the handlers inside ResourceProviderTracker to avoid a ConcurrentModificationException.
ca9bf3a is described below
commit ca9bf3a48bd4bd7ccb44dd5b98b734580e0ce62d
Author: Karl Pauls <ka...@gmail.com>
AuthorDate: Wed Jan 10 17:44:32 2018 +0100
SLING-7371: synchronize access to the handlers inside ResourceProviderTracker to avoid a ConcurrentModificationException.
---
.../impl/providers/ResourceProviderTracker.java | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/providers/ResourceProviderTracker.java b/src/main/java/org/apache/sling/resourceresolver/impl/providers/ResourceProviderTracker.java
index 2b04a64..85cc1c3 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/providers/ResourceProviderTracker.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/providers/ResourceProviderTracker.java
@@ -349,7 +349,9 @@ public class ResourceProviderTracker implements ResourceProviderStorageProvider
* @param handler The provider handler
*/
private boolean activate(final ResourceProviderHandler handler) {
- updateProviderContext(handler);
+ synchronized (this.handlers) {
+ updateProviderContext(handler);
+ }
if ( !handler.activate() ) {
logger.warn("Activating resource provider {} failed", handler.getInfo());
this.invalidProviders.put(handler.getInfo(), FailureReason.service_not_gettable);
@@ -481,13 +483,13 @@ public class ResourceProviderTracker implements ResourceProviderStorageProvider
private void updateProviderContext(final ResourceProviderHandler handler) {
final Set<String> excludedPaths = new HashSet<>();
final Path handlerPath = new Path(handler.getPath());
- synchronized (handlers) {
- for(final String otherPath : handlers.keySet()) {
- if ( !handler.getPath().equals(otherPath) && handlerPath.matches(otherPath) ) {
- excludedPaths.add(otherPath);
- }
+
+ for(final String otherPath : handlers.keySet()) {
+ if ( !handler.getPath().equals(otherPath) && handlerPath.matches(otherPath) ) {
+ excludedPaths.add(otherPath);
}
}
+
final PathSet excludedPathSet = PathSet.fromStringCollection(excludedPaths);
handler.getProviderContext().update(
reporterGenerator.create(handlerPath, excludedPathSet),
--
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].