summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2023-07-20 11:03:09 +0200
committerSimon Rettberg2023-07-20 11:03:09 +0200
commit8ad1196886fc06ff8655fc3b0a6a0865a9c74695 (patch)
tree3e71ce7d99f14a43f2b2f1656630ffa3405fe098
parent[run-virt] Linux scripts: demo user mount non-home shares, some speedup done (diff)
downloadmltk-8ad1196886fc06ff8655fc3b0a6a0865a9c74695.tar.gz
mltk-8ad1196886fc06ff8655fc3b0a6a0865a9c74695.tar.xz
mltk-8ad1196886fc06ff8655fc3b0a6a0865a9c74695.zip
[qemu] java: Don't throw away viewer output on crash
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/viewer/ViewerUtils.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/viewer/ViewerUtils.java b/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/viewer/ViewerUtils.java
index 5012737f..5e046e3e 100644
--- a/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/viewer/ViewerUtils.java
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/viewer/ViewerUtils.java
@@ -5,6 +5,7 @@ import java.nio.charset.StandardCharsets;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.ExecuteException;
import org.apache.commons.exec.PumpStreamHandler;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
@@ -57,18 +58,19 @@ public class ViewerUtils
viewerExecutor.setStreamHandler( viewerOutputStreamHandler );
// execute the viewer command as blocking process
+ final String viewerOuput;
try {
viewerExecutor.execute( viewerCommandLine );
} catch ( IOException e ) {
throw new ViewerException( "Failed to execute '" + viewerProgram + "': " + e.getLocalizedMessage() );
- }
-
- // retrieve the content from the viewer's standard output
- final String viewerOuput = viewerOutputStream.toString( StandardCharsets.UTF_8 );
- IOUtils.closeQuietly( viewerOutputStream );
+ } finally {
+ // retrieve the content from the viewer's standard output
+ viewerOuput = viewerOutputStream.toString( StandardCharsets.UTF_8 );
+ IOUtils.closeQuietly( viewerOutputStream );
- // log content from the viewer's standard output
- ViewerUtils.LOGGER.debug( viewerOuput );
+ // log content from the viewer's standard output
+ ViewerUtils.LOGGER.debug( viewerOuput );
+ }
return viewerOuput;
}