Skip to content

Commit 2005582

Browse files
authored
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.
1 parent 6ca2d3f commit 2005582

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,10 +2159,11 @@ public void shutdown(boolean deleteDfsDir, boolean closeFileSystem) {
21592159
LOG.info("Shutting down the Mini HDFS Cluster");
21602160
if (checkExitOnShutdown) {
21612161
if (ExitUtil.terminateCalled()) {
2162-
LOG.error("Test resulted in an unexpected exit",
2163-
ExitUtil.getFirstExitException());
2162+
Exception cause = ExitUtil.getFirstExitException();
2163+
LOG.error("Test resulted in an unexpected exit", cause);
21642164
ExitUtil.resetFirstExitException();
2165-
throw new AssertionError("Test resulted in an unexpected exit");
2165+
throw new AssertionError("Test resulted in an unexpected exit: " +
2166+
cause.toString(), cause);
21662167
}
21672168
}
21682169
if (closeFileSystem) {

0 commit comments

Comments
 (0)