diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/viewer/ViewerUtils.java | 16 |
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; } |