@@ -93,6 +93,13 @@ func applyLegacyClientKeepalive(conf *confmap.Conf, keepalive *configoptional.Op
9393 * keepalive = configoptional .None [KeepaliveClientConfig ]()
9494 return
9595 }
96+ // If no legacy fields are present, defer entirely to whatever the new `keepalive`
97+ // section (or its absence) already resolved to. Using both legacy fields and the
98+ // new section simultaneously is rejected by collectLegacyKeepaliveWarnings before
99+ // this function is called, so that case cannot arise here.
100+ if ! conf .IsSet ("idle_conn_timeout" ) && ! conf .IsSet ("max_idle_conns" ) && ! conf .IsSet ("max_idle_conns_per_host" ) {
101+ return
102+ }
96103 if ! keepalive .HasValue () {
97104 * keepalive = configoptional .Some (KeepaliveClientConfig {})
98105 }
@@ -155,10 +162,15 @@ func applyLegacyServerKeepalive(conf *confmap.Conf, keepalive *configoptional.Op
155162 * keepalive = configoptional .None [KeepaliveServerConfig ]()
156163 return
157164 }
165+ // If no legacy fields are present, defer entirely to whatever the new `keepalive`
166+ // section (or its absence) already resolved to. Using both legacy fields and the
167+ // new section simultaneously is rejected by collectLegacyKeepaliveWarnings before
168+ // this function is called, so that case cannot arise here.
169+ if ! conf .IsSet ("idle_timeout" ) {
170+ return
171+ }
158172 if ! keepalive .HasValue () {
159173 * keepalive = configoptional .Some (KeepaliveServerConfig {})
160174 }
161- if conf .IsSet ("idle_timeout" ) {
162- keepalive .Get ().IdleTimeout = legacy .IdleTimeout
163- }
175+ keepalive .Get ().IdleTimeout = legacy .IdleTimeout
164176}
0 commit comments