cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6297] Avoiding NPE if a subresource method was invoked
Date Wed, 18 Mar 2015 17:52:41 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 26e8350e1 -> 3c056d9f8


[CXF-6297] Avoiding NPE if a subresource method was invoked


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

Branch: refs/heads/master
Commit: 3c056d9f8a5324ecc9de46e687436937c03b2f46
Parents: 26e8350
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Mar 18 17:52:23 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Wed Mar 18 17:52:23 2015 +0000

----------------------------------------------------------------------
 .../org/apache/cxf/jaxrs/validation/ValidationUtils.java    | 3 +++
 .../systest/jaxrs/validation/BookStoreWithValidation.java   | 5 +++++
 .../jaxrs/validation/JAXRSClientServerValidationTest.java   | 9 +++++++++
 3 files changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/3c056d9f/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/ValidationUtils.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/ValidationUtils.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/ValidationUtils.java
index 18fa7c5..5bc108f 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/ValidationUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/ValidationUtils.java
@@ -35,6 +35,9 @@ public final class ValidationUtils {
         if (ori == null) {
             return null;
         }
+        if (!ori.getClassResourceInfo().isRoot()) {
+            return message.getExchange().get("org.apache.cxf.service.object.last");
+        }
         final ResourceProvider resourceProvider = ori.getClassResourceInfo().getResourceProvider();
         if (!resourceProvider.isSingleton()) {
             String error = "Service object is not a singleton, use a custom invoker to validate";

http://git-wip-us.apache.org/repos/asf/cxf/blob/3c056d9f/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/validation/BookStoreWithValidation.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/validation/BookStoreWithValidation.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/validation/BookStoreWithValidation.java
index e8bb68e..7b6d463 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/validation/BookStoreWithValidation.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/validation/BookStoreWithValidation.java
@@ -67,6 +67,11 @@ public class BookStoreWithValidation extends AbstractBookStoreWithValidation
imp
         return Response.ok(books.get(id)).build();
     }
     
+    @Path("/sub")
+    public BookStoreWithValidation getBookResponseSub() {
+        return this;
+    }
+    
     @POST
     @Path("/books")
     public Response addBook(@Context final UriInfo uriInfo, 

http://git-wip-us.apache.org/repos/asf/cxf/blob/3c056d9f/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/validation/JAXRSClientServerValidationTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/validation/JAXRSClientServerValidationTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/validation/JAXRSClientServerValidationTest.java
index 507f4c4..08d6bae 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/validation/JAXRSClientServerValidationTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/validation/JAXRSClientServerValidationTest.java
@@ -181,6 +181,15 @@ public class JAXRSClientServerValidationTest extends AbstractJAXRSValidationTest
     }
     
     @Test
+    public void testThatResponseValidationForOneBookSubNotFails()  {
+        Response r = createWebClient("/bookstore/books").post(new Form().param("id", "1234").param("name",
"cxf"));
+        assertEquals(Status.CREATED.getStatusCode(), r.getStatus());
+
+        r = createWebClient("/bookstore/sub/books/1234").get();
+        assertEquals(200, r.getStatus());
+    }
+    
+    @Test
     public void testThatResponseValidationForNullBookFails()  {
         Response r = createWebClient("/bookstore/books").post(new Form().param("id", "1234").param("name",
"cxf"));
         assertEquals(Status.CREATED.getStatusCode(), r.getStatus());


Mime
View raw message