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-6754] Applying a patch from Neal Hu with minor modifications
Date Tue, 26 Jan 2016 09:59:21 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 5638cae66 -> b490940ac


[CXF-6754] Applying a patch from Neal Hu with minor modifications


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

Branch: refs/heads/master
Commit: b490940ac0f3d959382336500171e21c31bd2334
Parents: 5638cae
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue Jan 26 09:59:02 2016 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Tue Jan 26 09:59:02 2016 +0000

----------------------------------------------------------------------
 .../cxf/jaxrs/interceptor/JAXRSOutInterceptor.java    | 14 +++++++++++---
 .../org/apache/cxf/systest/jaxrs/BookStoreSpring.java |  6 ++++++
 .../jaxrs/JAXRSClientServerSpringBookTest.java        |  8 ++++++++
 3 files changed, 25 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/b490940a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
index 634d07a..9506f8d 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
@@ -55,6 +55,7 @@ import org.apache.cxf.jaxrs.impl.WriterInterceptorMBW;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider;
 import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
+import org.apache.cxf.jaxrs.utils.AnnotationUtils;
 import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
@@ -217,7 +218,14 @@ public class JAXRSOutInterceptor extends AbstractOutDatabindingInterceptor
{
             return;
         }
         try {
-            responseMediaType = checkFinalContentType(responseMediaType, writers);
+            boolean checkWriters = false;
+            if (responseMediaType.isWildcardSubtype()) {
+                Produces pM = AnnotationUtils.getMethodAnnotation(ori == null ? null : ori.getAnnotatedMethod(),

+                                                                              Produces.class);
+                Produces pC = AnnotationUtils.getClassAnnotation(serviceCls, Produces.class);
+                checkWriters = pM == null && pC == null;
+            }
+            responseMediaType = checkFinalContentType(responseMediaType, writers, checkWriters);
         } catch (Throwable ex) {
             handleWriteException(providerFactory, message, ex, firstTry);
             return;
@@ -403,8 +411,8 @@ public class JAXRSOutInterceptor extends AbstractOutDatabindingInterceptor
{
     }
     
     
-    private MediaType checkFinalContentType(MediaType mt, List<WriterInterceptor> writers)
{
-        if (mt.isWildcardSubtype()) {
+    private MediaType checkFinalContentType(MediaType mt, List<WriterInterceptor> writers,
boolean checkWriters) {
+        if (checkWriters) {
             int mbwIndex = writers.size() == 1 ? 0 : writers.size() - 1;
             MessageBodyWriter<Object> writer = ((WriterInterceptorMBW)writers.get(mbwIndex)).getMBW();
             Produces pm = writer.getClass().getAnnotation(Produces.class);

http://git-wip-us.apache.org/repos/asf/cxf/blob/b490940a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
index a367733..f47068a 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
@@ -146,6 +146,12 @@ public class BookStoreSpring {
     public Book getBookXsiType() {
         return new SuperBook("SuperBook", 999L, true);
     }
+    @GET
+    @Path("/books/text")
+    @Produces("text/*")
+    public String getBookText() {
+        return "SuperBook";
+    }
     
     @SuppressWarnings("unchecked")
     @GET

http://git-wip-us.apache.org/repos/asf/cxf/blob/b490940a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
index eb515d7..f15c640 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
@@ -97,6 +97,14 @@ public class JAXRSClientServerSpringBookTest extends AbstractBusClientServerTest
     }
     
     @Test
+    public void testGetBookText() throws Exception {
+        final String address = "http://localhost:" + PORT + "/the/thebooks/bookstore/books/text";

+        WebClient wc = WebClient.create(address).accept("text/*");
+        assertEquals(406, wc.get().getStatus());
+        
+    }
+    
+    @Test
     public void testEchoBookForm() throws Exception {
         String address = "http://localhost:" + PORT + "/bus/thebooksform/bookform";
         WebClient wc = WebClient.create(address);


Mime
View raw message