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:53:45 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes d8fe2619f -> 450788a57


[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/450788a5
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/450788a5
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/450788a5

Branch: refs/heads/3.0.x-fixes
Commit: 450788a57e214df356613fe7b749b92fc35d5160
Parents: d8fe261
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:53:26 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/450788a5/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/450788a5/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/450788a5/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 104f2f6..63b1b19 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
@@ -182,6 +182,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