Skip to content

Commit 0aa5a28

Browse files
committed
restore closeWatch
1 parent 44645e2 commit 0aa5a28

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

util/src/main/java/io/kubernetes/client/informer/cache/ReflectorRunnable.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,7 @@ public void run() {
139139
this.exceptionHandler.accept(apiTypeClass, t);
140140
return;
141141
} 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);
149143
}
150144
}
151145
} catch (ApiException e) {
@@ -170,6 +164,17 @@ public void stop() {
170164
}
171165
}
172166

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+
173178
private String initialLoad() throws ApiException {
174179
ApiListType list =
175180
listerWatcher.list(
@@ -266,11 +271,7 @@ private void watchHandler(Watchable<ApiType> watch) {
266271
log.debug("{}#Receiving resourceVersion {}", apiTypeClass, lastSyncResourceVersion);
267272
}
268273
}
269-
try {
270-
watch.close();
271-
} catch (IOException e) {
272-
log.warn("{}#Error while closing watcher", this.apiTypeClass, e);
273-
}
274+
closeWatch(watch);
274275
}
275276

276277
static <ApiType extends KubernetesObject> void defaultWatchErrorHandler(

0 commit comments

Comments
 (0)