Hello,
I am precisely in a situation where I need to shutdown a client manually.
We are developing an IntelliJ plugins that uses OkHttp (https://sonarlint.org/). Since latest versions of IntelliJ, plugins can be installed and uninstalled without restarting the IDE. It means that when plugin is uninstalled we need to unload all the classes we use, and OkHttp is part of that.
I followed the guidelines here: https://square.github.io/okhttp/4.x/okhttp/okhttp3/-ok-http-client/#shutdown-isnt-necessary, and I use the latest version (4.7.2).
It appears that the steps described in this page are not sufficient. I can still see an instance of TaskRunner and RealBackend, that retains an ThreadPoolExecutor. I had to call also:
((TaskRunner.RealBackend)TaskRunner.INSTANCE.getBackend()).shutdown();
Which is a bit hacky, but this correctly released the executor.
I think this should be at least documented, or maybe improved with a better API. The shutdown method could possibly be defined in the Backend interface.
Hello,
I am precisely in a situation where I need to shutdown a client manually.
We are developing an IntelliJ plugins that uses OkHttp (https://sonarlint.org/). Since latest versions of IntelliJ, plugins can be installed and uninstalled without restarting the IDE. It means that when plugin is uninstalled we need to unload all the classes we use, and OkHttp is part of that.
I followed the guidelines here: https://square.github.io/okhttp/4.x/okhttp/okhttp3/-ok-http-client/#shutdown-isnt-necessary, and I use the latest version (4.7.2).
It appears that the steps described in this page are not sufficient. I can still see an instance of TaskRunner and RealBackend, that retains an ThreadPoolExecutor. I had to call also:
Which is a bit hacky, but this correctly released the executor.
I think this should be at least documented, or maybe improved with a better API. The
shutdownmethod could possibly be defined in theBackendinterface.