@@ -56,6 +56,11 @@ public abstract class RequestOptions {
5656 */
5757 private Boolean requireEncryption ;
5858
59+ /**
60+ * A value to indicate whether we should disable socket keep-alive.
61+ */
62+ private Boolean disableHttpsSocketKeepAlive ;
63+
5964 /**
6065 * Creates an instance of the <code>RequestOptions</code> class.
6166 */
@@ -78,6 +83,7 @@ public RequestOptions(final RequestOptions other) {
7883 this .setMaximumExecutionTimeInMs (other .getMaximumExecutionTimeInMs ());
7984 this .setOperationExpiryTimeInMs (other .getOperationExpiryTimeInMs ());
8085 this .setRequireEncryption (other .requireEncryption ());
86+ this .setDisableHttpsSocketKeepAlive (other .disableHttpsSocketKeepAlive ());
8187 }
8288 }
8389
@@ -132,6 +138,10 @@ protected static void populateRequestOptions(RequestOptions modifiedOptions,
132138 modifiedOptions .setOperationExpiryTimeInMs (new Date ().getTime ()
133139 + modifiedOptions .getMaximumExecutionTimeInMs ());
134140 }
141+
142+ if (modifiedOptions .disableHttpsSocketKeepAlive () == null ) {
143+ modifiedOptions .setDisableHttpsSocketKeepAlive (clientOptions .disableHttpsSocketKeepAlive ());
144+ }
135145 }
136146
137147 /**
@@ -178,18 +188,29 @@ public final LocationMode getLocationMode() {
178188 public Integer getMaximumExecutionTimeInMs () {
179189 return this .maximumExecutionTimeInMs ;
180190 }
181-
191+
182192 /**
183193 * Gets a value to indicate whether all data written and read must be encrypted. Use <code>true</code> to
184194 * encrypt/decrypt data for transactions; otherwise, <code>false</code>. For more
185195 * information about require encryption defaults, see {@link #setRequireEncryption(Boolean)}.
186- *
196+ *
187197 * @return A value to indicate whether all data written and read must be encrypted.
188198 */
189199 public Boolean requireEncryption () {
190200 return this .requireEncryption ;
191201 }
192202
203+ /**
204+ * Gets a value to indicate whether https socket keep-alive should be disabled. Use <code>true</code> to disable
205+ * keep-alive; otherwise, <code>false</code>. For more information about disableHttpsSocketKeepAlive defaults, see
206+ * {@link ServiceClient#getDefaultRequestOptions()}
207+ *
208+ * @return A value to indicate whther https socket keep-alive should be disabled.
209+ */
210+ public Boolean disableHttpsSocketKeepAlive () {
211+ return this .disableHttpsSocketKeepAlive ;
212+ }
213+
193214 /**
194215 * RESERVED FOR INTERNAL USE.
195216 *
@@ -283,8 +304,9 @@ public void setMaximumExecutionTimeInMs(Integer maximumExecutionTimeInMs) {
283304 * <p>
284305 * The default is set in the client and is by default false, indicating encryption is not required. You can change
285306 * the value on this request by setting this property. You can also change the value on the
286- * {@link ServiceClient#getDefaultRequestOptions()} object so that all subsequent requests made via the service
287- * client will use the appropriate value.
307+ * * {@link ServiceClient#getDefaultRequestOptions()} object so that all subsequent requests made via the
308+ * service
309+ * * client will use the appropriate value.
288310 *
289311 * @param requireEncryption
290312 * A value to indicate whether all data written and read must be encrypted.
@@ -293,6 +315,28 @@ public void setRequireEncryption(Boolean requireEncryption) {
293315 this .requireEncryption = requireEncryption ;
294316 }
295317
318+ /**
319+ * Sets a value to indicate whether https socket keep-alive should be disabled. Use <code>true</code> to disable
320+ * keep-alive; otherwise, <code>false</code>
321+ * <p>
322+ * The default is set in the client and is by default false, indicating that https socket keep-alive will be
323+ * enabled. You can change the value on this request by setting this property. You can also change the value on
324+ * on the {@link ServiceClient#getDefaultRequestOptions()} object so that all subsequent requests made via the
325+ * service client will use the appropriate value.
326+ * <p>
327+ * Setting keep-alive on https sockets is to work around a bug in the JVM where connection timeouts are not honored
328+ * on retried requests. In those cases, we use socket keep-alive as a fallback. Unfortunately, the timeout value
329+ * must be taken from a JVM property rather than configured locally. Therefore, in rare cases the JVM has configured
330+ * aggressively short keep-alive times, it may be beneficial to disable the use of keep-alives lest they interfere
331+ * with long running data transfer operations.
332+ *
333+ * @param disableHttpsSocketKeepAlive
334+ * A value to indicate whether https socket keep-alive should be disabled.
335+ */
336+ public void setDisableHttpsSocketKeepAlive (Boolean disableHttpsSocketKeepAlive ) {
337+ this .disableHttpsSocketKeepAlive = disableHttpsSocketKeepAlive ;
338+ }
339+
296340 /**
297341 * RESERVED FOR INTERNAL USE.
298342 *
0 commit comments