Skip to content

Commit a0c6b73

Browse files
committed
Synchronize with beta3 client changes
1 parent 7b9cc0b commit a0c6b73

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

src/main/java/oracle/kubernetes/operator/ServerStatusReader.java

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@
55

66
import java.io.IOException;
77
import java.io.InputStream;
8-
import java.nio.charset.StandardCharsets;
8+
import java.io.InputStreamReader;
9+
import java.io.Reader;
910
import java.util.ArrayList;
1011
import java.util.Collection;
1112
import java.util.Map;
1213
import java.util.concurrent.ConcurrentHashMap;
1314
import java.util.concurrent.ConcurrentMap;
1415
import java.util.concurrent.TimeUnit;
1516

17+
import com.google.common.base.Charsets;
18+
import com.google.common.io.CharStreams;
19+
1620
import io.kubernetes.client.ApiException;
1721
import io.kubernetes.client.Exec;
1822
import io.kubernetes.client.models.V1ObjectMeta;
@@ -127,25 +131,15 @@ public NextAction apply(Packet packet) {
127131
Exec exec = new Exec(holder.getApiClient());
128132
Process proc = null;
129133
try {
130-
131-
// TEST
132-
System.out.println("***** pod: " + podName);
133-
134134
proc = exec.exec(namespace, podName,
135135
new String[] { "/weblogic-operator/scripts/readState.sh" },
136136
KubernetesConstants.CONTAINER_NAME, stdin, tty);
137137

138+
InputStream in = proc.getInputStream();
138139
if (proc.waitFor(timeoutSeconds, TimeUnit.SECONDS)) {
139140
String state = null;
140-
InputStream in = proc.getInputStream();
141-
int a = in.available();
142-
if (a > 0) {
143-
byte[] data = new byte[a];
144-
in.read(data);
145-
state = new String(data, StandardCharsets.UTF_8);
146-
147-
// TEST
148-
System.out.println("***** state: " + state);
141+
try (final Reader reader = new InputStreamReader(in, Charsets.UTF_8)) {
142+
state = CharStreams.toString(reader);
149143
}
150144

151145
@SuppressWarnings("unchecked")
@@ -161,10 +155,9 @@ public NextAction apply(Packet packet) {
161155
LOGGER.warning(MessageKeys.EXCEPTION, e);
162156
} finally {
163157
helper.recycle(holder);
164-
}
165-
166-
if (proc != null) {
167-
proc.destroy();
158+
if (proc != null) {
159+
proc.destroy();
160+
}
168161
}
169162

170163
fiber.resume(packet);

0 commit comments

Comments
 (0)