HDFS-16702. MiniDFSCluster should report cause of exception in assert error (#4680)

When the MiniDFSClsuter detects that an exception caused an exit, it should include that exception as the cause for the AssertionError that it throws. The current AssertError simply reports the message "Test resulted in an unexpected exit" and provides a stack trace to the location of the check for an exit exception. This patch adds the original exception as the cause of the AssertError.
This commit is contained in:
Steve Vaughan 2022-08-11 16:52:39 -04:00 committed by GitHub
parent 6ca2d3f848
commit 2005582a28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -2159,10 +2159,11 @@ public class MiniDFSCluster implements AutoCloseable {
LOG.info("Shutting down the Mini HDFS Cluster");
if (checkExitOnShutdown) {
if (ExitUtil.terminateCalled()) {
LOG.error("Test resulted in an unexpected exit",
ExitUtil.getFirstExitException());
Exception cause = ExitUtil.getFirstExitException();
LOG.error("Test resulted in an unexpected exit", cause);
ExitUtil.resetFirstExitException();
throw new AssertionError("Test resulted in an unexpected exit");
throw new AssertionError("Test resulted in an unexpected exit: " +
cause.toString(), cause);
}
}
if (closeFileSystem) {