Hi,
thanks for your response.
Should i open an issue for this?

Hartmut

2014-10-23 10:43 GMT+02:00 Sergey Beryozkin <[email protected]>:

> Hi
> On 23/10/14 08:41, Hartmut Lang wrote:
>
>> Hi,
>>
>> my question is how i can reuse (or not) the WebTarget of a JaxRs Client
>> with CXF 3.0.2.
>>
>> My scenario is roughly like this:
>>
>> Init:
>> Client client = ClientBuilder.newBuilder().
>>                  register(JacksonJsonProvider.class).
>>                  build();
>> WebTarget target = client.target(baseUrl).path("
>> lights/{lightNum}/{state}");
>>
>>
>> Then i issue several (thousands) requests like this:
>>
>> Invocation.Builder builder = target.
>>                  resolveTemplate("lightNum", lightNum).
>>                  resolveTemplate("state", state).
>>                  request();
>> Response response = builder.put(null);
>> response.close();
>>
>> What i see is, that for every request a new WebClient-Object is created
>> and
>> added to
>> ClientImpl.baseClients-HashMap.
>> And finally i can run into OOM-issues.
>>
> Right, that was the quick implementation to support the Client.close()
> docs saying:
>
> "Calling this method effectively invalidates all resource targets produced
> by the client instance. Invoking any method on such targets once the client
> is closed would result in an IllegalStateException being thrown."
>
> To be honest the fact most of WebTarget methods create new WebTargets may
> indeed lead to some unexpected results, though in this case the bug is in
> the CXF code, i.e, I guess it has to be a WeakHashMap, I'll take care of it
> next week as I'm off shortly...
>
>>
>> My question:
>> - is it ok to reuse the WebTarget for several requests?
>>
>
> I guess for now it is better to reuse for a small number of requests
>
>  - if i close the client and create a new one, this solves this issue. Is
>> this the intended live-cycle of Client/WebTarget?
>>
>
> yes, this is my understanding.
>
> Thanks, Sergey
>
>>
>> Thanks,
>> Hartmut
>>
>>
>

Reply via email to