You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by cs...@apache.org on 2018/08/09 16:12:21 UTC

[1/2] aries-jax-rs-whiteboard git commit: Avoid concurrent modification exception

Repository: aries-jax-rs-whiteboard
Updated Branches:
  refs/heads/master 7ceb8f191 -> 9f7ecf18c


Avoid concurrent modification exception


Project: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/commit/dc976c14
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/dc976c14
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/dc976c14

Branch: refs/heads/master
Commit: dc976c14ad0a646d8551038606dc3d2cd6a3a046
Parents: 7ceb8f1
Author: Carlos Sierra <cs...@apache.org>
Authored: Thu Aug 9 17:37:38 2018 +0200
Committer: Carlos Sierra <cs...@apache.org>
Committed: Thu Aug 9 17:42:58 2018 +0200

----------------------------------------------------------------------
 .../whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java  | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/dc976c14/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
index 54cb945..b6a5687 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
@@ -77,7 +77,7 @@ public class CxfJaxrsServiceRegistrator {
         rewire();
     }
 
-    public void add(ResourceProvider resourceProvider) {
+    public synchronized void add(ResourceProvider resourceProvider) {
         if (_closed) {
             return;
         }
@@ -94,7 +94,7 @@ public class CxfJaxrsServiceRegistrator {
         }
     }
 
-    public void addProvider(ServiceTuple<?> tuple) {
+    public synchronized void addProvider(ServiceTuple<?> tuple) {
         if (_closed) {
             return;
         }
@@ -169,7 +169,7 @@ public class CxfJaxrsServiceRegistrator {
         return classes;
     }
 
-    public void remove(ResourceProvider resourceProvider) {
+    public synchronized void remove(ResourceProvider resourceProvider) {
         if (_closed) {
             return;
         }
@@ -179,7 +179,7 @@ public class CxfJaxrsServiceRegistrator {
         rewire();
     }
 
-    public void removeProvider(ServiceTuple<?> tuple) {
+    public synchronized void removeProvider(ServiceTuple<?> tuple) {
         if (_closed) {
             return;
         }


[2/2] aries-jax-rs-whiteboard git commit: Use (fixed) accumulate

Posted by cs...@apache.org.
Use (fixed) accumulate


Project: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/commit/9f7ecf18
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/9f7ecf18
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/9f7ecf18

Branch: refs/heads/master
Commit: 9f7ecf18c0e14cc4e5556a8430512eca98bc1663
Parents: dc976c1
Author: Carlos Sierra <cs...@apache.org>
Authored: Thu Aug 9 17:56:09 2018 +0200
Committer: Carlos Sierra <cs...@apache.org>
Committed: Thu Aug 9 17:56:09 2018 +0200

----------------------------------------------------------------------
 integrations/shiro/shiro-authc/pom.xml          |  2 +-
 .../impl/ShiroAuthenticationActivator.java      | 25 ++++----------------
 integrations/shiro/shiro-authz/pom.xml          |  2 +-
 jax-rs.whiteboard/pom.xml                       |  2 +-
 4 files changed, 8 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/9f7ecf18/integrations/shiro/shiro-authc/pom.xml
----------------------------------------------------------------------
diff --git a/integrations/shiro/shiro-authc/pom.xml b/integrations/shiro/shiro-authc/pom.xml
index 5ec42c4..6bb081c 100644
--- a/integrations/shiro/shiro-authc/pom.xml
+++ b/integrations/shiro/shiro-authc/pom.xml
@@ -36,7 +36,7 @@
 	    <dependency>
             <groupId>org.apache.aries.component-dsl</groupId>
             <artifactId>org.apache.aries.component-dsl.component-dsl</artifactId>
-            <version>1.2.0</version>
+            <version>1.2.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
 	    <dependency>

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/9f7ecf18/integrations/shiro/shiro-authc/src/main/java/org/apache/aries/jax/rs/shiro/authc/impl/ShiroAuthenticationActivator.java
----------------------------------------------------------------------
diff --git a/integrations/shiro/shiro-authc/src/main/java/org/apache/aries/jax/rs/shiro/authc/impl/ShiroAuthenticationActivator.java b/integrations/shiro/shiro-authc/src/main/java/org/apache/aries/jax/rs/shiro/authc/impl/ShiroAuthenticationActivator.java
index 8fde563..ad6f599 100644
--- a/integrations/shiro/shiro-authc/src/main/java/org/apache/aries/jax/rs/shiro/authc/impl/ShiroAuthenticationActivator.java
+++ b/integrations/shiro/shiro-authc/src/main/java/org/apache/aries/jax/rs/shiro/authc/impl/ShiroAuthenticationActivator.java
@@ -21,7 +21,9 @@ import static org.apache.aries.component.dsl.OSGi.coalesce;
 import static org.apache.aries.component.dsl.OSGi.configuration;
 import static org.apache.aries.component.dsl.OSGi.just;
 import static org.apache.aries.component.dsl.OSGi.register;
+import static org.apache.aries.component.dsl.OSGi.service;
 import static org.apache.aries.component.dsl.OSGi.serviceReferences;
+import static org.apache.aries.component.dsl.Utils.accumulate;
 import static org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_EXTENSION;
 
 import java.util.ArrayList;
@@ -37,6 +39,7 @@ import javax.ws.rs.core.Feature;
 import org.apache.aries.component.dsl.CachingServiceReference;
 import org.apache.aries.component.dsl.OSGi;
 import org.apache.aries.component.dsl.OSGiResult;
+import org.apache.aries.component.dsl.Utils;
 import org.apache.shiro.realm.Realm;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
@@ -51,12 +54,8 @@ public class ShiroAuthenticationActivator implements BundleActivator {
     
     private OSGiResult registration;
 
-    private BundleContext context;
-
     @Override
     public void start(BundleContext context) throws Exception {
-        
-        this.context = context;
         _LOG.debug("Starting the Shiro JAX-RS Authentication Feature");
         
         registration = coalesce(
@@ -101,27 +100,13 @@ public class ShiroAuthenticationActivator implements BundleActivator {
         
         Object filter = properties.get("realms.target");
         
-        ConcurrentSkipListMap<CachingServiceReference<Realm>, Realm> discovered = new ConcurrentSkipListMap<>();
-        
         OSGi<List<Realm>> realms;
         if(filter == null) {
             _LOG.debug("The Shiro JAX-RS Authentication Feature is accepting all realms");
-            realms = serviceReferences(Realm.class)
-                .effects(csr -> discovered.put(csr, context.getService(csr.getServiceReference())), 
-                        csr -> {
-                            discovered.remove(csr);
-                            context.ungetService(csr.getServiceReference());
-                        })
-                .map(x -> new ArrayList<>(discovered.values()));
+            realms = accumulate(service(serviceReferences(Realm.class)));
         } else {
             _LOG.debug("The Shiro JAX-RS Authentication Feature is filtering realms using the filter {}", filter);
-            realms = serviceReferences(Realm.class, String.valueOf(filter))
-                    .effects(csr -> discovered.put(csr, context.getService(csr.getServiceReference())), 
-                            csr -> {
-                                discovered.remove(csr);
-                                context.ungetService(csr.getServiceReference());
-                            })
-                    .map(x -> new ArrayList<>(discovered.values()));
+            realms = accumulate(service(serviceReferences(Realm.class, String.valueOf(filter))));
         }
         
         return realms.map(ShiroAuthenticationFeatureProvider::new)

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/9f7ecf18/integrations/shiro/shiro-authz/pom.xml
----------------------------------------------------------------------
diff --git a/integrations/shiro/shiro-authz/pom.xml b/integrations/shiro/shiro-authz/pom.xml
index 375350b..8ec97ab 100644
--- a/integrations/shiro/shiro-authz/pom.xml
+++ b/integrations/shiro/shiro-authz/pom.xml
@@ -36,7 +36,7 @@
 		<dependency>
             <groupId>org.apache.aries.component-dsl</groupId>
             <artifactId>org.apache.aries.component-dsl.component-dsl</artifactId>
-            <version>1.2.0</version>
+            <version>1.2.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
 	    <dependency>

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/9f7ecf18/jax-rs.whiteboard/pom.xml
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/pom.xml b/jax-rs.whiteboard/pom.xml
index 38826c9..369a2e9 100644
--- a/jax-rs.whiteboard/pom.xml
+++ b/jax-rs.whiteboard/pom.xml
@@ -31,7 +31,7 @@
         <dependency>
             <groupId>org.apache.aries.component-dsl</groupId>
             <artifactId>org.apache.aries.component-dsl.component-dsl</artifactId>
-            <version>1.2.0</version>
+            <version>1.2.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>