Skip to content

Add a warning and an exception if a watch is created with debugging enabled. #280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions util/src/main/java/io/kubernetes/client/util/Watch.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.Iterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

private static final Logger log = LoggerFactory.getLogger(Watch.class);

/**
* Response class holds a watch response that has a `type` that can be ADDED, MODIFIED, DELETED
* and ERROR. It also hold the actual target object.
Expand Down Expand Up @@ -78,6 +82,11 @@ public static class Response<T> {
*/
public static <T> Watch<T> createWatch(ApiClient client, Call call, Type watchType)
throws ApiException {
if (client.isDebugging()) {
log.warn(
"Watch is (for now) incompatible with debugging mode active. Watches will not return data until the watch connection terminates");
throw new ApiException("Watch is incompatible with debugging mode active.");
}
try {
com.squareup.okhttp.Response response = call.execute();
if (!response.isSuccessful()) {
Expand Down