Skip to content

Commit 4f99714

Browse files
committed
ensure watch connection closed
1 parent 0aa3b94 commit 4f99714

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.slf4j.Logger;
1010
import org.slf4j.LoggerFactory;
1111

12+
import java.io.IOException;
1213
import java.lang.reflect.Method;
1314
import java.net.ConnectException;
1415
import java.util.ArrayList;
@@ -100,6 +101,10 @@ public void run() {
100101
}
101102
log.error("ReflectRunnable#watch failed as {} unexpected", t.getMessage(), t);
102103
return;
104+
} finally {
105+
if (watch != null) {
106+
watch.close();
107+
}
103108
}
104109
}
105110
} catch (Throwable t) {
@@ -124,7 +129,7 @@ public String getLastSyncResourceVersion() {
124129
return lastSyncResourceVersion;
125130
}
126131

127-
private void watchHandler(io.kubernetes.client.util.Watch<T> watch) {
132+
private void watchHandler(io.kubernetes.client.util.Watch<T> watch) throws IOException {
128133
while (watch.hasNext()) {
129134
io.kubernetes.client.util.Watch.Response<T> item = watch.next();
130135

0 commit comments

Comments
 (0)