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 10:01:58 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes a43da7591 -> 4e070f41d


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

Branch: refs/heads/3.0.x-fixes
Commit: 4e070f41dd35bfc748c1b4565cf5b038fa36f2dc
Parents: a43da75
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 10:01:42 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/4e070f41/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 5cafd8c..5eba218 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
@@ -54,6 +54,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;
@@ -216,7 +217,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;
@@ -402,8 +410,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/4e070f41/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/4e070f41/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 5571952..2af1689 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
@@ -96,6 +96,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