8231287: JMap should do a better job of reporting exception it catches

Retrhow any caught exception, and always print exceptions before exiting

Reviewed-by: sspitsyn, phh
This commit is contained in:
Chris Plummer 2019-09-28 12:33:34 -07:00
parent 680fceb9ba
commit f6a5479a44
3 changed files with 7 additions and 8 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2019, 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
@ -182,9 +182,8 @@ public class JMap extends Tool {
hgw.write(fileName);
System.out.println("heap written to " + fileName);
return true;
} catch (IOException | RuntimeException exp) {
System.err.println(exp.getMessage());
return false;
} catch (IOException exp) {
throw new RuntimeException(exp);
}
}
@ -199,8 +198,7 @@ public class JMap extends Tool {
System.out.println("heap written to " + fileName);
return true;
} catch (IOException exp) {
System.err.println(exp.getMessage());
return false;
throw new RuntimeException(exp);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2019, 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
@ -116,6 +116,8 @@ public abstract class Tool implements Runnable {
try {
returnStatus = start(args);
} catch (Throwable t) {
t.printStackTrace(System.err);
} finally {
stop();
}

View File

@ -73,7 +73,6 @@ public class JShellHeapDumpTest {
System.out.println("jhsdb jmap stderr:");
System.out.println(output.getStderr());
System.out.println("###### End of all output:");
output.shouldNotContain("null");
output.shouldHaveExitValue(0);
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);