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:00:57 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 9c053334d -> aa237f26f


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

Branch: refs/heads/master
Commit: aa237f26fcbc023240c79694e61d8dd2d0a34377
Parents: 9c05333
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:00:22 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/aa237f26/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
index 5fdd141..d41a76e 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
+++ b/rt/rs/client/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;
@@ -43,6 +45,7 @@ import org.apache.cxf.jaxrs.JAXRSServiceFactoryBean;
 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.utils.AnnotationUtils;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.factory.FactoryBeanListener;
 
@@ -384,7 +387,9 @@ public class JAXRSClientFactoryBean extends AbstractJAXRSFactoryBean {
                 @SuppressWarnings("unchecked")
                 @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/aa237f26/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 af45433..299afd8 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
@@ -931,7 +931,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/aa237f26/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 e51d515..d0f4b21 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
@@ -695,7 +695,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());
     }
@@ -708,7 +708,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());
     }
@@ -717,7 +717,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