cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1563203 - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
Date Fri, 31 Jan 2014 18:33:07 GMT
Author: sergeyb
Date: Fri Jan 31 18:33:06 2014
New Revision: 1563203

URL: http://svn.apache.org/r1563203
Log:
Merged revisions 1563197-1563198 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1563197 | sergeyb | 2014-01-31 18:18:17 +0000 (Fri, 31 Jan 2014) | 1 line
  
  [CXF-5348] Fix to get complex typed mappers correctly selected
........
  r1563198 | sergeyb | 2014-01-31 18:24:34 +0000 (Fri, 31 Jan 2014) | 1 line
  
  [CXF-5348] Preventing NPE
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1563197-1563198

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=1563203&r1=1563202&r2=1563203&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
Fri Jan 31 18:33:06 2014
@@ -1304,9 +1304,13 @@ public final class ProviderFactory {
         }
         if (expectedClass != null) {
             Type genericSuperType = cls.getGenericSuperclass();
-            if (genericSuperType instanceof ParameterizedType       
-                && expectedClass == InjectionUtils.getActualType(genericSuperType))
{
-                return new Type[]{genericSuperType};
+            if (genericSuperType instanceof ParameterizedType) {       
+                Class<?> actualType = InjectionUtils.getActualType(genericSuperType);
+                if (expectedClass == actualType) {
+                    return new Type[]{genericSuperType};
+                } else if (actualType != null && expectedClass.isAssignableFrom(actualType))
{
+                    return new Type[]{};    
+                }
             }
         }
         Type[] types = cls.getGenericInterfaces();

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java?rev=1563203&r1=1563202&r2=1563203&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
Fri Jan 31 18:33:06 2014
@@ -42,6 +42,7 @@ import javax.ws.rs.WebApplicationExcepti
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
 import javax.ws.rs.core.UriInfo;
 import javax.ws.rs.ext.ContextResolver;
 import javax.ws.rs.ext.ExceptionMapper;
@@ -507,6 +508,17 @@ public class ProviderFactoryTest extends
                        "application/json");
     }
     
+    @Test
+    public void testComplexExceptionMapper() {
+        ProviderFactory pf = ProviderFactory.getInstance();
+        pf.registerUserProvider(new SecurityExceptionMapper());
+        ExceptionMapper<SecurityException> mapper = 
+            pf.createExceptionMapper(SecurityException.class, new MessageImpl());
+        assertTrue(mapper instanceof SecurityExceptionMapper);
+        ExceptionMapper<Throwable> mapper2 = 
+            pf.createExceptionMapper(Throwable.class, new MessageImpl());
+        assertNull(mapper2);
+    }
     
     @Test
     public void testRegisterCustomResolver() throws Exception {
@@ -947,4 +959,14 @@ public class ProviderFactoryTest extends
     public static class AClass {
     }
     
+    private static class SecurityExceptionMapper 
+        extends AbstractBadRequestExceptionMapper<SecurityException> {
+    }
+    private abstract static class AbstractBadRequestExceptionMapper<T extends Throwable>

+        implements ExceptionMapper<T> {
+        @Override
+        public Response toResponse(T exception) {
+            return Response.status(Status.BAD_REQUEST).entity(exception.getMessage()).build();
+        }
+    }
 }



Mime
View raw message