You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your enhancement related to a problem? Please describe
Up to version 6.3.1, it was possible to pass a custom ExecutorService to OkHttp client's Dispatcher, thanks to OkHttpClientFactory:
/** * Subclasses may use this to apply additional configuration after the Config has been applied * This method is only called for clients constructed using the Config. * * @param builder */protectedvoidadditionalConfig(OkHttpClient.Builderbuilder) {
// no default implementation
}
... which used to allow, for instance, to make sure the thread pool spawns daemon threads:
Since version 6.4.0, due to "Test/simultaneous HttpClient connections" (#4687), the default Dispatcher creation happens afteradditionalConfig, thus disregarding any user-provided ExecutorService.
Describe the solution you'd like
To get the best of both worlds, i.e. both the default Dispatcher configuration from #4687 and a daemon thread pool:
either always set a cached thread pool spawning daemon threads when configuring the default Dispatcher (assuming this forms a consensus, of course),
or allow to pass a custom ExecutorService at some stage that would be later used when configuring the default Dispatcher, for instance leveraging existingKubernetesClientBuilder.withTaskExecutor[Supplier] (probably a good option),
or mutate the builder's Dispatcher in place (obtained through builder.dispatcher()),
or invoke additionalConfigafter having configured the default Dispatcher. In this case users would have to replicate any default configuration by themselves (through [get|set]IdleCallback, [get|set]MaxRequests and [get|set]MaxRequestsPerHost as of now).
@manusa this is related to the change that moved the dispatcher configuration from the factory to the okhttp client builder. I'm fine with 1, or we can make the Dispatcher a first class member of the factory with a method like createDispatcher so that this behavior can easily be overloaded.
rdesgroppes
changed the title
Restore ability to configure OkHttp's ExecutorService (Dispatcher)
Restore ability to make OkHttp's Dispatcher use daemon threads
Feb 7, 2023
or we can make the Dispatcher a first class member of the factory with a method like createDispatcher so that this behavior can easily be overloaded.
I'll provide a fix based on this since there might be users that want further customization regardless of whatever we agree to default the Dispatcher to.
Is your enhancement related to a problem? Please describe
Up to version 6.3.1, it was possible to pass a custom
ExecutorService
to OkHttp client'sDispatcher
, thanks toOkHttpClientFactory
:... which used to allow, for instance, to make sure the thread pool spawns daemon threads:
Since version 6.4.0, due to "Test/simultaneous HttpClient connections" (#4687), the default
Dispatcher
creation happens afteradditionalConfig
, thus disregarding any user-providedExecutorService
.Describe the solution you'd like
To get the best of both worlds, i.e. both the default
Dispatcher
configuration from #4687 and a daemon thread pool:Dispatcher
(assuming this forms a consensus, of course),ExecutorService
at some stage that would be later used when configuring the defaultDispatcher
, for instance leveraging existingKubernetesClientBuilder.withTaskExecutor[Supplier]
(probably a good option),Dispatcher
in place (obtained throughbuilder.dispatcher()
),additionalConfig
after having configured the defaultDispatcher
. In this case users would have to replicate any default configuration by themselves (through[get|set]IdleCallback
,[get|set]MaxRequests
and[get|set]MaxRequestsPerHost
as of now).Describe alternatives you've considered
Something as arguable as:
Additional context
No response
The text was updated successfully, but these errors were encountered: