cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-6015] Excluding header and cokkie params from being url auto-encoded
Date Tue, 07 Oct 2014 11:54:13 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 4c509a532 -> 3762de320


[CXF-6015] Excluding header and cokkie params from being url auto-encoded


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

Branch: refs/heads/2.7.x-fixes
Commit: 3762de3200f988541c0b0964bed7b816487d531d
Parents: 4c509a5
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Tue Oct 7 12:00:22 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Tue Oct 7 12:53:47 2014 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java   | 7 ++++++-
 .../src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java | 6 +++++-
 .../apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java   | 6 +++---
 3 files changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/3762de32/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
index c6b8e14..7725355 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
@@ -25,6 +25,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.logging.Logger;
 
+import javax.ws.rs.CookieParam;
+import javax.ws.rs.HeaderParam;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.ParamConverter;
 import javax.ws.rs.ext.ParamConverterProvider;
@@ -44,6 +46,7 @@ import org.apache.cxf.jaxrs.JAXRSServiceImpl;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.jaxrs.utils.AnnotationUtils;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.factory.FactoryBeanListener;
 
@@ -384,7 +387,9 @@ public class JAXRSClientFactoryBean extends AbstractJAXRSFactoryBean {
                 @Override
                 public <T> ParamConverter<T> getConverter(Class<T> cls,
                     Type t, Annotation[] anns) {
-                    if (cls == String.class) {
+                    if (cls == String.class
+                        && AnnotationUtils.getAnnotation(anns, HeaderParam.class)
== null
+                        && AnnotationUtils.getAnnotation(anns, CookieParam.class)
== null) {
                         return (ParamConverter<T>)new UrlEncodingParamConverter(encodeClientParametersList);
                     } else {
                         return null;

http://git-wip-us.apache.org/repos/asf/cxf/blob/3762de32/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
index 78a1e51..e794383 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
@@ -872,7 +872,11 @@ public class BookStore {
     @GET
     @Path("/thebooks/{bookId}/")
     @Produces("application/xml")
-    public Book getBookWithSemicolon(@Encoded @PathParam("bookId") String id) {
+    public Book getBookWithSemicolon(@Encoded @PathParam("bookId") String id,
+                                     @HeaderParam("customheader") String custom) {
+        if (!"custom;:header".equals(custom)) {
+            throw new RuntimeException();
+        }
         Book b = new Book();
         b.setId(Long.valueOf(id.substring(0, 3)));
         b.setName("CXF in Action" + id.substring(3));

http://git-wip-us.apache.org/repos/asf/cxf/blob/3762de32/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
index 9d3adf6..596e904 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
@@ -688,7 +688,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
         bean.setAddress("http://localhost:" + PORT);
         bean.setProperties(Collections.<String, Object>singletonMap("url.encode.client.parameters",
Boolean.TRUE));
         BookStore store = bean.create(BookStore.class);
-        Book book = store.getBookWithSemicolon("123;:");
+        Book book = store.getBookWithSemicolon("123;:", "custom;:header");
         assertEquals(123L, book.getId());
         assertEquals("CXF in Action%3B%3A", book.getName());
     }
@@ -701,7 +701,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
         bean.getProperties(true).put("url.encode.client.parameters", "true");
         bean.getProperties(true).put("url.encode.client.parameters.list", ";");
         BookStore store = bean.create(BookStore.class);
-        Book book = store.getBookWithSemicolon("123;:");
+        Book book = store.getBookWithSemicolon("123;:", "custom;:header");
         assertEquals(123L, book.getId());
         assertEquals("CXF in Action%3B:", book.getName());
     }
@@ -710,7 +710,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     public void testBookWithSpaceProxyNonEncodedSemicolon() throws Exception {
         BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT,
                                                     BookStore.class);
-        Book book = store.getBookWithSemicolon("123;");
+        Book book = store.getBookWithSemicolon("123;", "custom;:header");
         assertEquals(123L, book.getId());
         assertEquals("CXF in Action;", book.getName());
     }


Mime
View raw message