Hi Sergey, Yep, you are right - reset() have to be in finally block. Just optimized exception processing blocks for simplicity.
Andrei. > -----Original Message----- > From: Sergey Beryozkin [mailto:[email protected]] > Sent: Donnerstag, 15. Juni 2017 10:37 > To: Andrei Shakirin > Subject: Re: Thread and memroy leak safety for WebClient initilized through > blueprint > > Hi Andrei > > Sorry :-), I did not spot a 'finally' block (to clean up in case of the > exceptions > too) and I missed you already coded it there, > > Thanks, Sergey > On 14/06/17 19:10, Andrei Shakirin wrote: > > Hi Sergey, > > > > Thanks a lot for response! > > myWebClient.reset() was in my initial code snippet :) > > > > Regards, > > Andrei. > > > > > >> -----Original Message----- > >> From: Sergey Beryozkin [mailto:[email protected]] > >> Sent: Dienstag, 13. Juni 2017 13:56 > >> To: [email protected]; Andrei Shakirin > >> Cc: Sergey Beryozkin > >> Subject: Re: Thread and memroy leak safety for WebClient initilized > >> through blueprint > >> > >> Hi Andrei > >> > >> I do expect such a builder-style code be thread safe, however if it > >> is very intensive then you might want to finalize the call with a > >> myWebClient.reset() which will clean the thread local state more > >> proactively, > >> > >> The client factor bean also has a timeToKeepState property but at the > >> moment this property is not available at the schema level but having > >> an explicit reset() would be the most effective option > >> > >> Thanks, Sergey > >> > >> > >> On 08/06/17 09:13, Andrei Shakirin wrote: > >>> Hi, > >>> > >>> Is that code thread and memory leak safe (by intensive multithread using): > >>> > >>> <jaxrs-client:client id="myWebClient" > >>> address="http://localhost/myservice" > >>> serviceClass="org.apache.cxf.jaxrs.client.WebClient" > >>> inheritHeaders="true" > >>> threadSafe="true"> > >>> > >>> <jaxrs-client:providers> > >>> <bean > >> class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider"/> > >>> </jaxrs-client:providers> > >>> > >>> <jaxrs-client:properties> > >>> <entry key="http.receive.timeout" value="60"/> > >>> </jaxrs-client:properties> </jaxrs-client:client> > >>> > >>> .... > >>> // injection on class level > >>> WebClient myWebClient; > >>> > >>> // concurrent using > >>> Response myResponse = > >> myWebClient.accept(MediaType.APPLICATION_JSON) > >>> .header("Content-Type", > >>> MediaType.APPLICATION_JSON) > >>> .query(QUERY_TOKEN, apiToken) > >>> .path(PATH_SERVICE_AREAS + zipCode) > >>> .get(); > >>> myWebClient.reset() > >>> > >>> Regards, > >>> Andrei. > >>>
