|
12 | 12 | */
|
13 | 13 | package io.kubernetes.client.util;
|
14 | 14 |
|
| 15 | +import com.google.gson.JsonParseException; |
15 | 16 | import com.google.gson.annotations.SerializedName;
|
| 17 | +import com.google.gson.reflect.TypeToken; |
16 | 18 | import com.squareup.okhttp.Call;
|
17 | 19 | import com.squareup.okhttp.ResponseBody;
|
18 | 20 | import io.kubernetes.client.ApiClient;
|
19 | 21 | import io.kubernetes.client.ApiException;
|
20 | 22 | import io.kubernetes.client.JSON;
|
21 | 23 |
|
| 24 | +import io.kubernetes.client.models.V1Status; |
22 | 25 | import java.io.IOException;
|
23 | 26 | import java.lang.reflect.Type;
|
24 | 27 | import java.util.Iterator;
|
@@ -46,9 +49,18 @@ public static class Response<T> {
|
46 | 49 | @SerializedName("object")
|
47 | 50 | public T object;
|
48 | 51 |
|
| 52 | + public V1Status status; |
| 53 | + |
49 | 54 | Response(String type, T object) {
|
50 | 55 | this.type = type;
|
51 | 56 | this.object = object;
|
| 57 | + this.status = null; |
| 58 | + } |
| 59 | + |
| 60 | + Response(String type, V1Status status) { |
| 61 | + this.type = type; |
| 62 | + this.object = null; |
| 63 | + this.status = status; |
52 | 64 | }
|
53 | 65 | }
|
54 | 66 |
|
@@ -99,7 +111,13 @@ public Response<T> next() {
|
99 | 111 | if (line == null) {
|
100 | 112 | throw new RuntimeException("Null response from the server.");
|
101 | 113 | }
|
102 |
| - return json.deserialize(line, watchType); |
| 114 | + try { |
| 115 | + return json.deserialize(line, watchType); |
| 116 | + } catch (JsonParseException ex) { |
| 117 | + Type statusType = new TypeToken<Response<V1Status>>(){}.getType(); |
| 118 | + Response<V1Status> status = json.deserialize(line, statusType); |
| 119 | + return new Response<T>(status.type, status.object); |
| 120 | + } |
103 | 121 | } catch (IOException e) {
|
104 | 122 | throw new RuntimeException("IO Exception during next method.", e);
|
105 | 123 | }
|
|
0 commit comments