diff --git a/system-x/services/telegram/src/main/java/software/tnb/telegram/resource/openshift/OpenshiftTelegram.java b/system-x/services/telegram/src/main/java/software/tnb/telegram/resource/openshift/OpenshiftTelegram.java index 81d7ad764..31f5a818d 100644 --- a/system-x/services/telegram/src/main/java/software/tnb/telegram/resource/openshift/OpenshiftTelegram.java +++ b/system-x/services/telegram/src/main/java/software/tnb/telegram/resource/openshift/OpenshiftTelegram.java @@ -11,7 +11,7 @@ import com.google.auto.service.AutoService; -import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -118,12 +118,12 @@ public boolean isDeployed() { @Override public String execInContainer(String... commands) { - ByteArrayOutputStream baosOutput = new ByteArrayOutputStream(); - - OpenshiftClient.get().pods().withName(OpenshiftClient.get().getAnyPod(name()).getMetadata().getName()) - .writingOutput(baosOutput).exec(commands); - - return baosOutput.toString(); + try { + return new String(OpenshiftClient.get().pods().withName(OpenshiftClient.get().getAnyPod(name()).getMetadata().getName()) + .redirectingOutput().exec(commands).getOutput().readAllBytes()); + } catch (IOException e) { + throw new RuntimeException("Unable to read command output: " + e); + } } @Override