Reuse http client
…troying on ConnectException to avoid thread leak
I've been your library for a few months now and it works brilliantly (thanks)
However, we'd a network blip yesterday and it started causing ExecutionExeptions in the HttpClient causing a thread leak. Having a look at your code, it appears the client isn't releasing threads when exceptions occur. I'm fairly sure this PR fixes the issue ..
I've been your library for a few months now and it works brilliantly (thanks)
Happy to hear! You're welcome.
However, we'd a network blip yesterday and it started causing ExecutionExeptions in the HttpClient causing a thread leak. Having a look at your code, it appears the client isn't releasing threads when exceptions occur. I'm fairly sure this PR fixes the issue ..
I'll run some tests over the weekend and merge it if there are no problems. Your contribution is much appreciated!
Awesome, fingers crossed
On Wed, Jul 11, 2018 at 9:25 PM Martijn Dwars [email protected] wrote:
I've been your library for a few months now and it works brilliantly (thanks)
Happy to hear! You're welcome.
However, we'd a network blip yesterday and it started causing ExecutionExeptions in the HttpClient causing a thread leak. Having a look at your code, it appears the client isn't releasing threads when exceptions occur. I'm fairly sure this PR fixes the issue ..
I'll run some tests over the weekend and merge it if there are no problems. Your contribution is much appreciated!
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/web-push-libs/webpush-java/pull/62#issuecomment-404298621, or mute the thread https://github.com/notifications/unsubscribe-auth/AFBGPSGbhTSDunNU5Du8gL_jvAPi6k25ks5uFl8sgaJpZM4VLaac .
I suppose the big change that your PR introduces is that it re-uses a single HTTP client instead of creating one for each request. If you send many notifications in async, then creating a new HTTP client will waste a lot of resources. Is that correct?
Not off the top of my head, I'll see if I can cobble together a unit test to recreate it
On Thu, Jul 12, 2018 at 7:49 PM Martijn Dwars [email protected] wrote:
Any suggestions on how to reproduce the issue? I tried calling the send() method without internet connection which triggers an UnknownHostException which in turn triggers a ExecutionException. However, the UnknownHostException triggers a call to failed in the ClosableCallback which calls close() on CloseableHttpAsyncClient. I don't see any threads not being cleaned up if I call the send() method many times.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/web-push-libs/webpush-java/pull/62#issuecomment-404613058, or mute the thread https://github.com/notifications/unsubscribe-auth/AFBGPXv9ytXsNCPawgFDyZho5Jy3NjcKks5uF5o9gaJpZM4VLaac .