HTTPClients are reusable

Hi 👋, I wanted to write this article to tell you that instantiating a HttpClient class is often a costly operation. If you have a method that does something like: public class Main { static void myMethod() { HttpClient client = new HttpClient() // do stuff } } You should refactor it ASAP. Either move the HttpClient into the class and perhaps ensure that the class is a Singleton or retrieve the HttpClient instance using an Object Pool pattern like the HttpClient class from System....

June 23, 2022 · 1 min · Denis Nuțiu