cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1175939 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Date Mon, 26 Sep 2011 16:29:52 GMT
Author: sergeyb
Date: Mon Sep 26 16:29:51 2011
New Revision: 1175939

URL: http://svn.apache.org/viewvc?rev=1175939&view=rev
Log:
[CXF-3822] Returning 406 in case of malformed Accept header values

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=1175939&r1=1175938&r2=1175939&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
Mon Sep 26 16:29:51 2011
@@ -131,7 +131,12 @@ public class JAXRSInInterceptor extends 
             acceptTypes = "*/*";
             message.put(Message.ACCEPT_CONTENT_TYPE, acceptTypes);
         }
-        List<MediaType> acceptContentTypes = JAXRSUtils.sortMediaTypes(acceptTypes);
+        List<MediaType> acceptContentTypes = null;
+        try {
+            JAXRSUtils.sortMediaTypes(acceptTypes);
+        } catch (IllegalArgumentException ex) {
+            throw new WebApplicationException(406);
+        }
         message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentTypes);
 
         MultivaluedMap<String, String> values = new MetadataMap<String, String>();

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1175939&r1=1175938&r2=1175939&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Mon Sep 26 16:29:51 2011
@@ -74,6 +74,15 @@ public class JAXRSClientServerBookTest e
     }
     
     @Test
+    public void testMalformedAcceptType() {
+        WebClient wc = 
+            WebClient.create("http://localhost:" + PORT + "/bookstore/books/123");
+        wc.accept("application");
+        Response r = wc.get();
+        assertEquals(406, r.getStatus());
+    }
+    
+    @Test
     public void testProxyWrongAddress() throws Exception {
         BookStore store = JAXRSClientFactory.create("http://localhost:8080/wrongaddress",

                                                     BookStore.class);



Mime
View raw message