cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject cxf git commit: [CXF-6819]:ConfigurationImp returns wrong value for isRegistered(Object obj)
Date Fri, 04 Mar 2016 08:55:48 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes f746b982a -> d016544ff


[CXF-6819]:ConfigurationImp returns wrong value for isRegistered(Object obj)


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/d016544f
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/d016544f
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/d016544f

Branch: refs/heads/3.1.x-fixes
Commit: d016544ffa6ddb63d9ff55c22c375461ff5323e2
Parents: f746b98
Author: Jim Ma <ema@apache.org>
Authored: Fri Mar 4 16:55:10 2016 +0800
Committer: Jim Ma <ema@apache.org>
Committed: Fri Mar 4 16:55:29 2016 +0800

----------------------------------------------------------------------
 .../org/apache/cxf/jaxrs/impl/ConfigurationImpl.java   | 13 +++++++++++--
 .../apache/cxf/jaxrs/impl/ConfigurationImplTest.java   |  1 +
 2 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/d016544f/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java
index 57b65c8..f1dfdce 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java
@@ -141,7 +141,12 @@ public class ConfigurationImpl implements Configuration {
 
     @Override
     public boolean isRegistered(Object obj) {
-        return isRegistered(obj.getClass());
+        for (Object o : getInstances()) {
+            if (o.equals(obj)) {
+                return true;
+            }
+        }
+        return false;
     }
 
     @Override
@@ -171,8 +176,12 @@ public class ConfigurationImpl implements Configuration {
         register(provider, initContractsMap(bindingPriority, contracts));
     }
     
-    public boolean register(Object provider, Map<Class<?>, Integer> contracts)
{
+    public boolean register(Object provider, Map<Class<?>, Integer> contracts)
{        
         if (provider.getClass() == Class.class) {
+            if (isRegistered((Class<?>)provider)) {
+                LOG.warning("Provider class " + ((Class<?>)provider).getName() + "
has already been registered");
+                return false;
+            }
             provider = createProvider((Class<?>)provider);
         }
         if (isRegistered(provider)) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/d016544f/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ConfigurationImplTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ConfigurationImplTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ConfigurationImplTest.java
index b5dbd6c..5363d16 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ConfigurationImplTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ConfigurationImplTest.java
@@ -39,6 +39,7 @@ public class ConfigurationImplTest extends Assert {
         assertTrue(c.register(filter, 
                    Collections.<Class<?>, Integer>singletonMap(ContainerResponseFilter.class,
1000)));
         assertTrue(c.isRegistered(filter));
+        assertFalse(c.isRegistered(new ContainerResponseFilterImpl()));
         assertTrue(c.isRegistered(ContainerResponseFilterImpl.class));
         assertFalse(c.isRegistered(ContainerResponseFilter.class));
         assertFalse(c.register(filter, 


Mime
View raw message