8280058: JFR: StreamUtils::getJfrRepository(Process) should print stdout and stderr

Reviewed-by: mgronlun
This commit is contained in:
Erik Gahlin 2022-01-18 17:14:42 +00:00
parent 88a8b239aa
commit 7acc4c7dfe

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -43,8 +43,10 @@ public class StreamingUtils {
public static Path getJfrRepository(Process process) throws Exception {
while (true) {
if (!process.isAlive()) {
String msg = String.format("Process (pid = %d) is no longer alive, exit value = %d",
String msg = String.format("Process (pid = %d) is no longer alive, exit value = %d\n",
process.pid(), process.exitValue());
msg += "Stderr: " + new String(process.getErrorStream().readAllBytes()) + "\n";
msg += "Stdout: " + new String(process.getInputStream().readAllBytes()) + "\n";
throw new RuntimeException(msg);
}