1414import java .util .concurrent .ExecutorService ;
1515import java .util .concurrent .Executors ;
1616import java .util .concurrent .Future ;
17+ import java .util .concurrent .TimeUnit ;
1718
1819/** SharedInformerFactory class constructs and caches informers for api types. */
1920public class SharedInformerFactory {
@@ -24,9 +25,16 @@ public class SharedInformerFactory {
2425
2526 private ExecutorService informerExecutor ;
2627
28+ private ApiClient apiClient ;
29+
2730 /** Constructor w/ default thread pool. */
2831 public SharedInformerFactory () {
29- this (Executors .newCachedThreadPool ());
32+ this (Configuration .getDefaultApiClient (), Executors .newCachedThreadPool ());
33+ }
34+
35+ /** Constructor w/ api client specified and default thread pool. */
36+ public SharedInformerFactory (ApiClient apiClient ) {
37+ this (apiClient , Executors .newCachedThreadPool ());
3038 }
3139
3240 /**
@@ -35,6 +43,17 @@ public SharedInformerFactory() {
3543 * @param threadPool specified thread pool
3644 */
3745 public SharedInformerFactory (ExecutorService threadPool ) {
46+ this (Configuration .getDefaultApiClient (), threadPool );
47+ }
48+
49+ /**
50+ * Constructor w/ api client and thread pool specified.
51+ *
52+ * @param client specific api client
53+ * @param threadPool specified thread pool
54+ */
55+ public SharedInformerFactory (ApiClient client , ExecutorService threadPool ) {
56+ apiClient = client ;
3857 informerExecutor = threadPool ;
3958 informers = new HashMap <>();
4059 startedInformers = new HashMap <>();
@@ -87,7 +106,8 @@ private <ApiType, ApiListType> ListerWatcher<ApiType, ApiListType> listerWatcher
87106 CallGenerator callGenerator ,
88107 Class <ApiType > apiTypeClass ,
89108 Class <ApiListType > apiListTypeClass ) {
90- ApiClient apiClient = Configuration .getDefaultApiClient ();
109+ // set read timeout zero to ensure client doesn't time out
110+ apiClient .getHttpClient ().setReadTimeout (0 , TimeUnit .MILLISECONDS );
91111 return new ListerWatcher <ApiType , ApiListType >() {
92112 @ Override
93113 public ApiListType list (CallGeneratorParams params ) throws ApiException {
0 commit comments