Quantcast

WebResource and type method

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

WebResource and type method

Alexandre Bertails-2-2
Hi all,

I have a problem with jersey-client 1.0.3.

This code is ok :

WebResource wr = ...
wr.path("/path").type(MediaType.MULTIPART_FORM_DATA_TYPE).post(ClientResponse.class,
form);

But this one is not :

WebResource wr = ...
wr.path("/path").type(MediaType.MULTIPART_FORM_DATA_TYPE)
wr.post(ClientResponse.class, form);

The javadoc for the type method is "Set the media type" but it is not
the case as internally, it instantiates a new object.

Ok the return type is not a WebResource but the interfaces are the
same. So it's too easy to fall into the trap...

Is it possible to be clearer and eventually change the documentation ?

Alexandre.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: WebResource and type method

Paul Sandoz
Administrator

On May 7, 2009, at 10:43 AM, Alexandre Bertails wrote:

> Hi all,
>
> I have a problem with jersey-client 1.0.3.
>
> This code is ok :
>
> WebResource wr = ...
> wr.path("/
> path
> ").type(MediaType.MULTIPART_FORM_DATA_TYPE).post(ClientResponse.class,
> form);
>
> But this one is not :
>
> WebResource wr = ...
> wr.path("/path").type(MediaType.MULTIPART_FORM_DATA_TYPE)
> wr.post(ClientResponse.class, form);
>

You need to do the following:

   WebResource wr = ...
   WebResource.Builder wrb = wr.path("/
path").type(MediaType.MULTIPART_FORM_DATA_TYPE);
   wrb.post(ClientResponse.class, form);

WebResource is immutable, state for a request is modified on the  
builder returned.

A call to wr.path("/path") returns a new WebResource instance.


> The javadoc for the type method is "Set the media type" but it is not
> the case as internally, it instantiates a new object.
>

> Ok the return type is not a WebResource but the interfaces are the
> same. So it's too easy to fall into the trap...
>

Yes, RequestBuilder s a generic interface that is reused be the class  
that initiates building and the builder returned by the initiator.


> Is it possible to be clearer and eventually change the documentation ?
>


Sure, can you log a bug?

I think we can override the JavaDoc for the RequestBuilder methods  
implemented by WebResource.

Paul.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: WebResource and type method

Alexandre Bertails-2
> I think we can override the JavaDoc for the RequestBuilder methods
> implemented by WebResource.

I think it should be sufficient.

Alexandre.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: WebResource and type method

Paul Sandoz
Administrator

On May 7, 2009, at 11:22 AM, Alexandre Bertails wrote:

>> I think we can override the JavaDoc for the RequestBuilder methods
>> implemented by WebResource.
>
> I think it should be sufficient.
>

Could you log an issue so i do not forget about it?

Thanks,
Paul.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...