File tree Expand file tree Collapse file tree 1 file changed +13
-12
lines changed
util/src/main/java/io/kubernetes/client/informer/cache Expand file tree Collapse file tree 1 file changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -139,13 +139,7 @@ public void run() {
139
139
this .exceptionHandler .accept (apiTypeClass , t );
140
140
return ;
141
141
} finally {
142
- if (watch != null ) {
143
- try {
144
- watch .close ();
145
- } catch (IOException e ) {
146
- log .warn ("{}#Error while closing watcher" , this .apiTypeClass , e );
147
- }
148
- }
142
+ closeWatch (watch );
149
143
}
150
144
}
151
145
} catch (ApiException e ) {
@@ -170,6 +164,17 @@ public void stop() {
170
164
}
171
165
}
172
166
167
+ private synchronized void closeWatch (Watchable <ApiType > watch ) {
168
+ try {
169
+ if (watch != null ) {
170
+ watch .close ();
171
+ watch = null ;
172
+ }
173
+ } catch (IOException e ) {
174
+ log .warn ("{}#Error while closing watcher" , this .apiTypeClass , e );
175
+ }
176
+ }
177
+
173
178
private String initialLoad () throws ApiException {
174
179
ApiListType list =
175
180
listerWatcher .list (
@@ -266,11 +271,7 @@ private void watchHandler(Watchable<ApiType> watch) {
266
271
log .debug ("{}#Receiving resourceVersion {}" , apiTypeClass , lastSyncResourceVersion );
267
272
}
268
273
}
269
- try {
270
- watch .close ();
271
- } catch (IOException e ) {
272
- log .warn ("{}#Error while closing watcher" , this .apiTypeClass , e );
273
- }
274
+ closeWatch (watch );
274
275
}
275
276
276
277
static <ApiType extends KubernetesObject > void defaultWatchErrorHandler (
You can’t perform that action at this time.
0 commit comments