@@ -78,24 +78,28 @@ abstract class ApiClient(
7878 defaultConnectTimeout : Duration ,
7979 defaultWriteTimeout : Duration
8080 ): Requester = {
81+ val optionsWithDefaultTimeouts = options.copy(
82+ readTimeout = defaultReadTimeout,
83+ connectTimeout = defaultConnectTimeout,
84+ writeTimeout = defaultWriteTimeout
85+ )
86+
8187 val algoliaAgent = AlgoliaAgent (BuildInfo .version)
8288 .addSegment(AgentSegment (clientName, Some (BuildInfo .version)))
83- .addSegments(options .agentSegments)
89+ .addSegments(optionsWithDefaultTimeouts .agentSegments)
8490
85- val hosts = if (options .hosts.isEmpty) defaultHosts else options .hosts
91+ val hosts = if (optionsWithDefaultTimeouts .hosts.isEmpty) defaultHosts else optionsWithDefaultTimeouts .hosts
8692 val statefulHosts = hosts.map(host => StatefulHost (host)).toList
87-
88- options.withReadTimeout(Option (options.readTimeout).getOrElse(defaultReadTimeout)).withWriteTimeout(Option (options.writeTimeout).getOrElse(defaultWriteTimeout)).withConnectTimeout(Option (options.connectTimeout).getOrElse(defaultConnectTimeout))
89-
93+
9094 val builder = HttpRequester
91- .builder(options .customFormats.getOrElse(formats))
95+ .builder(optionsWithDefaultTimeouts .customFormats.getOrElse(formats))
9296 .withInterceptor(authInterceptor)
9397 .withInterceptor(new UserAgentInterceptor (algoliaAgent))
9498 .withInterceptor(new RetryStrategy (statefulHosts))
9599
96- options .requesterConfig.foreach(_(builder))
100+ optionsWithDefaultTimeouts .requesterConfig.foreach(_(builder))
97101
98- builder.build(options )
102+ builder.build(optionsWithDefaultTimeouts )
99103 }
100104
101105 /** Executes the given request and returns the response.
0 commit comments