You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Nikolay Aleksiev <ni...@alexiev.net> on 2012/03/07 20:12:14 UTC

Possible bug in ClientProxyImpl

Hello,

I have the following service (ContentManager):

     @WebMethod
     @GET
     @Path("/list/{contentType}/{id}")
     @Secured("ROLE_RESTCLIENT")
     public Contents browse(@PathParam("id") String idVal, 
@PathParam("contentType") RequestContentType contentTypeVal,
             @QueryParam("page") @DefaultValue("0") String page, 
@QueryParam("size") @DefaultValue("10") String size,
             @QueryParam("dateFrom") @DefaultValue("0") String dateFrom,
             @QueryParam("dateTo") @DefaultValue("0") String dateTo,
             @QueryParam("free") @DefaultValue("false") Boolean 
freeFilter) throws WSException;

Note the @Path annotation and the arguments order!

I try to perform the following code:

protected <T> T getAuthenticatedProxy(Class<T> clazz) {
         T proxy = JAXRSClientFactory.create(BASE_URL, clazz);
         WebClient.client(proxy).cookie(Cookie.valueOf(sessionCookie));

         return proxy;
}
....

Contents list = getAuthenticatedProxy(ContentManager.class).browse(
                 parts[parts.length - 1],
                 RequestContentType.vod,
                 "0",
                 Integer.MAX_VALUE + "",
                 null,
                 "",
                 false);
...

What happens is that the URL Path parameters are send in wrong order 
(ContentType and Id). Since ContentType is an Enum I get 
"IllegalArgumentException: No enum const".
Here is the server wrong part of the inbound message: 
/list/*1*/*text*?page=0&size=2147483647&dateTo&free=false

I tried to debug the ClientProxy and what I see is that 
/*getPathParamValues*/ returns the parameters in the order like in the 
method signature (id, contentType). After that the URIBuilder is not 
reordering according to param names. I don't know who should handle the 
ordering, the UriBuilder or inside the getPathParamValues, but obviously 
there's something wrong.
If I'm doing the call in some strange manner, please let me know how to 
fix it.

Tested with CXF 2.4.3.

Best regards,
Nikolay

Re: Possible bug in ClientProxyImpl

Posted by Sergey Beryozkin <sb...@gmail.com>.
See
https://issues.apache.org/jira/browse/CXF-4177

Cheers, Sergey

On 08/03/12 11:51, Sergey Beryozkin wrote:
> Hi-
>
> Yes, it's a bug within ClientProxyImpl, it needs to ensure the ordering
> matches the expectations of UriBuilder...
> Will look into it soon
>
> Sergey
>
> On 07/03/12 19:12, Nikolay Aleksiev wrote:
>> Hello,
>>
>> I have the following service (ContentManager):
>>
>> @WebMethod
>> @GET
>> @Path("/list/{contentType}/{id}")
>> @Secured("ROLE_RESTCLIENT")
>> public Contents browse(@PathParam("id") String idVal,
>> @PathParam("contentType") RequestContentType contentTypeVal,
>> @QueryParam("page") @DefaultValue("0") String page, @QueryParam("size")
>> @DefaultValue("10") String size,
>> @QueryParam("dateFrom") @DefaultValue("0") String dateFrom,
>> @QueryParam("dateTo") @DefaultValue("0") String dateTo,
>> @QueryParam("free") @DefaultValue("false") Boolean freeFilter) throws
>> WSException;
>>
>> Note the @Path annotation and the arguments order!
>>
>> I try to perform the following code:
>>
>> protected <T> T getAuthenticatedProxy(Class<T> clazz) {
>> T proxy = JAXRSClientFactory.create(BASE_URL, clazz);
>> WebClient.client(proxy).cookie(Cookie.valueOf(sessionCookie));
>>
>> return proxy;
>> }
>> ....
>>
>> Contents list = getAuthenticatedProxy(ContentManager.class).browse(
>> parts[parts.length - 1],
>> RequestContentType.vod,
>> "0",
>> Integer.MAX_VALUE + "",
>> null,
>> "",
>> false);
>> ...
>>
>> What happens is that the URL Path parameters are send in wrong order
>> (ContentType and Id). Since ContentType is an Enum I get
>> "IllegalArgumentException: No enum const".
>> Here is the server wrong part of the inbound message:
>> /list/*1*/*text*?page=0&size=2147483647&dateTo&free=false
>>
>> I tried to debug the ClientProxy and what I see is that
>> /*getPathParamValues*/ returns the parameters in the order like in the
>> method signature (id, contentType). After that the URIBuilder is not
>> reordering according to param names. I don't know who should handle the
>> ordering, the UriBuilder or inside the getPathParamValues, but obviously
>> there's something wrong.
>> If I'm doing the call in some strange manner, please let me know how to
>> fix it.
>>
>> Tested with CXF 2.4.3.
>>
>> Best regards,
>> Nikolay
>>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: Possible bug in ClientProxyImpl

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi-

Yes, it's a bug within ClientProxyImpl, it needs to ensure the ordering 
matches the expectations of UriBuilder...
Will look into it soon

Sergey

On 07/03/12 19:12, Nikolay Aleksiev wrote:
> Hello,
>
> I have the following service (ContentManager):
>
> @WebMethod
> @GET
> @Path("/list/{contentType}/{id}")
> @Secured("ROLE_RESTCLIENT")
> public Contents browse(@PathParam("id") String idVal,
> @PathParam("contentType") RequestContentType contentTypeVal,
> @QueryParam("page") @DefaultValue("0") String page, @QueryParam("size")
> @DefaultValue("10") String size,
> @QueryParam("dateFrom") @DefaultValue("0") String dateFrom,
> @QueryParam("dateTo") @DefaultValue("0") String dateTo,
> @QueryParam("free") @DefaultValue("false") Boolean freeFilter) throws
> WSException;
>
> Note the @Path annotation and the arguments order!
>
> I try to perform the following code:
>
> protected <T> T getAuthenticatedProxy(Class<T> clazz) {
> T proxy = JAXRSClientFactory.create(BASE_URL, clazz);
> WebClient.client(proxy).cookie(Cookie.valueOf(sessionCookie));
>
> return proxy;
> }
> ....
>
> Contents list = getAuthenticatedProxy(ContentManager.class).browse(
> parts[parts.length - 1],
> RequestContentType.vod,
> "0",
> Integer.MAX_VALUE + "",
> null,
> "",
> false);
> ...
>
> What happens is that the URL Path parameters are send in wrong order
> (ContentType and Id). Since ContentType is an Enum I get
> "IllegalArgumentException: No enum const".
> Here is the server wrong part of the inbound message:
> /list/*1*/*text*?page=0&size=2147483647&dateTo&free=false
>
> I tried to debug the ClientProxy and what I see is that
> /*getPathParamValues*/ returns the parameters in the order like in the
> method signature (id, contentType). After that the URIBuilder is not
> reordering according to param names. I don't know who should handle the
> ordering, the UriBuilder or inside the getPathParamValues, but obviously
> there's something wrong.
> If I'm doing the call in some strange manner, please let me know how to
> fix it.
>
> Tested with CXF 2.4.3.
>
> Best regards,
> Nikolay
>