Skip to content

Commit c3a1a80

Browse files
Merge pull request #280 from brendandburns/watch-debug
Add a warning and an exception if a watch is created with debugging enabled.
2 parents 7382152 + dfc3519 commit c3a1a80

File tree

1 file changed

+9
-0
lines changed
  • util/src/main/java/io/kubernetes/client/util

1 file changed

+9
-0
lines changed

util/src/main/java/io/kubernetes/client/util/Watch.java

+9
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import java.io.IOException;
2525
import java.lang.reflect.Type;
2626
import java.util.Iterator;
27+
import org.slf4j.Logger;
28+
import org.slf4j.LoggerFactory;
2729

2830
/**
2931
* Watch class implements watch mechansim of kubernetes. For every list API call with a watch
@@ -34,6 +36,8 @@
3436
public class Watch<T>
3537
implements Iterable<Watch.Response<T>>, Iterator<Watch.Response<T>>, java.io.Closeable {
3638

39+
private static final Logger log = LoggerFactory.getLogger(Watch.class);
40+
3741
/**
3842
* Response class holds a watch response that has a `type` that can be ADDED, MODIFIED, DELETED
3943
* and ERROR. It also hold the actual target object.
@@ -78,6 +82,11 @@ public static class Response<T> {
7882
*/
7983
public static <T> Watch<T> createWatch(ApiClient client, Call call, Type watchType)
8084
throws ApiException {
85+
if (client.isDebugging()) {
86+
log.warn(
87+
"Watch is (for now) incompatible with debugging mode active. Watches will not return data until the watch connection terminates");
88+
throw new ApiException("Watch is incompatible with debugging mode active.");
89+
}
8190
try {
8291
com.squareup.okhttp.Response response = call.execute();
8392
if (!response.isSuccessful()) {

0 commit comments

Comments
 (0)