Skip to content

Commit

Permalink
fix: Watcher emits error if initial response is unsuccessful
Browse files Browse the repository at this point in the history
  • Loading branch information
manusa committed Sep 20, 2020
1 parent 22f8a68 commit b8611d7
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,12 @@ public void subscribe(ObservableEmitter<WatchEvent<T>> emitter) {
final InputStreamReader isr = new InputStreamReader(is);
final BufferedReader br = new BufferedReader(isr)
) {
if (!response.isSuccessful()) {
emitter.tryOnError(
KubernetesException.forResponse("Error opening Watch connection", response));
}
String line;
while (!emitter.isDisposed() && (line = br.readLine()) != null) {
while (response.isSuccessful() && !emitter.isDisposed() && (line = br.readLine()) != null) {
final WatchEvent<T> next = converter
.convert(ResponseBody.create(MediaType.get("application/json"), line));
emitter.onNext(next);
Expand Down

0 comments on commit b8611d7

Please sign in to comment.