@@ -66,6 +66,14 @@ abstract class AbstractClientApplicationBase implements IClientApplicationBase {
66
66
@ Getter
67
67
private SSLSocketFactory sslSocketFactory ;
68
68
69
+ @ Accessors (fluent = true )
70
+ @ Getter
71
+ private Integer connectTimeoutForDefaultHttpClient ;
72
+
73
+ @ Accessors (fluent = true )
74
+ @ Getter
75
+ private Integer readTimeoutForDefaultHttpClient ;
76
+
69
77
@ Accessors (fluent = true )
70
78
@ Getter
71
79
protected TokenCache tokenCache ;
@@ -284,6 +292,8 @@ abstract static class Builder<T extends Builder<T>> {
284
292
private ITokenCacheAccessAspect tokenCacheAccessAspect ;
285
293
private AadInstanceDiscoveryResponse aadInstanceDiscoveryResponse ;
286
294
private String clientCapabilities ;
295
+ private Integer connectTimeoutForDefaultHttpClient ;
296
+ private Integer readTimeoutForDefaultHttpClient ;
287
297
288
298
/**
289
299
* Constructor to create instance of Builder of client application
@@ -446,6 +456,34 @@ public T sslSocketFactory(SSLSocketFactory val) {
446
456
return self ();
447
457
}
448
458
459
+ /**
460
+ * Sets the connect timeout value used in HttpsURLConnection connections made by {@link DefaultHttpClient},
461
+ * and is not needed if using a custom HTTP client
462
+ *
463
+ * @param val timeout value in milliseconds
464
+ * @return instance of the Builder on which method was called
465
+ */
466
+ public T connectTimeoutForDefaultHttpClient (Integer val ) {
467
+ validateNotNull ("connectTimeoutForDefaultHttpClient" , val );
468
+
469
+ connectTimeoutForDefaultHttpClient = val ;
470
+ return self ();
471
+ }
472
+
473
+ /**
474
+ * Sets the read timeout value used in HttpsURLConnection connections made by {@link DefaultHttpClient},
475
+ * and is not needed if using a custom HTTP client
476
+ *
477
+ * @param val timeout value in milliseconds
478
+ * @return instance of the Builder on which method was called
479
+ */
480
+ public T readTimeoutForDefaultHttpClient (Integer val ) {
481
+ validateNotNull ("readTimeoutForDefaultHttpClient" , val );
482
+
483
+ readTimeoutForDefaultHttpClient = val ;
484
+ return self ();
485
+ }
486
+
449
487
T telemetryConsumer (Consumer <List <HashMap <String , String >>> val ) {
450
488
validateNotNull ("telemetryConsumer" , val );
451
489
@@ -549,10 +587,12 @@ public T clientCapabilities(Set<String> capabilities) {
549
587
telemetryConsumer = builder .telemetryConsumer ;
550
588
proxy = builder .proxy ;
551
589
sslSocketFactory = builder .sslSocketFactory ;
590
+ connectTimeoutForDefaultHttpClient = builder .connectTimeoutForDefaultHttpClient ;
591
+ readTimeoutForDefaultHttpClient = builder .readTimeoutForDefaultHttpClient ;
552
592
serviceBundle = new ServiceBundle (
553
593
builder .executorService ,
554
594
builder .httpClient == null ?
555
- new DefaultHttpClient (builder .proxy , builder .sslSocketFactory ) :
595
+ new DefaultHttpClient (builder .proxy , builder .sslSocketFactory , builder . connectTimeoutForDefaultHttpClient , builder . readTimeoutForDefaultHttpClient ) :
556
596
builder .httpClient ,
557
597
new TelemetryManager (telemetryConsumer , builder .onlySendFailureTelemetry ));
558
598
authenticationAuthority = builder .authenticationAuthority ;
0 commit comments