77import com .squareup .okhttp .Call ;
88import io .kubernetes .client .ApiClient ;
99import io .kubernetes .client .ApiException ;
10- import io .kubernetes .client .ProgressRequestBody ;
11- import io .kubernetes .client .ProgressResponseBody ;
1210import io .kubernetes .client .apis .BatchV1Api ;
1311import io .kubernetes .client .apis .CoreV1Api ;
1412import io .kubernetes .client .models .V1ConfigMap ;
@@ -33,6 +31,8 @@ public class WatchBuilder {
3331 /** Ignored for watches. */
3432 private static final String START_LIST = null ;
3533
34+ private static final int ADDITIONAL_TIMEOUT_FOR_SOCKET = 60 ;
35+
3636 private static WatchFactory FACTORY = new WatchFactoryImpl ();
3737
3838 private CallParamsImpl callParams = new CallParamsImpl ();
@@ -92,7 +92,7 @@ private class ListNamespacedServiceCall implements BiFunction<ApiClient, CallPar
9292 @ Override
9393 public Call apply (ApiClient client , CallParams callParams ) {
9494 // Ensure that client doesn't time out before call or watch
95- client .getHttpClient ().setReadTimeout (callParams . getTimeoutSeconds ( ), TimeUnit .SECONDS );
95+ client .getHttpClient ().setReadTimeout (getSocketTimeout ( callParams ), TimeUnit .SECONDS );
9696
9797 try {
9898 return new CoreV1Api (client )
@@ -137,7 +137,7 @@ private class ListPodCall implements BiFunction<ApiClient, CallParams, Call> {
137137 @ Override
138138 public Call apply (ApiClient client , CallParams callParams ) {
139139 // Ensure that client doesn't time out before call or watch
140- client .getHttpClient ().setReadTimeout (callParams . getTimeoutSeconds ( ), TimeUnit .SECONDS );
140+ client .getHttpClient ().setReadTimeout (getSocketTimeout ( callParams ), TimeUnit .SECONDS );
141141
142142 try {
143143 return new CoreV1Api (client )
@@ -182,7 +182,7 @@ private class ListJobCall implements BiFunction<ApiClient, CallParams, Call> {
182182 @ Override
183183 public Call apply (ApiClient client , CallParams callParams ) {
184184 // Ensure that client doesn't time out before call or watch
185- client .getHttpClient ().setReadTimeout (callParams . getTimeoutSeconds ( ), TimeUnit .SECONDS );
185+ client .getHttpClient ().setReadTimeout (getSocketTimeout ( callParams ), TimeUnit .SECONDS );
186186
187187 try {
188188 return new BatchV1Api (client )
@@ -227,7 +227,7 @@ private class ListEventCall implements BiFunction<ApiClient, CallParams, Call> {
227227 @ Override
228228 public Call apply (ApiClient client , CallParams callParams ) {
229229 // Ensure that client doesn't time out before call or watch
230- client .getHttpClient ().setReadTimeout (callParams . getTimeoutSeconds ( ), TimeUnit .SECONDS );
230+ client .getHttpClient ().setReadTimeout (getSocketTimeout ( callParams ), TimeUnit .SECONDS );
231231
232232 try {
233233 return new CoreV1Api (client )
@@ -272,7 +272,7 @@ private class ListDomainsCall implements BiFunction<ApiClient, CallParams, Call>
272272 @ Override
273273 public Call apply (ApiClient client , CallParams callParams ) {
274274 // Ensure that client doesn't time out before call or watch
275- client .getHttpClient ().setReadTimeout (callParams . getTimeoutSeconds ( ), TimeUnit .SECONDS );
275+ client .getHttpClient ().setReadTimeout (getSocketTimeout ( callParams ), TimeUnit .SECONDS );
276276
277277 try {
278278 return new WeblogicApi (client )
@@ -320,7 +320,7 @@ private class ListNamespacedConfigMapCall implements BiFunction<ApiClient, CallP
320320 @ Override
321321 public Call apply (ApiClient client , CallParams callParams ) {
322322 // Ensure that client doesn't time out before call or watch
323- client .getHttpClient ().setReadTimeout (callParams . getTimeoutSeconds ( ), TimeUnit .SECONDS );
323+ client .getHttpClient ().setReadTimeout (getSocketTimeout ( callParams ), TimeUnit .SECONDS );
324324
325325 try {
326326 return new CoreV1Api (client )
@@ -343,6 +343,10 @@ public Call apply(ApiClient client, CallParams callParams) {
343343 }
344344 }
345345
346+ private Integer getSocketTimeout (CallParams callParams ) {
347+ return callParams .getTimeoutSeconds () + ADDITIONAL_TIMEOUT_FOR_SOCKET ;
348+ }
349+
346350 /**
347351 * Sets a value for the fieldSelector parameter for the call that will set up this watch. Defaults
348352 * to null.
@@ -355,7 +359,8 @@ public WatchBuilder withFieldSelector(String fieldSelector) {
355359 return this ;
356360 }
357361
358- public WatchBuilder withIncludeUninitialized (Boolean includeUninitialized ) {
362+ @ SuppressWarnings ("SameParameterValue" )
363+ WatchBuilder withIncludeUninitialized (Boolean includeUninitialized ) {
359364 callParams .setIncludeUninitialized (includeUninitialized );
360365 return this ;
361366 }
@@ -370,16 +375,12 @@ public WatchBuilder withLabelSelectors(String... labelSelectors) {
370375 return this ;
371376 }
372377
373- public WatchBuilder withLimit (Integer limit ) {
378+ @ SuppressWarnings ("SameParameterValue" )
379+ WatchBuilder withLimit (Integer limit ) {
374380 callParams .setLimit (limit );
375381 return this ;
376382 }
377383
378- public WatchBuilder withPrettyPrinting () {
379- callParams .setPretty ("true" );
380- return this ;
381- }
382-
383384 public WatchBuilder withResourceVersion (String resourceVersion ) {
384385 callParams .setResourceVersion (resourceVersion );
385386 return this ;
@@ -390,17 +391,6 @@ public WatchBuilder withTimeoutSeconds(Integer timeoutSeconds) {
390391 return this ;
391392 }
392393
393- public WatchBuilder withProgressListener (ProgressResponseBody .ProgressListener progressListener ) {
394- callParams .setProgressListener (progressListener );
395- return this ;
396- }
397-
398- public WatchBuilder withProgressRequestListener (
399- ProgressRequestBody .ProgressRequestListener progressRequestListener ) {
400- callParams .setProgressRequestListener (progressRequestListener );
401- return this ;
402- }
403-
404394 static class WatchFactoryImpl implements WatchFactory {
405395 @ Override
406396 public <T > WatchI <T > createWatch (
@@ -411,7 +401,7 @@ public <T> WatchI<T> createWatch(
411401 throws ApiException {
412402 ApiClient client = pool .take ();
413403 try {
414- return new WatchImpl <T >(
404+ return new WatchImpl <>(
415405 pool ,
416406 client ,
417407 Watch .createWatch (
0 commit comments