Skip to content

Commit fe15acc

Browse files
committed
Add a warning and an exception if a watch is created with debugging enabled.
1 parent 73c866c commit fe15acc

File tree

1 file changed

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

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.io.IOException;
2525
import java.lang.reflect.Type;
2626
import java.util.Iterator;
27+
import java.util.logging.Logger;
2728

2829
/**
2930
* Watch class implements watch mechansim of kubernetes. For every list API call with a watch
@@ -34,6 +35,8 @@
3435
public class Watch<T>
3536
implements Iterable<Watch.Response<T>>, Iterator<Watch.Response<T>>, java.io.Closeable {
3637

38+
private static final Logger log = LoggerFactory.getLogger(Watch.class);
39+
3740
/**
3841
* Response class holds a watch response that has a `type` that can be ADDED, MODIFIED, DELETED
3942
* and ERROR. It also hold the actual target object.
@@ -78,6 +81,10 @@ public static class Response<T> {
7881
*/
7982
public static <T> Watch<T> createWatch(ApiClient client, Call call, Type watchType)
8083
throws ApiException {
84+
if (client.isDebugging()) {
85+
log.warning("Watch is (for now) incompatible with debugging mode active. Watches will not return data until the watch connection terminates");
86+
throw new ApiException("Watch is incompatible with debugging mode active.");
87+
}
8188
try {
8289
com.squareup.okhttp.Response response = call.execute();
8390
if (!response.isSuccessful()) {

0 commit comments

Comments
 (0)